Audio Input (Local file)
Code
1from pathlib import Path2from 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)1011# Please download a sample audio file to test this Agent and upload using:12audio_path = Path(__file__).parent.joinpath("sample.mp3")1314agent.print_response(15 "Tell me about this audio",16 audio=[Audio(filepath=audio_path)],17 stream=True,18)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 kern-aiRun Agent
1python cookbook/11_models/google/gemini/audio_input_local_file_upload.py