Transcribe multichannel speech-to-text
Transcribe multichannel speech-to-text
Turn on multichannel when the audio already has discrete channels (call center agent on ch0, customer on ch1). Batch returns a channels array; streaming tags partials with channel_index and emits transcript.done once per channel. Base flows: Transcribe audio with the Voice API and Stream speech to text over WebSocket.
Batch REST
POST https://api.x.ai/v1/stt. multichannel is a boolean (default false). When true, the response includes channels: each item has index, text, and words.
For raw PCM/mulaw/alaw, pass channels as an integer from 2 to 8. Container formats (WAV, MP3, FLAC, OGG, WebM, MP4, M4A) auto-detect channel count.
curl -X POST https://api.x.ai/v1/stt \
-H "Authorization: Bearer $XAI_API_KEY" \
-F multichannel=true \
-F file=@/path/to/stereo-call.wav
Max batch file size is 500 MB. Up to 8 channels.
Streaming WebSocket
multichannel=true requires channels ≥ 2. Multichannel is unsupported with encoding=opus. Send interleaved PCM (L,R,L,R…).
wss://api.x.ai/v1/stt?sample_rate=16000&encoding=pcm&multichannel=true&channels=2&interim_results=true
transcript.partialincludeschannel_index.transcript.donefires once per channel.- Finalize all channels with
{"type":"Finalize"}. Finalize one channel with{"type":"Finalize","channel":N}.
Chunk size note: stereo PCM16 at 16 kHz for 100 ms is 6400 bytes (sample_rate * channels * bytes_per_sample * duration_s → 16000 * 2 * 2 * 0.1).
Proxy the WebSocket through your backend so the API key stays off the client.
Speaker labels on mixed mono
For a single mixed track where you need speaker integers on each word, use Enable speaker diarization on speech-to-text.
Pitfalls
multichannel=truewithencoding=opusis rejected on streaming.- Raw audio needs an explicit
channelsvalue (2–8); containers auto-detect. - Cap is 8 channels. Batch max file size is 500 MB.
- Console API credits are separate from SuperGrok's weekly pool on grok.com.