A professional benchmarking framework for evaluating Azure OpenAI speech-to-text models. This toolkit provides comprehensive accuracy and latency measurements using controlled audio datasets, with detailed Word Error Rate (WER) analysis and automated reporting.
- Automated Test Discovery β Automatically pairs audio files with reference transcripts from your dataset directory
- Multi-Model Support β Benchmarks multiple Azure OpenAI models including:
- Chat-based models:
gpt-audio,gpt-audio-mini,gpt-4o-audio-preview - Transcription models:
gpt-4o-transcribe,gpt-4o-mini-transcribe
- Chat-based models:
- Comprehensive Metrics β Calculates raw WER, latency, and detailed error analysis (substitutions, insertions, deletions)
- Professional Reporting β Generates executive summaries with model rankings, comparison tables, and detailed per-sample breakdowns
- Detailed Error Analysis β Shows exactly which words were substituted, inserted, or deleted for each model
- Flexible CLI β Target specific audio files, list available samples, or skip report generation with command-line options
- Modular Architecture β Clean, maintainable codebase with separate modules for configuration, testing, metrics, and reporting
.
βββ data/
β βββ mine/processed/ # User-created test samples (not used)
β βββ off/processed/ # Official test audio samples
β βββ audio_clean.wav
β βββ audio_clean_reference.txt
β βββ audio_noisy.wav
β βββ audio_noisy_reference.txt
βββ reports/ # Generated benchmark reports
β βββ stt_report.md
β βββ stt_report_normalized.md
βββ scripts/
β βββ convert_audio.sh # Audio conversion utility
βββ src/ # Source code (modular architecture)
β βββ __init__.py
β βββ config.py # Configuration and model definitions
β βββ test_discovery.py # Test case discovery and filtering
β βββ transcription.py # API communication for both chat and transcription models
β βββ metrics.py # WER calculation and error analysis
β βββ llm_normalization.py # LLM normalization (disabled)
β βββ reporting.py # Comprehensive benchmark report generation
β βββ runner.py # Test orchestration
β βββ main.py # Main entry point with CLI
βββ tests/ # Test files
βββ logs/ # Application logs
βββ .env # Environment variables (not in git)
βββ .env.example # Environment variables template
βββ pyproject.toml # Project dependencies and metadata
βββ uv.lock # UV lock file
βββ README.md # This file
βββ ARCHITECTURE.md # Architecture documentation
βββ MODULE_DEPENDENCIES.md # Module dependencies
- Python 3.13+ (or Python 3.8+ with compatibility adjustments)
- Azure OpenAI resource with deployed speech models
- Audio samples with corresponding reference transcripts
-
Clone or download the project
-
Install dependencies:
pip install -e .Or using
uv:uv pip install -r pyproject.toml
-
Configure environment variables:
cp .env.example .env
Edit
.envwith your Azure credentials:AZURE_API_KEY=your_azure_openai_api_key AZURE_ENDPOINT=https://your-resource.cognitiveservices.azure.com # Note: AUDIO_DATA_DIR is not needed - hardcoded to data/off/processed -
Prepare your dataset:
data/off/processed/ βββ audio_clean.wav βββ audio_clean_reference.txt βββ audio_noisy.wav βββ audio_noisy_reference.txt βββ ...Each
audio_*.wavfile must have a correspondingaudio_*_reference.txtfile with the ground truth transcript.
Run all benchmarks:
python -m src.mainList available test cases:
python -m src.main --listTest specific audio files:
python -m src.main --audio audio_clean audio_noisySkip report generation:
python -m src.main --skip-report| Option | Description |
|---|---|
--list |
Display all discovered audio/reference pairs and exit |
-a, --audio FILES... |
Run benchmarks only on specified files (accepts names, stems, or paths) |
--skip-report |
Skip generating the detailed Markdown report |
Console Summary:
================================================================================
π BENCHMARK RESULTS - MODEL COMPARISON
================================================================================
Model Avg WER Latency Errors Status
--------------------------------------------------------------------------------
gpt-4o-mini-transcribe 5.84% 1.72s 9 β
2
gpt-audio-mini 7.79% 3.85s 12 β
2
gpt-4o-audio-preview 8.44% 1.83s 13 β
2
gpt-4o-transcribe 9.09% 2.68s 14 β
2
gpt-audio 12.99% 2.45s 20 β
2
================================================================================
π BEST MODEL: gpt-4o-mini-transcribe
Average WER: 5.84%
Average Latency: 1.72s
Total Errors: 9
================================================================================
Markdown Report:
A comprehensive benchmark report is generated at reports/stt_report_normalized.md containing:
Executive Summary:
- Model performance comparison table (ranked by WER)
- Best model announcement with key metrics
- Error type breakdown (substitutions, insertions, deletions)
Detailed Results:
- Per-audio sample analysis
- Side-by-side model comparison tables
- Full transcripts from each model
- Detailed error analysis showing exact mismatches
Edit src/config.py to add model configurations:
MODELS = {
"your-new-model": {
"url": f"{AZURE_ENDPOINT}/openai/deployments/your-model/...",
"deployment": "your-model",
"type": "chat", # or "transcription" for audio transcription models
"api_version": "2025-01-01-preview",
}
}
ACTIVE_MODELS = [
"gpt-audio",
"gpt-audio-mini",
"gpt-4o-transcribe",
"gpt-4o-mini-transcribe",
"your-new-model", # Add here
]Model Types:
"chat"- For chat-based audio models (uses chat completions API)"transcription"- For dedicated transcription models (uses audio transcriptions API)
Import and use individual modules in your own scripts:
from src.config import ACTIVE_MODELS
from src.test_discovery import discover_test_cases
from src.runner import test_all_models
from src.reporting import print_results, generate_report
# Discover test cases (returns list of (audio_path, reference_path) tuples)
cases = discover_test_cases()
# Prepare test cases with reference text
test_cases = []
all_results = []
for audio_path, ref_path in cases:
if ref_path:
reference = ref_path.read_text(encoding='utf-8').strip()
test_cases.append({
'audio_path': audio_path,
'reference_path': ref_path,
'reference_text': reference
})
results = test_all_models(audio_path, reference)
all_results.append(results)
# Display results
print_results(all_results)
# Generate markdown report
generate_report(test_cases, all_results)Add new metric calculations in src/metrics.py:
def calculate_custom_metric(reference: str, hypothesis: str) -> float:
"""Your custom metric calculation."""
# Implementation here
return score- Format: WAV (16 kHz, mono recommended)
- Naming:
audio_*.wav(e.g.,audio_clean.wav,audio_noisy.wav) - Location:
data/off/processed/
- Format: Plain text (.txt) with UTF-8 encoding
- Naming: Must match audio file with
_referencesuffix (e.g.,audio_clean_reference.txt) - Content: Exact transcription of the audio file
- Location: Same directory as audio files (
data/off/processed/)
The framework currently uses 2 audio samples:
audio_clean.wav- Clean audio recordingaudio_noisy.wav- Noisy audio recording
Both with corresponding reference files for WER calculation.
The project uses a modular architecture for maintainability and extensibility:
- config.py β Centralized configuration with model definitions and API endpoints
- test_discovery.py β Automatically discovers and pairs audio files with references
- transcription.py β Handles API communication for both chat and transcription models
- metrics.py β Calculates raw WER and performs detailed error analysis
- reporting.py β Generates comprehensive benchmark reports with executive summaries
- runner.py β Orchestrates test execution across multiple models
- main.py β Entry point with CLI argument parsing
| Variable | Required | Default | Description |
|---|---|---|---|
AZURE_API_KEY |
Yes | β | Your Azure OpenAI API key |
AZURE_ENDPOINT |
No | https://draftspeechtotext.cognitiveservices.azure.com |
Azure OpenAI endpoint URL |
Models are configured in src/config.py. Each model requires:
- Deployment name
- API endpoint URL
- API version
- Model type (
"chat"or"transcription")
The framework is configured to:
- Use only
data/off/processed/directory for audio samples - Calculate raw WER (no normalization)
- Test 5 models: gpt-audio, gpt-audio-mini, gpt-4o-transcribe, gpt-4o-mini-transcribe, gpt-4o-audio-preview
The primary metric for transcription quality:
WER = (Substitutions + Insertions + Deletions) / Total Reference Words
Raw WER is calculated by comparing the model's transcript directly against the reference text (case-insensitive).
Detailed breakdown includes:
- Substitutions β Words incorrectly transcribed
- Insertions β Words added that weren't in the reference
- Deletions β Words omitted from the reference
Measures API response time from request to completion (in seconds).
- Audio Quality β Use clear, noise-free recordings for accurate baseline measurements
- Reference Transcripts β Ensure reference transcripts are accurate and match audio exactly
- Consistent Format β Use 16 kHz mono WAV files for best results
- Batch Size β Be mindful of Azure API rate limits when testing large datasets
- Version Control β Keep historical reports for tracking model improvements over time
Ensure your .env file exists and contains valid Azure credentials.
The framework is configured to use data/off/processed/. Ensure this directory exists and contains your audio files.
Each audio_*.wav file must have a corresponding audio_*_reference.txt file with the same base name (e.g., audio_clean.wav β audio_clean_reference.txt).
Activate your virtual environment:
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # WindowsBased on testing with 2 audio samples (clean and noisy):
π Winner: gpt-4o-mini-transcribe
- Average WER: 5.84%
- Average Latency: 1.72s
- Best for: Accuracy and speed
Full Rankings:
- gpt-4o-mini-transcribe: 5.84% WER, 1.72s
- gpt-audio-mini: 7.79% WER, 3.85s
- gpt-4o-audio-preview: 8.44% WER, 1.83s
- gpt-4o-transcribe: 9.09% WER, 2.68s
- gpt-audio: 12.99% WER, 2.45s
- GPT Realtime β Not currently supported (requires websocket session)
- Whisper Models β Removed from testing (focus on OpenAI GPT models only)
- Normalization β Disabled to show true model performance
- Audio Length β Ensure audio files comply with Azure request size limits
- Rate Limiting β 1-second delay between API calls (configurable in src/config.py)
The modular architecture makes contributions straightforward:
- Bug fixes: Target the specific module
- New features: Extend relevant modules
- New models: Update configuration
- New metrics: Extend metrics module
This benchmark framework provides a clear, objective comparison of Azure OpenAI speech-to-text models. The comprehensive reports help you make informed decisions about which model best fits your use case based on accuracy, speed, and error characteristics.
Key Takeaways:
- gpt-4o-mini-transcribe offers the best balance of accuracy and speed
- All models handle clean audio better than noisy audio
- Transcription models are generally faster than chat-based models
- Detailed error analysis helps identify specific model weaknesses
Ready to benchmark your models? Run python -m src.main to get started! π€π