OpenAI provides a complete audio stack: Whisper for transcribing recorded audio in over 50 languages, a text-to-speech (TTS) endpoint for generating natural-sounding voice output, and a Realtime API for building low-latency voice applications with streaming input and output. Whether you need to process uploaded meeting recordings, add a voice interface to a chatbot, or build live caption software, the same OpenAI client handles all three.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/openai/openai-cookbook/llms.txt
Use this file to discover all available pages before exploring further.
Transcribe audio with Whisper
Theaudio.transcriptions.create endpoint accepts an audio file and returns the transcribed text. It works well for voicemails, meeting recordings, podcasts, and any other pre-recorded content.
Supported formats
Whisper accepts the following audio formats:mp3, mp4, mpeg, mpga, m4a, wav, and webm. The maximum file size per request is 25 MB. For longer recordings, split the audio into segments before sending.
Detect language automatically
By default, Whisper detects the spoken language automatically. You can also specify a language explicitly using an ISO-639-1 code to improve accuracy and skip the detection step.Return timestamps
Addtimestamp_granularities to receive word-level or segment-level timing alongside the transcript. Set response_format to "verbose_json" to access the full output structure.
Improve accuracy with prompting
Whisper’sprompt parameter accepts a short text snippet (up to 224 tokens) that the model uses to calibrate its output style. Unlike GPT prompting, Whisper does not follow instructions — it imitates the style and vocabulary of the prompt text.
There are two practical techniques:
- Spelling guide
- Style transcript
Provide a comma-separated list of proper nouns, product names, or technical terms that Whisper might otherwise misspell. The model learns the correct spellings from context.
The prompt is limited to 224 tokens. If you provide more, only the final 224 tokens are used. The prompt influences style and vocabulary — it does not allow you to issue instructions like “format as bullet points.”
Stitch multi-segment transcriptions
When you split a long recording into segments, pass the previous segment’s transcript as the prompt for the next segment. This maintains consistent vocabulary, speaker names, and punctuation across the full recording.Generate speech with TTS
Theaudio.speech.create endpoint converts text to spoken audio. Choose from six built-in voices and two model tiers depending on your quality and latency needs.
Available voices
alloy
Neutral and balanced. A good default for general applications.
echo
Male, slightly more formal. Works well for instructional content.
fable
Warm and expressive. Suited for storytelling or creative content.
onyx
Deep and authoritative. Strong for announcements or narration.
nova
Bright and energetic. A good choice for assistants and chatbots.
shimmer
Soft and calm. Well suited for meditation or accessibility use cases.
TTS model tiers
| Model | Description |
|---|---|
tts-1 | Optimized for low latency. Best for real-time applications. |
tts-1-hd | Optimized for audio quality. Best for recorded or published content. |
Stream audio to a file or speaker
For longer inputs, stream audio as it is generated rather than waiting for the full response.Supported output formats
The TTS endpoint defaults to MP3. Passresponse_format to choose a different container.
Transcription methods compared
Different scenarios call for different approaches. The table below summarizes the key trade-offs.| Method | First token latency | Best for | Key limitations |
|---|---|---|---|
| File upload, non-streaming | Seconds | Voicemail, meeting recordings | No partial results; 25 MB max per request |
| File upload, streaming | Sub-second feel | Voice memos, mobile apps | Still requires a completed file before sending |
| Realtime WebSocket | Sub-second | Live captions, voice assistants | Audio must be PCM16, G711 ulaw, or G711 alaw; sessions limited to 30 min |
| Agents SDK VoicePipeline | Sub-second | Agentic voice workflows | Python-only beta; API surface may change |
Real-time voice with the Realtime API
The Realtime API accepts a continuous audio stream over a WebSocket and returns transcription events as speech is detected. This is the right choice for live captioning, voice interfaces, and any application where users expect an immediate response to their voice.The Realtime API requires audio in PCM16 format (24 kHz, mono, 16-bit signed). If your audio source produces a different format, use a library such as
resampy or sounddevice to convert before sending.Pre- and post-processing tips
Raw transcriptions sometimes need cleaning before they are useful in production. Common post-processing steps include:- Add punctuation: Pass the transcript through a GPT model with a prompt to insert missing punctuation and capitalize sentence starts.
- Normalize numbers: Convert spoken numbers (“five two nine”) to digit form (“529”) using regex rules or a language model pass.
- Handle Unicode: Normalize Unicode characters to remove unexpected encoding artifacts, especially from recordings with accented speech.