Speech-to-Text

Transcribe audio files with Agno agents.

Agno agents can transcribe audio files using different tools and models. This page covers OpenAI transcription; see Audio to Text Transcription for the fully multimodal Gemini approach.

Using OpenAI Transcription (Cloud)

The following agent uses OpenAITools with whisper-1, its default transcription model. This adapter requests plain text. The current OpenAI transcription API requires JSON for gpt-4o-transcribe and gpt-4o-mini-transcribe; use a custom JSON transcription function for those models until the adapter supports that format.

speech_to_text.py
from pathlib import Path

from agno.agent import Agent
from agno.tools.openai import OpenAITools
from agno.utils.media import download_file

url = "https://agno-public.s3.amazonaws.com/demo_data/sample_conversation.wav"

local_audio_path = Path("tmp/sample_conversation.wav")
print(f"Downloading file to local path: {local_audio_path}")
download_file(url, local_audio_path)

transcription_agent = Agent(
    tools=[OpenAITools(transcription_model="whisper-1")],
    markdown=True,
)
transcription_agent.print_response(
    f"Transcribe the audio file for this file: {local_audio_path}"
)

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U openai agno

Export your OpenAI API key

  export OPENAI_API_KEY="your_openai_api_key_here"

Run Agent

python speech_to_text.py