AssemblyAI Streaming & Live Transcription Skill
Overview
Use this skill to build and maintain code that talks to AssemblyAI’s:
- Streaming Speech-to-Text (STT) via WebSockets (
wss://streaming.assemblyai.com/v3/ws)
- Async / pre-recorded STT via REST (
https://api.assemblyai.com/v2/transcript)
- LLM Gateway for applying Claude/GPT/Gemini-style models to transcripts (
https://llm-gateway.assemblyai.com)
The emphasis is on streaming/live transcription, meeting notetakers, and voice agents, while still covering async workflows and post-processing.
This skill assumes a Claude Code environment with access to Python (preferred) and Bash.
When to Use
Use this skill when:
- Implementing real-time transcription from a microphone, telephony stream, or audio file.
- Building a live meeting notetaker (Zoom/Teams/Meet), especially with summaries, action items, and highlights.
- Implementing a voice agent where latency and natural turn-taking matter.
- Migrating from other STT providers (OpenAI/Deepgram/Google/AWS/etc.) to AssemblyAI.
- Applying LLMs to audio via LLM Gateway for summaries, Q&A, topic tagging, or custom prompts.
Do not use this skill when:
- The task is generic HTTP client usage with no AssemblyAI-specific logic.
- The request clearly targets a different STT vendor.
- The environment cannot safely store or use an API key.
AssemblyAI Mental Model
1. Products to care about
Pre-recorded Speech-to-Text (Async)
- REST API:
POST /v2/transcript → GET /v2/transcript/{id}
- Designed for files from URLs, uploads, S3, etc.
- Supports extra models: summarization, topic detection, sentiment, PII redaction, chapters, etc.
Streaming Speech-to-Text
- WebSocket:
wss://streaming.assemblyai.com/v3/ws
- Low-latency, immutable transcripts (~300ms).
- Turn detection built in; fits voice agents and live captioning.
LLM Gateway
- REST API:
POST /v1/chat/completions at https://llm-gateway.assemblyai.com
- Unified access to multiple LLMs (Claude, GPT, Gemini, etc.).
- Designed for “LLM over transcripts” workflows.
2. Key model knobs (Async)
speech_models: ["slam-1", "universal"] etc.
- Slam-1: best English accuracy + keyterms_prompt, good for medical/technical conversations.
- Universal: multilingual coverage; good default if language is unknown.
language_code vs language_detection:
- Use
language_code when the language is known.
- Use
language_detection: true when unknown; optionally set language_confidence_threshold.
keyterms_prompt:
- Domain words/phrases to boost (med terms, product names, etc.).
- Extra intelligence:
summarization, iab_categories, content_safety, entity_detection, auto_chapters, sentiment_analysis, speaker_labels, auto_highlights, redact_pii, etc.
3. Key model knobs (Streaming)
Connection URL:
- US:
wss://streaming.assemblyai.com/v3/ws
- EU:
wss://streaming.eu.assemblyai.com/v3/ws
Important query parameters:
sample_rate (required): e.g. 16000
format_turns (bool): return formatted final transcripts; avoid for low-latency voice agents.
speech_model: universal-streaming-english (default) or universal-streaming-multi.
- `keyterms_p
rompt: JSON-encoded list of terms, e.g. ["AssemblyAI", "Slam-1", "Keanu Reeves"]`.
- Turn detection:
end_of_turn_confidence_threshold (0.0–1.0, default ~0.4)
min_end_of_turn_silence_when_confident (ms, default ~400)
max_turn_silence (ms, default ~1280)
Headers:
- Use either
Authorization: <API_KEY> or a short-lived token query parameter issued by your backend.
Messages:
- Client sends:
- Binary audio chunks (50–1000ms each).
- Optional JSON messages:
{"type": "UpdateConfig", ...}, {"type": "Terminate"}, {"type": "ForceEndpoint"}.
- Server sends:
Begin event with id, expires_at.
Turn events with:
transcript (immutable partials/finals),
utterance (complete semantic chunk),
end_of_turn (bool),
turn_is_formatted (bool),
words array with timestamps/confidences.
Termination event with summary stats.
4. Regions and data residency
- Async:
- US:
https://api.assemblyai.com
- EU:
https://api.eu.assemblyai.com
- Streaming:
- US:
wss://streaming.assemblyai.com/v3/ws
- EU:
wss://streaming.eu.assemblyai.com/v3/ws
Always keep base URLs consistent per project; don’t mix US/EU endpoints for the same data.
Security & API Keys
- Always require an AssemblyAI API key and keep it out of source in Claude Code output:
- Use environment variables:
ASSEMBLYAI_API_KEY.
- Or placeholders (
"<YOUR_API_KEY>") in snippets.
- For browser/client code:
- Do not embed the API key.
- Instruct the user to generate temporary streaming tokens on their backend and pass only the token into the WebSocket connection.
- Never print real keys in logs or comments.
High-Level Workflow Patterns
Decision tree
Is the audio live?
- Yes → Use Streaming STT.
- No → Use Async STT.
Is latency critical (<1s) for responses?
- Yes → Streaming with
format_turns=false and careful turn detection.
- No → Async, then Summarization/Chapters/etc.
Do transcripts leave the backend?
- Yes → Consider
redact_pii (and optionally redact_pii_audio) before sharing.
- No → Use raw transcripts as needed.
Need LLM-based processing (Q&A, structured summaries)?
- Yes → Pipe transcripts into LLM Gateway via
chat/completions.
How Claude Should Work with This Skill
General principles
- Prefer official AssemblyAI SDKs (Python/JS) when available; fall back to
requests/websocket-client only if SDK cannot be installed.
- Always:
- Validate HTTP responses and WebSocket status.
- Surface useful error messages (
status, error fields in transcript JSON).
- Respect documented min/max chunk sizes (50–1000ms of audio per binary message).
- For voice-agent code, optimize for:
- Immutable partials (
transcript) and utterance field.
- Minimal latency, avoid extra formatting passes.
Recipe 1 – Minimal Streaming from Microphone (Python SDK)
Goal: Stream mic audio to AssemblyAI and print transcripts in real time.
Use this when the environment has Python and assemblyai + pyaudio installed, and the user wants a quick streaming demo.
import assemblyai as aai
from assemblyai.streaming import v3 as aai_stream
import pyaudio
API_KEY = "<YOUR_API_KEY>"
aai.settings.api_key = API_KEY
SAMPLE_RATE = 16000
CHUNK_MS = 50
FRAMES_PER_BUFFER = int(SAMPLE_RATE * (CHUNK_MS / 1000.0))
def main():
client = aai_stream.StreamingClient(
aai_stream.StreamingClientOptions(
api_key=API_KEY,
api_host="streaming.assemblyai.com", # or "streaming.eu.assemblyai.com"
)
)
def on_begin(_client, event: aai_stream.BeginEvent):
print(f"Session started: {event.id}, expires at {event.expires_at}")
def on_turn(_client, event: aai_stream.TurnEvent):
# Use immutable transcript text
text = (event.transcript or "").strip()
if not text:
return
# Use formatted finals only for display; keep unformatted for LLMs
if event.turn_is_formatted:
print(f"[FINAL] {text}")
else:
print(f"[PARTIAL] {text}", end="\r")
def on_terminated(_client, event: aai_stream.TerminationEvent):
print(f"\nTerminated. Audio duration={event.audio_duration_seconds}s")
def on_error(_client, error: aai_stream.StreamingError):
print(f"\nStreaming error: {error}")
client.on(aai_stream.StreamingEvents.Begin, on_begin)
client.on(aai_stream.StreamingEvents.Turn, on_turn)
client.on(aai_stream.StreamingEvents.Termination, on_terminated)
client.on(aai_stream.StreamingEvents.Error, on_error)
client.connect(
aai_stream.StreamingParameters(
sample_rate=SAMPLE_RATE,
format_turns=False, # better latency for voice agents
)
)
pa = pyaudio.PyAudio()
stream = pa.open(
format=pyaudio.paInt16,
channels=1,
rate=SAMPLE_RATE,
input=True,
frames_per_buffer=FRAMES_PER_BUFFER,
)
try:
print("Speak into your microphone (Ctrl+C to stop)...")
def audio_gen():
while True:
yield stream.read(FRAMES_PER_BUFFER, exception_on_overflow=False)
client.stream(audio_gen())
except KeyboardInterrupt:
pass
finally:
client.disconnect(terminate=True)
stream.stop_stream()
stream.close()
pa.terminate()
if __name__ == "__main__":
main()
1---2name: assemblyai-streaming3description: This skill should be used when working with AssemblyAI’s Speech-to-Text and LLM Gateway APIs, especially for streaming/live transcription, meeting notetakers, and voice agents that need low-latency transcripts and audio analysis.4license: MIT5allowed-tools:6 - Read7 - Write8 - Edit9 - Grep10 - Glob11 - Bash12 - Python13metadata:14 source: https://skillmd.com/skills/levalencia/assemblyai-streaming15 skill-version: "1.0.0"16 upstream-docs: "https://www.assemblyai.com/docs"17 focus: "streaming-stt, meeting-notetaker, voice-agent, llm-gateway"18---1920# AssemblyAI Streaming & Live Transcription Skill2122## Overview2324Use this skill to build and maintain code that talks to AssemblyAI’s:2526- **Streaming Speech-to-Text (STT)** via WebSockets (`wss://streaming.assemblyai.com/v3/ws`)27- **Async / pre-recorded STT** via REST (`https://api.assemblyai.com/v2/transcript`)28- **LLM Gateway** for applying Claude/GPT/Gemini-style models to transcripts (`https://llm-gateway.assemblyai.com`)2930The emphasis is on **streaming/live transcription**, **meeting notetakers**, and **voice agents**, while still covering async workflows and post-processing.3132This skill assumes a Claude Code environment with access to Python (preferred) and Bash.3334---3536## When to Use3738Use this skill when:3940- Implementing **real-time transcription** from a microphone, telephony stream, or audio file.41- Building a **live meeting notetaker** (Zoom/Teams/Meet), especially with summaries, action items, and highlights.42- Implementing a **voice agent** where latency and natural turn-taking matter.43- Migrating from other STT providers (OpenAI/Deepgram/Google/AWS/etc.) to AssemblyAI.44- Applying **LLMs to audio** via LLM Gateway for summaries, Q&A, topic tagging, or custom prompts.4546Do **not** use this skill when:4748- The task is generic HTTP client usage with no AssemblyAI-specific logic.49- The request clearly targets a different STT vendor.50- The environment cannot safely store or use an API key.5152---5354## AssemblyAI Mental Model5556### 1. Products to care about57581. **Pre-recorded Speech-to-Text (Async)**59 - REST API: `POST /v2/transcript` → `GET /v2/transcript/{id}`60 - Designed for files from URLs, uploads, S3, etc.61 - Supports extra models: summarization, topic detection, sentiment, PII redaction, chapters, etc.62632. **Streaming Speech-to-Text**64 - WebSocket: `wss://streaming.assemblyai.com/v3/ws`65 - Low-latency, immutable transcripts (~300ms).66 - Turn detection built in; fits voice agents and live captioning.67683. **LLM Gateway**69 - REST API: `POST /v1/chat/completions` at `https://llm-gateway.assemblyai.com`70 - Unified access to multiple LLMs (Claude, GPT, Gemini, etc.).71 - Designed for “LLM over transcripts” workflows.7273### 2. Key model knobs (Async)7475- `speech_models`: `["slam-1", "universal"]` etc.76 - **Slam-1**: best English accuracy + keyterms_prompt, good for medical/technical conversations.77 - **Universal**: multilingual coverage; good default if language is unknown.78- `language_code` vs `language_detection`:79 - Use `language_code` when the language is known.80 - Use `language_detection: true` when unknown; optionally set `language_confidence_threshold`.81- `keyterms_prompt`:82 - Domain words/phrases to boost (med terms, product names, etc.).83- Extra intelligence: `summarization`, `iab_categories`, `content_safety`, `entity_detection`, `auto_chapters`, `sentiment_analysis`, `speaker_labels`, `auto_highlights`, `redact_pii`, etc.8485### 3. Key model knobs (Streaming)8687Connection URL:8889- US: `wss://streaming.assemblyai.com/v3/ws`90- EU: `wss://streaming.eu.assemblyai.com/v3/ws`9192Important query parameters:9394- `sample_rate` (required): e.g. `16000`95- `format_turns` (bool): return formatted final transcripts; **avoid** for low-latency voice agents.96- `speech_model`: `universal-streaming-english` (default) or `universal-streaming-multi`.97- `keyterms_p9899rompt`: JSON-encoded list of terms, e.g. `["AssemblyAI", "Slam-1", "Keanu Reeves"]`.100- Turn detection:101 - `end_of_turn_confidence_threshold` (0.0–1.0, default ~0.4)102 - `min_end_of_turn_silence_when_confident` (ms, default ~400)103 - `max_turn_silence` (ms, default ~1280)104105Headers:106107- Use either `Authorization: <API_KEY>` or a short-lived `token` query parameter issued by your backend.108109Messages:110111- Client sends:112 - Binary audio chunks (50–1000ms each).113 - Optional JSON messages: `{"type": "UpdateConfig", ...}`, `{"type": "Terminate"}`, `{"type": "ForceEndpoint"}`.114- Server sends:115 - `Begin` event with `id`, `expires_at`.116 - `Turn` events with:117 - `transcript` (immutable partials/finals),118 - `utterance` (complete semantic chunk),119 - `end_of_turn` (bool),120 - `turn_is_formatted` (bool),121 - `words` array with timestamps/confidences.122 - `Termination` event with summary stats.123124### 4. Regions and data residency125126- Async:127 - US: `https://api.assemblyai.com`128 - EU: `https://api.eu.assemblyai.com`129- Streaming:130 - US: `wss://streaming.assemblyai.com/v3/ws`131 - EU: `wss://streaming.eu.assemblyai.com/v3/ws`132133Always keep base URLs consistent per project; don’t mix US/EU endpoints for the same data.134135---136137## Security & API Keys138139- Always require an AssemblyAI API key and keep it **out of source** in Claude Code output:140 - Use environment variables: `ASSEMBLYAI_API_KEY`.141 - Or placeholders (`"<YOUR_API_KEY>"`) in snippets.142- For browser/client code:143 - Do **not** embed the API key.144 - Instruct the user to generate **temporary streaming tokens** on their backend and pass only the token into the WebSocket connection.145- Never print real keys in logs or comments.146147---148149## High-Level Workflow Patterns150151### Decision tree1521531. **Is the audio live?**154 - Yes → Use **Streaming STT**.155 - No → Use **Async STT**.1561572. **Is latency critical (<1s) for responses?**158 - Yes → Streaming with `format_turns=false` and careful turn detection.159 - No → Async, then Summarization/Chapters/etc.1601613. **Do transcripts leave the backend?**162 - Yes → Consider `redact_pii` (and optionally `redact_pii_audio`) before sharing.163 - No → Use raw transcripts as needed.1641654. **Need LLM-based processing (Q&A, structured summaries)?**166 - Yes → Pipe transcripts into **LLM Gateway** via `chat/completions`.167168---169170## How Claude Should Work with This Skill171172### General principles173174- Prefer **official AssemblyAI SDKs** (Python/JS) when available; fall back to `requests`/`websocket-client` only if SDK cannot be installed.175- Always:176 - Validate HTTP responses and WebSocket status.177 - Surface useful error messages (`status`, `error` fields in transcript JSON).178 - Respect documented min/max chunk sizes (50–1000ms of audio per binary message).179- For voice-agent code, optimize for:180 - Immutable partials (`transcript`) and `utterance` field.181 - Minimal latency, avoid extra formatting passes.182183---184185## Recipe 1 – Minimal Streaming from Microphone (Python SDK)186187> Goal: Stream mic audio to AssemblyAI and print transcripts in real time.188189Use this when the environment has Python and `assemblyai` + `pyaudio` installed, and the user wants a quick streaming demo.190191```python192import assemblyai as aai193from assemblyai.streaming import v3 as aai_stream194import pyaudio195196API_KEY = "<YOUR_API_KEY>"197198aai.settings.api_key = API_KEY199200SAMPLE_RATE = 16000201CHUNK_MS = 50202FRAMES_PER_BUFFER = int(SAMPLE_RATE * (CHUNK_MS / 1000.0))203204def main():205 client = aai_stream.StreamingClient(206 aai_stream.StreamingClientOptions(207 api_key=API_KEY,208 api_host="streaming.assemblyai.com", # or "streaming.eu.assemblyai.com"209 )210 )211212 def on_begin(_client, event: aai_stream.BeginEvent):213 print(f"Session started: {event.id}, expires at {event.expires_at}")214215 def on_turn(_client, event: aai_stream.TurnEvent):216 # Use immutable transcript text217 text = (event.transcript or "").strip()218 if not text:219 return220 # Use formatted finals only for display; keep unformatted for LLMs221 if event.turn_is_formatted:222 print(f"[FINAL] {text}")223 else:224 print(f"[PARTIAL] {text}", end="\r")225226 def on_terminated(_client, event: aai_stream.TerminationEvent):227 print(f"\nTerminated. Audio duration={event.audio_duration_seconds}s")228229 def on_error(_client, error: aai_stream.StreamingError):230 print(f"\nStreaming error: {error}")231232 client.on(aai_stream.StreamingEvents.Begin, on_begin)233 client.on(aai_stream.StreamingEvents.Turn, on_turn)234 client.on(aai_stream.StreamingEvents.Termination, on_terminated)235 client.on(aai_stream.StreamingEvents.Error, on_error)236237 client.connect(238 aai_stream.StreamingParameters(239 sample_rate=SAMPLE_RATE,240 format_turns=False, # better latency for voice agents241 )242 )243244 pa = pyaudio.PyAudio()245 stream = pa.open(246 format=pyaudio.paInt16,247 channels=1,248 rate=SAMPLE_RATE,249 input=True,250 frames_per_buffer=FRAMES_PER_BUFFER,251 )252253 try:254 print("Speak into your microphone (Ctrl+C to stop)...")255 def audio_gen():256 while True:257 yield stream.read(FRAMES_PER_BUFFER, exception_on_overflow=False)258 client.stream(audio_gen())259 except KeyboardInterrupt:260 pass261 finally:262 client.disconnect(terminate=True)263 stream.stop_stream()264 stream.close()265 pa.terminate()266267if __name__ == "__main__":268 main()