Skip to main content
Stream audio responses from an Agno agent using OpenAI’s gpt-audio model.
audio_streaming.py

Usage

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Create the output directory

5

Run Agent

Key Features

  • Streamed output: Consumes audio chunks as the model returns them
  • PCM16 format: Writes 16-bit PCM audio at 24 kHz in mono
  • Transcript output: Prints transcript chunks as they arrive
  • WAV file: Saves the audio stream to tmp/response_stream.wav
  • Decode failures: Prints chunk decoding failures and continues consuming the stream

Next Steps

Output Format

The agent writes 24 kHz, mono, 16-bit PCM audio to tmp/response_stream.wav. The script saves the stream to disk. It does not play the audio.