Commit f374b42
feat(assemblyai): new STT plugin for Universal-Streaming (v3)
Adds a new `@livekit/agents-plugin-assemblyai` STT plugin that connects to
AssemblyAI's Universal-Streaming v3 WebSocket API. Ported line-by-line from
the Python `livekit-plugins-assemblyai` plugin; every non-trivial block has
a `// Ref: python .../stt.py - N-M lines` comment pointing back to the
source so future syncs are straightforward.
Architecture follows the existing Deepgram STT plugin: retry loop around a
single WebSocket lifetime, concurrent sendTask/listenTask/configTask under
`#runWS`, graceful close via `{"type":"Terminate"}`.
Key features:
- All AssemblyAI v3 options exposed: speechModel (universal-streaming-*,
u3-rt-pro), sampleRate, bufferSizeMs, min/maxTurnSilence, formatTurns,
keytermsPrompt, prompt (u3-rt-pro only), vadThreshold, endOfTurnConfidenceThreshold,
speakerLabels, maxSpeakers, domain, custom baseUrl (for EU region).
- Live config updates via `UpdateConfiguration` messages over the active
socket — no reconnect needed, unlike Deepgram's updateOptions.
- `forceEndpoint()` to finalize the current turn on demand.
- `sessionId` / `expiresAt` getters for debugging; `sessionId` is also
propagated as `requestId` on RECOGNITION_USAGE events.
- Turn-event mapping: `Turn` message → INTERIM_TRANSCRIPT (cumulative),
PREFLIGHT_TRANSCRIPT (chunk-based from `utterance`), FINAL_TRANSCRIPT +
END_OF_SPEECH on `end_of_turn` (with `turn_is_formatted` check when
`formatTurns` is enabled).
- Word timestamps converted from ms → seconds for `createTimedString`.
- `u3-pro` → `u3-rt-pro` rename handled with deprecation warning (matches
Python).
Known framework gap: `stt.SpeechData` in `@livekit/agents` doesn't yet have
a `speakerId` field, so per-word speaker labels from AssemblyAI's
diarization are not surfaced on emitted events. The `speakerLabels` option
is exposed and sent to the server; a follow-up PR can wire through speaker
ids once the base type is extended. See the TSDoc on `speakerLabels` for
the exact forwarding point.
Smoke-tested end-to-end against the AssemblyAI API using the shared
`@livekit/agents-plugins-test` STT harness; transcription matches the
reference transcript within the 20% Levenshtein threshold.
Also adds `ASSEMBLYAI_API_KEY` to `turbo.json` globalEnv (required for
lint to pass).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent adf2651 commit f374b42
12 files changed
Lines changed: 812 additions & 1 deletion
File tree
- .changeset
- plugins/assemblyai
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments