API reference · Streaming speech to text
Streaming speech to text
Transcribe live audio over a WebSocket.
WS
/v1/speech-to-text/stream
Open a WebSocket with your key in the x-api-key header (or ?api_key= where headers cannot be set), send a start message, then raw 16-bit little-endian mono PCM in binary frames. Each time the speaker pauses, the utterance is transcribed and sent back.
| Direction | Message |
|---|---|
| you → | {"type": "start", "language_code"?: "en-IN", "model_id"?, "sample_rate"?: 16000, "partials"?: false} |
| ← server | {"type": "ready", "request_id"} |
| you → | binary PCM frames… |
| ← server | {"type": "partial", "text"} |
| ← server | {"type": "final", "text", "language_code", "start", "end", "audio_seconds"} |
| you → | {"type": "end"} |
| ← server | {"type": "done", "audio_seconds"} |
| ← server | {"type": "error", "code", "message"} |
Partials (the utterance so far, while the person is still speaking) are sent only with "partials": true. Audio is charged as it arrives; when credits run out the server sends an INSUFFICIENT_CREDITS error and closes.
from lipivo import AsyncLipivo # pip install "lipivo[streaming]"
async with AsyncLipivo() as client:
async for event in client.speech_to_text_stream(microphone_chunks(), language_code="en-IN"):
if event["type"] == "final":
print(event["text"])