This project showcases how to use Gemini 2.5 Pro for transcribing multi-speaker audio, applying audio diarization (identifying "who said what"), and working with long-form audio files effectively.
With Gemini 2.5 Pro, you can:
- Upload and transcribe long-form audio (up to 9.5 hours in total per prompt).
- Perform audio diarization to segment and label speakers automatically.
- Handle common audio formats like
.wav,.mp3,.aac, etc. - Work within token and resolution limits using smart chunking.
- Extract meaningful text output with speaker attribution.
Input Audio (Multi-speaker)
|
1. Feature Extraction — Extract MFCCs, spectral features
↓
2. Voice Activity Detection (VAD) — Detect speech vs. non-speech
↓
3. Speaker Segmentation & Clustering — Identify unique speakers
↓
Output: Speaker-Labeled Timeline
Example:
[00:00–00:15] Speaker A: Hello and welcome...
[00:15–00:45] Speaker B: Thanks! I'm excited...
Gemini supports:
- WAV -
audio/wav - MP3 -
audio/mp3 - AIFF -
audio/aiff - AAC -
audio/aac - OGG -
audio/ogg - FLAC -
audio/flac
- 1 second of audio ≈ 32 tokens
- 1 minute of audio ≈ 1,920 tokens
- Max input tokens =
1,000,000 - Max output tokens =
64,000
| Audio Duration | Input Tokens (approx.) | Output Tokens |
|---|---|---|
| 15 minutes | 28,800 tokens | ~8K tokens |
| 1 hour | 115,200 tokens | ~32K tokens |
| 2 hours | 230,400 tokens | ~64K tokens |
🔁 To process more than 2 hours of audio, chunk the file and use prompt windowing (e.g., from X min to Y min).
You can provide audio in two ways:
- Pre-upload via API or file handler.
- Inline data in the request body.
NB: I removed the lines
import IPython.display as ipd
ipd.Audio("/content/HS4830417304.mp3", autoplay=True) so that the file can be uploaded to Git—it was beyond the 25MB limit.
Feel free to add those lines at the end of the notebook if needed.
| Modality | Price / 1M Tokens |
|---|---|
| Input ≤ 200K | $1.25 |
| Input > 200K | $2.50 |
| Output ≤ 200K | $10.00 |
| Output > 200K | $15.00 |
- Audio is downsampled to 16 kbps mono. Stereo channels are merged.
- Gemini understands non-speech audio, but only returns responses for English-language speech.
- You can label speakers manually if diarization doesn’t identify names correctly.
prompt = """
Please transcribe the audio and indicate speaker turns.
From minute 5:00 to minute 10:00:
Speaker A is Alice
Speaker B is Bob
"""[Alice]: Welcome to the show!
[Bob]: Thanks, it’s great to be here.
...
- Python example with Gemini API
- Audio file chunking helper
- Diarization label enhancer
Gemini_2_5_Pro_Podcast_Audio_transcription_boo.ipynb– Jupyter notebook showing audio processing- Images/screenshots from Sam Witteveen’s tutorial
- Gemini AI by Google DeepMind
- Visuals inspired by Sam Witteveen
- README by Emmanuel Kasigazi






