> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Audio Input Output

> Send a WAV recording to gpt-audio and save the model's spoken reply to tmp/result.wav with write_audio_to_file().

Audio Input Output.

```python audio_input_output.py theme={null}
"""
Audio Input Output
=============================

Audio Input Output.
"""

import requests
from agno.agent import Agent
from agno.media import Audio
from agno.models.openai import OpenAIChat
from agno.utils.audio import write_audio_to_file
from rich.pretty import pprint

# Fetch the audio file and convert it to a base64 encoded string
url = "https://openaiassets.blob.core.windows.net/$web/API/docs/audio/alloy.wav"
response = requests.get(url)
response.raise_for_status()
wav_data = response.content

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIChat(
        id="gpt-audio",
        modalities=["text", "audio"],
        audio={"voice": "sage", "format": "wav"},
    ),
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    run_response = agent.run(
        "What's in these recording?",
        audio=[Audio(content=wav_data, format="wav")],
    )

    if run_response.response_audio is not None:
        pprint(run_response.content)
        write_audio_to_file(
            audio=run_response.response_audio.content, filename="tmp/result.wav"
        )
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai requests
```

**2. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Run the example**

Save the code above as `audio_input_output.py`, then run:

```bash theme={null}
python audio_input_output.py
```

Full source: [cookbook/02\_agents/12\_multimodal/audio\_input\_output.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/02_agents/12_multimodal/audio_input_output.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.