Guide for implementing Google Gemini API audio capabilities - analyze audio with transcription, summarization, and understanding (up to 9.5 hours), plus generate speech with controllable TTS. Use when processing audio files, creating transcripts, analyzing speech/music/sounds, or generating natural speech from text.
Guide for implementing Google Gemini API audio capabilities - analyze audio with transcription, summarization, and understanding (up to 9.5 hours), plus generate speech with controllable TTS. Use when processing audio files, creating transcripts, analyzing speech/music/sounds, or generating natural speech from text.
license
MIT
allowed-tools
["Bash","Read","Write","Edit"]
Gemini Audio API Skill
Process audio with transcription, analysis, and understanding, plus generate natural speech using Google's Gemini API. Supports up to 9.5 hours of audio per request with multiple formats.
When to Use This Skill
Use this skill when you need to:
Transcribe audio files to text with timestamps
Summarize audio content and extract key points
Analyze speech, music, or environmental sounds
Generate speech from text with controllable voice and style
Process podcasts, interviews, meetings, or any audio content
response = client.models.generate_content(
model='gemini-2.5-flash-native-audio-preview-09-2025',
contents='Generate audio: Welcome to today\'s episode, in a warm, friendly tone.'
)
# Save audio outputwithopen('output.wav', 'wb') as f:
f.write(response.audio_data)
Input Methods
Method 1: File Upload (Recommended for >20MB)
# Upload and reuse
myfile = client.files.upload(file='large-audio.mp3')
# Use file multiple times
response1 = client.models.generate_content(
model='gemini-2.5-flash',
contents=['Transcribe this', myfile]
)
response2 = client.models.generate_content(
model='gemini-2.5-flash',
contents=['Summarize this', myfile]
)
Method 2: Inline Data (<20MB)
from google.genai import types
withopen('small-audio.mp3', 'rb') as f:
audio_bytes = f.read()
response = client.models.generate_content(
model='gemini-2.5-flash',
contents=[
'Describe this audio',
types.Part.from_bytes(data=audio_bytes, mime_type='audio/mp3')
]
)