Realtime streaming

Audio in, audio out. Both live.

One socket streams Arabic speech in and returns text as it's spoken. One request streams speech out from the first chunk. Same key, same base URL, built for the turn-taking a voice agent lives on.

import websockets, json

ws = await websockets.connect(
    "wss://api.munsit.com/api/v1/listen?encoding=linear16&sample_rate=16000",
    additional_headers={"x-api-key": MUNSIT_API_KEY},
)
async for frame in microphone():          # 20–200 ms of PCM each
    await ws.send(frame)
await ws.send(json.dumps({"type": "CloseStream"}))

The numbers that matter on the wire.

What arrives first, how soon, at what rate, and how many at once.

<50 ms
To the first partial, the speech-to-text figure, in
<50 ms
To the first audio byte, the text-to-speech figure, out
48 kHz
Native output rate, no resampling for WebRTCDocs
5
Sessions per key, by default, raised on requestDocs

Words appear while they are still talking.

Every server message is JSON with a type. A turn arrives in this order, and each event carries the session id, so a multiplexed client can attribute it without tracking connections.

  1. 01

    Speech starts

    The voice-activity detector confirmed speech on a channel. ts is the audio second.

  2. 02

    Interim results

    Refresh continuously while the speaker talks, and may revise earlier words. Render them as provisional text.

  3. 03

    The final

    Text that will not change, with a timestamp and a confidence on every word. speech_final: true means the speaker genuinely finished; that is your trigger to respond.

  4. 04

    Turn end

    Fires only on a genuine end of turn, never on a forced split. The cleanest single signal that the caller stopped talking.

  5. 05

    Gender

    Classified from the turn's audio, male or female, with a score. No extra request.

  6. 06

    Sentiment

    Positive, neutral or negative, from the turn's transcript. On a two-channel call, a live trajectory per party.

Knows when the caller has finished, not just paused.

The silence the engine waits for before it declares a turn finished is the latency and accuracy trade you control, and you can retune it mid-session.

  • Retune it live with a Configure message: 300 for a yes-or-no question, back to 800 for an open answer.
  • Smart turn detection runs a semantic end-of-turn model on every pause, so a caller who stops to think is not cut off.
  • A turn always ends after twice the endpointing silence, whatever the model says.
  • 800 mssafest boundaries
    Final arrives
    About 1.2 s after speech ends
    Best for
    Conversational speech
    The trade
    The longest wait
  • 500 msbalanced
    Final arrives
    About 0.9 s
    Best for
    Most mid-sentence hesitations
    The trade
    A little of each
  • 300 msfastest
    Final arrives
    About 0.8 s
    Best for
    Short commands
    The trade
    Can split a hesitant speaker mid-thought
endpointing800 mssafest boundaries500 msbalanced300 msfastest
Final arrivesAbout 1.2 s after speech endsAbout 0.9 sAbout 0.8 s
Best forConversational speechMost mid-sentence hesitationsShort commands
The tradeThe longest waitA little of eachCan split a hesitant speaker mid-thought

Send text, hear speech before the sentence is finished.

Three ways to get speech back as it's generated. Pick by where your text is: all known up front, still arriving from a model, or needing timings for captions.

Ask for 48 kHz. It is the engine's native rate, so the audio skips downsampling and needs no client-side resampling for WebRTC.

Four habits keep a session healthy.

The listen socket meters seconds of audio times channels, and closes with a code that says why. Handle these four and it stays up.

  • Send KeepAlive during pauses

    Twelve seconds with neither audio nor a KeepAlive closes the session. On hold is a pause.

  • Pace a file to real time

    Audio can run at most 60 seconds ahead of real time. A live source never hits it; a file replay does unless you sleep.

    4008
  • End with CloseStream

    It finalises the turn in progress and sends the closing Metadata with the seconds billed. Keep reading until the server closes.

  • Read the close code

    1008 is policy: the key, the session limit or the wallet. The Error before it says which.

    1008

Open the socket. Read it as it's spoken.

The first partial arrives in under 50 ms. Try it for free.