Skip to main content

Overview

The Speech-to-Text feature provides powerful transcription capabilities with both real-time WebSocket connections and batch processing options.

Realtime Transcription

The realtime API uses WebSocket connections for live audio transcription.

URL-Based Streaming

Transcribe audio from a URL in real-time:

Manual Audio Chunks

Send audio chunks manually for transcription:

Event Types

Available events from the realtime API:
event
Emitted when a partial (interim) transcript is available.
event
Emitted when a final (complete) transcript segment is available.
event
Emitted when an error occurs during transcription.
event
Emitted when the WebSocket connection is established.
event
Emitted when the WebSocket connection is closed.

Audio Formats

Supported audio formats for realtime transcription:

Complete Example

Full example with error handling:

Microphone Input

Transcribe from microphone in real-time:

File Transcription

Transcribe a complete audio file:

Use Cases

Live Captioning

Real-time captions for videos and streams

Voice Commands

Transcribe voice commands for applications

Meeting Transcription

Transcribe meetings and calls in real-time

Accessibility

Provide text alternatives for audio content

Best Practices

  • Use appropriate audio formats for your use case
  • Handle both partial and final transcripts for better UX
  • Implement error handling for network issues
  • Close connections properly when done
  • Use lower sample rates (16kHz) for speech-only content
Partial transcripts provide interim results that may change as more audio is processed. Final transcripts are stable and won’t change.

Async Client

The async client provides the same functionality: