Streaming Audio
Streaming Events Reference
Full reference for all 5 streaming events and the StreamingConfig parameter.
Event reference
| Event | Model | Key Attributes |
|---|---|---|
PARTIAL | StreamingPartial | text, language, segment_id, latency_ms |
FINAL_SEGMENT | StreamingFinalSegment | text, language, segment_id, silence_duration_ms |
FINAL | StreamingFinal | text, language, audio_duration_sec, inference_time_ms |
DONE | StreamingDone | total_segments, total_audio_duration_sec |
ERROR | StreamingError | message, code |
Registering handlers
python
@conn.on(StreamingMessageType.PARTIAL)
def on_partial(msg): print(f"Interim: {msg.text}")
@conn.on(StreamingMessageType.FINAL_SEGMENT)
def on_segment(msg): print(f"Segment: {msg.text}")
@conn.on(StreamingMessageType.DONE)
def on_done(msg): print(f"Done. {msg.total_segments} segments.")StreamingConfig parameter reference
| Parameter | Type | Default | Description |
|---|---|---|---|
language | string | "auto" | Language code or "auto" for auto-detection. |
sample_rate | int | 16000 | Audio sample rate in Hz. |
dtype | string | "int16" | Audio data type: "int16", "float32", "ulaw", or "alaw". |
chunk_size_sec | float | 2.0 | Buffer duration before returning results (in seconds). |
silence_threshold_sec | float | 0.8 | Silence duration to trigger segment boundary. |
inactivity_timeout | float | 300 | Seconds of inactivity before the connection is closed. |
max_connection_duration | float | 3600 | Maximum connection lifetime in seconds. |