Skip to main content
The config part arrives before the audio, so a live upload can’t change its settings once the audio has started. Some context only arrives after the user starts speaking: names pulled from the screen, a message that comes in while they talk, the app they switch to. To use it, restart the request:
  1. Keep a copy of every audio frame you send, from the first one.
  2. When the new context is ready, open a new request with the updated config: stt_prompt, keyterms_prompt, llm_instruction or llm.
  3. Send the copy first, then keep streaming. The copy can go faster than real time, so the new request catches up with the speaker.
  4. Abort the old request. Abort it rather than ending its audio: ending the audio asks for a transcript, and a finished request is billed. A request aborted before it finishes returns nothing and is not billed.
Restart once, when the context is ready, rather than on every change. Each restart transcribes the audio so far again, which adds a little latency on a long recording. The 120-second limit counts all the audio in the new request, the copy included; see Recordings over two minutes.

Example

Each example records 16 kHz mono 16-bit PCM from the default microphone, starts with a plain config, and restarts with keyterms three seconds in, where your own screen-context lookup would call it. The SDK examples use a live session’s abort(); the examples without an SDK drop the connection before the body is complete. The JavaScript examples record with SoX, so install it first (brew install sox or sudo apt-get install sox).