Audio Input (Bytes Content)
Code
1import requests2from kern.agent import Agent3from kern.media import Audio4from kern.models.google import Gemini56agent = Agent(7 model=Gemini(id="gemini-2.0-flash-exp"),8 markdown=True,9)1011url = "https://openaiassets.blob.core.windows.net/$web/API/docs/audio/alloy.wav"1213# Download the audio file from the URL as bytes14response = requests.get(url)15audio_content = response.content1617agent.print_response(18 "Tell me about this audio",19 audio=[Audio(content=audio_content)],20)Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export GOOGLE_API_KEY=xxxInstall dependencies
1uv pip install -U google-genai requests kern-aiRun Agent
1python cookbook/11_models/google/gemini/audio_input_bytes_content.py