Skip to main content
Stream live audio over a WebSocket and get the transcript turn by turn while people speak. transcribe-stream-1 does more than transcribe: it decides when the user has finished their turn, usually tells the user talking to your app apart from background sound, and notices when a “mm-hm” is only an acknowledgement. This helps your voice agent decide when to answer, when to keep talking and when to stop. Connect to wss://api.fish.audio/v1/asr/realtime, send audio as you capture it, and read the events the server sends back.

API reference

Every message, field, error and limit.

Quickstart

Stream a file or a browser microphone.

Voice agent guide

Turn-taking, interruptions and backchannels.

When to use it

Voice agents

Know when the user has finished, start replies early, and handle interruptions.

Live captions

Show live drafts as people speak, then the final text for each turn.

Voice commands

Act on what the user said as soon as the turn ends, or on button release with push-to-talk.

Phone calls

Stream 8 kHz call audio as it arrives. Decode μ-law or A-law audio to 16-bit PCM first; the server converts the sample rate.
To transcribe a recording you already have, use POST /v1/asr with transcribe-1-pro instead: The realtime endpoints of the compatible APIs are separate from this endpoint. They use manual commit and have no server-side turn detection.

Models

Two models serve this endpoint, with the same turn detection, messages, and limits. Choose one with the model header when you connect.
  • transcribe-stream-1: the default. A connection without the model header, or with any other value, uses it.
  • transcribe-stream-2: send model: transcribe-stream-2, written exactly. It also takes results.text_format in config: "written" (the default) for digits and symbols, or "spoken" for words, the way they were said. transcribe-stream-1 refuses a config that sends text_format, with invalid_config. transcribe-stream-2 also takes results.primary_speaker (true transcribes the person speaking to your agent and leaves out background voices) and language_hints (the languages you expect, such as ["en"]).
session_started.config.model names the model that serves the session.

Quick start

With the Python or TypeScript SDK, pass an iterator of audio chunks and read the events it returns. Install it with pip install --upgrade fish-audio-sdk or npm install fish-audio and set FISH_API_KEY in your environment.
The Python example reads a WAV file and the TypeScript example reads raw PCM; to make speech.pcm, run ffmpeg -i input.mp3 -ac 1 -ar 16000 -f s16le speech.pcm. Transcripts start with a speaker tag such as <|speaker:0|> by default; diarize=False (diarize: false in TypeScript) gives plain text. With AsyncFishAudio, pass an async iterator and read the events with async for.
client.asr.stream_websocket() requires fish-audio-sdk 1.5.0 or later. client.speechToText.convertRealtime() requires fish-audio 0.2.0 or later and runs in Node.js only. For the control methods and errors of both SDKs, see Choose what you receive in the recipe.

Without the SDK

In other languages and in browsers, connect with any WebSocket client and exchange MessagePack messages. The SDKs do these steps for you.
1

Connect

Open wss://api.fish.audio/v1/asr/realtime from your server with the header Authorization: Bearer <API key>.
2

Configure the session

Send a config message with your audio format and options, and wait for session_started.
3

Stream audio

Send audio messages with 16-bit mono PCM, 20–40 ms each, as you capture it.
4

Read the transcript

Each turn ends with one committed message holding its final text. Answer it if user_turn is true.
5

Finish

Send audio_done. The server commits the last turn, sends session_done and closes the connection.
Transcribe a live audio stream has a complete recipe with the Python and TypeScript SDKs, WebSocket clients in Python and Node.js, and a browser microphone page with a server relay.

How a session works

Audio is divided into turns. A turn opens when voice activity begins (speech_start), usually before the server knows what the sound is: the user speaking, a short acknowledgement, noise or another voice. It ends with exactly one committed message, which holds the final transcript and says why the turn ended. In between, you can receive live draft text and turn signals that tell you what the turn is. In the default auto mode, with results.drafts and turn_detection.eager turned on as in the example above:
  • draft: the turn’s text so far. Drafts come in every kind of turn, so a draft does not mean the user is talking. A draft’s settled_text is the beginning of its text that the server is confident will not change, so live captions can show it as stable.
  • user_turn_taken: the server judged that the user is taking their turn.
  • user_backchannel: while your agent is speaking (see Backchannel detection), the user only acknowledged; keep talking. If the user goes on to take the turn, user_turn_taken follows, and the turn that holds the acknowledgement is the user’s. That can be a new turn, with its own speech_start.
  • eager_end_of_turn: the turn has probably ended; its text equals the final transcript unless turn_resumed follows. Only the user’s turns get it, and not every one does.
  • committed: the final transcript. user_turn says whether it was the user’s turn, and turn_kind what it was otherwise.
