AssemblyAI
Transcribe recordings and live audio with assemblyai(): streaming partials, word timings and speaker labels. No AssemblyAI package needed.
assemblyai() is a speech-to-text provider. listen uses AssemblyAI's streaming WebSocket and transcribe uploads the audio and waits for the transcript.
Install
npm install voiceai-sdkpnpm add voiceai-sdkyarn add voiceai-sdkbun add voiceai-sdkSet ASSEMBLYAI_API_KEY on your server, and keep it out of browser bundles.
Quickstart
import { createSession } from "voiceai-sdk";
import { assemblyai } from "voiceai-sdk/assemblyai";
await using session = await createSession(assemblyai());
const result = await session.transcribe(await Bun.file("meeting.wav").bytes());
console.log(result.ok, result.text);This prints true and the transcript. If the file has no speech, ok is false and reason is "no_speech". await using closes the session when the block ends.
What it supports
| Feature | Support | Notes |
|---|---|---|
Speech-to-text (transcribe) | Yes | |
Streaming transcripts (listen) | Yes | |
Text-to-speech (speak) | No | Use a pipeline with a text-to-speech provider |
| Streaming speech | No | |
| Speech-to-speech | No | |
| Word timings | Yes | |
| Speaker labels | Yes | Batch transcripts only |
| Interruptions | No | |
Voice list (listVoices) | No | |
pause() and resume() | No |
The capability matrix compares these with every other provider.
Stream transcripts
Iterate session.listen to get partial transcripts while someone speaks and a final one when they stop.
import { createSession } from "voiceai-sdk";
import { assemblyai } from "voiceai-sdk/assemblyai";
await using session = await createSession(assemblyai(), { language: "en", sampleRate: 16000 });
for await (const t of session.listen(microphone())) {
if (t.type === "final") console.log(`[${t.startMs}ms] ${t.text}`);
}microphone() stands for any AsyncIterable<Uint8Array> of 16-bit PCM, such as a transport or a file stream.
Use it in a pipeline
AssemblyAI only transcribes. For a conversation, combine it with a provider that speaks.
import { createSession } from "voiceai-sdk";
import { assemblyai } from "voiceai-sdk/assemblyai";
import { elevenlabs } from "voiceai-sdk/elevenlabs";
await using session = await createSession({ stt: assemblyai(), tts: elevenlabs({ voice: process.env.VOICE_ID }) });
await session.converse(async (text) => answer(text));Configuration
Pass options to assemblyai(). Options that have an environment variable fall back to it.
| Option | Type | Default | Env var |
|---|---|---|---|
apiKey | string | ASSEMBLYAI_API_KEY | |
speechModel | string | Provider default | |
speakerLabels | boolean | false | |
pollIntervalMs | number | 1000 |
Call the API directly
session.native is the streaming socket while listen runs.
import { createSession } from "voiceai-sdk";
import { assemblyai } from "voiceai-sdk/assemblyai";
await using session = await createSession(assemblyai());
session.native.send(JSON.stringify({ type: "ForceEndpoint" }));Limitations
speakfails withunsupported. Pair AssemblyAI with a text-to-speech provider.- Speaker labels are available for
transcribe, not forlisten.
How it works
transcribeuploads the audio, creates a transcript, and polls until it completes or the session closes.- Streaming turns map to
finalevents. Unfinished turns are sent aspartialevents.
Next steps
- Lifecycle and cleanup
- Give your agent a voice
- Compare providers: the same features on every other provider