So do not stop your agent on speech_start or on a draft: noise opens turns and gets drafts too. Wait for user_turn_taken. In vad and manual mode there is no user_turn_taken: every turn is a user turn, so stop on speech_start there (see Turn detection modes).

Smart Turn Detection

In the default auto mode, the server’s turn detection decides when a turn ends, from what was said and how, not from silence alone.

Eager end of turn

With turn_detection.eager: true, you receive eager_end_of_turn as soon as the turn has probably ended, before the final transcript. Its text is exactly the text committed will have, unless turn_resumed follows because the user went on. A voice agent can start its LLM on the eager text and save that time.

Backchannel detection

Tell the server when your agent is speaking with agent_speaking. While it speaks, a short “mm-hm”, “yeah”, “right” or “uh-huh” from the user produces user_backchannel: the agent keeps talking. A real interruption produces user_turn_taken: the agent stops.

Background awareness

Noise, a TV or side conversations usually become non-user turns, committed with user_turn: false, so your agent does not answer them.

Room to think

Short pauses in the middle of a sentence usually do not end the turn, so people can stop to think. When a speaker stops mid-sentence and does not go on, the turn ends about 2 seconds later. As a further safety net, a user turn with no voice activity for silence_timeout_ms (default 5 seconds) always ends.

History Aware Transcription

The server uses the conversation to recognize names and follow-ups.
  • Custom vocabulary: list names, products and jargon in context.terms, up to 100 terms of up to 32 characters. Update the list during the session with configure.
  • What the agent just said: send each line your agent speaks with context_add as an assistant item, so the user’s answer is heard in context.
  • Conversation history: recent turns of the session are used as context, and speaker labels such as <|speaker:0|> stay the same for the whole session.
  • Prior conversation: start a session with earlier lines in context.history.

Turn detection modes

Eager end of turn, backchannel detection and background awareness are available in auto mode, when the session starts in auto (the default). In vad and manual mode, and after a later switch to auto from another mode, every turn is a user turn. See Turn detection modes for details.

Languages

Smart Turn Detection, including eager end of turn, backchannel detection and background awareness, works on speech in every language. In some languages, a turn can end a little later after the speaker stops. draft, eager_end_of_turn and committed carry the language of their own text as language_code when it can be identified, one of 29 supported codes.

Latency

Measured on the production service with synthetic speech:
  • The first text, a draft (with results.drafts: true), arrives about 0.5 seconds after speech starts.
  • eager_end_of_turn arrives about 0.6 seconds after the speaker stops.
  • committed arrives about 1.1 seconds after the speaker stops.
Your network and how you send audio add to these times. Each result also waits for the message that carries its audio, on average half a message: about 50 ms with 100 ms messages and 20 ms with 40 ms messages. Send audio as you capture it, in 20–40 ms messages.

Implementation details

Audio

Send 16-bit little-endian PCM, mono, at 8000, 12000, 16000, 22050, 24000, 32000, 44100 or 48000 Hz. The server converts the sample rate, so you never need to resample. Compressed formats such as Opus or MP3 are not accepted on this endpoint.

Speakers

Transcripts contain speaker tags such as <|speaker:0|>, stable within a session. Strip them, or send results.diarize: false (diarize=False in the Python SDK, diarize: false in the TypeScript SDK) for plain text. Whitespace right after a tag can vary, so trim the text after you strip the tags. Transcripts can also contain sound tags such as [laughter] or [pause]. Strip them too, or send results.tag_audio_events: false to remove them; see Sound tags.

Keys and browsers

Never put a long-lived sk-fish- API key in a web page. To connect directly from a browser, mint a short-lived single-use ek-fish- token on your backend and pass ["bearer", token] as the WebSocket subprotocol (see Ephemeral Tokens for Browsers and Client Apps; note that browser-direct WebSockets cannot set a custom model header and use the default transcribe-stream-1). If you need transcribe-stream-2 from a browser, relay the audio through your server, as shown in the quickstart.

Limits

A session lasts up to 60 minutes and a turn up to 60 seconds. Each open connection counts against the same concurrency limit as your other API requests, from the moment it opens until it closes, even while you send no audio; see Concurrent request limits. See Limits for the full list.

Pricing

transcribe-stream-2 costs $0.26 per session hour, with a launch price of $0.12 per session hour through December 31, 2026. transcribe-stream-1 costs $0.36 per session hour. Both are billed per second of session duration as their own line item, Realtime ASR. See ASR pricing.

Going further

Build a voice agent

The agent loop: eager replies, interruptions and backchannels.

Stream speech back

Speak your agent’s replies with streaming text to speech.

Transcribe files

Recordings up to 60 minutes with transcribe-1-pro.

WebSocket reference

Messages, errors, close codes and limits.