File size: 14,894 Bytes
1080b26 c4f6575 1080b26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
import gradio as gr
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
from pathlib import Path
# Read reference text
reference_text_path = Path("text/reference.txt")
if reference_text_path.exists():
with open(reference_text_path, "r") as f:
reference_text = f.read()
else:
reference_text = "Reference text not available"
# Check if audio file exists
audio_path = Path("audio/001.wav")
audio_exists = audio_path.exists()
# Prepare WER data for visualizations
wer_data = {
"Model": ["tiny", "base", "small", "medium", "large-v3-turbo"],
"WER (%)": [15.05, 9.95, 11.17, 6.07, 7.04],
"Speed (s)": [2.73, 5.01, 5.14, 19.42, 33.08],
"Model Size": ["39M", "74M", "244M", "769M", "809M"]
}
df_wer = pd.DataFrame(wer_data)
# Engine comparison data
engine_data = {
"Engine": ["faster-whisper", "openai-whisper", "distil-whisper"],
"WER (%)": [9.95, 9.95, 21.6],
"Speed (s)": [4.87, 6.51, 38.49]
}
df_engine = pd.DataFrame(engine_data)
# Create interactive WER by model visualization
fig_wer = go.Figure()
fig_wer.add_trace(go.Bar(
x=df_wer["Model"],
y=df_wer["WER (%)"],
text=df_wer["WER (%)"].round(2),
textposition='auto',
marker_color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7'],
hovertemplate='<b>%{x}</b><br>WER: %{y:.2f}%<br>Size: %{customdata}<extra></extra>',
customdata=df_wer["Model Size"]
))
fig_wer.update_layout(
title="Word Error Rate by Model Size",
xaxis_title="Model",
yaxis_title="WER (%)",
template="plotly_white",
height=400
)
# Create speed vs accuracy scatter plot
fig_scatter = go.Figure()
fig_scatter.add_trace(go.Scatter(
x=df_wer["Speed (s)"],
y=df_wer["WER (%)"],
mode='markers+text',
marker=dict(size=15, color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7']),
text=df_wer["Model"],
textposition="top center",
hovertemplate='<b>%{text}</b><br>Speed: %{x:.2f}s<br>WER: %{y:.2f}%<extra></extra>'
))
fig_scatter.update_layout(
title="Speed vs Accuracy Tradeoff",
xaxis_title="Inference Time (seconds)",
yaxis_title="WER (%)",
template="plotly_white",
height=400
)
# Create engine comparison visualization
fig_engine = go.Figure()
fig_engine.add_trace(go.Bar(
x=df_engine["Engine"],
y=df_engine["WER (%)"],
name="WER (%)",
marker_color='#4ECDC4',
text=df_engine["WER (%)"].round(2),
textposition='auto'
))
fig_engine.update_layout(
title="WER by Engine (Base Model)",
xaxis_title="Engine",
yaxis_title="WER (%)",
template="plotly_white",
height=400
)
# Custom CSS
custom_css = """
.gradio-container {
font-family: 'Inter', sans-serif;
}
.limitation-box {
background-color: #FFF3CD;
border-left: 4px solid #FFC107;
padding: 15px;
margin: 10px 0;
}
.question-box {
background-color: #E3F2FD;
border-left: 4px solid #2196F3;
padding: 15px;
margin: 15px 0;
}
"""
# Build the interface
with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
gr.Markdown(
"""
# Local ASR/STT Benchmark Evaluation
### A Single Sample Evaluation on Local Hardware
Testing different Whisper model sizes to find the optimal balance between accuracy and speed for daily transcription workflow.
"""
)
with gr.Tabs():
# Tab 1: Overview & Test Sample
with gr.Tab("π Overview"):
gr.Markdown(
"""
## About This Evaluation
This was a "back of the envelope" style experiment to determine which Whisper model size works best
for daily transcription on local hardware, focusing on the tradeoff between accuracy (WER) and inference speed.
"""
)
gr.Markdown("### π― Test Sample")
if audio_exists:
gr.Audio(
value=str(audio_path),
label="Test Audio (001.wav)",
type="filepath"
)
else:
gr.Markdown("**Note:** Audio file will be added soon.")
gr.Markdown("### π Reference Text (Ground Truth)")
gr.Textbox(
value=reference_text,
label="Reference Transcription",
lines=10,
max_lines=15,
interactive=False
)
gr.Markdown(
"""
### β οΈ Important Limitations
- **Quick experiment**: Not a definitive scientific evaluation
- **Hardware specific**: AMD GPU with ROCm (not ideal for STT), using CPU inference
- **Single sample**: Results based on one audio clip
- **Variable conditions**: ASR accuracy depends on mic quality, background noise, speaking style
- **Personal use case**: Optimized for one user's voice and workflow
"""
)
# Tab 2: Results & Visualizations
with gr.Tab("π Results"):
gr.Markdown("## Key Findings")
with gr.Row():
with gr.Column():
gr.Markdown(
"""
### Best Accuracy
**medium** model
- 6.07% WER
- 19.42s inference
### Fastest
**tiny** model
- 15.05% WER
- 2.73s inference
### Recommended for Daily Use
**base** model (faster-whisper)
- 9.95% WER
- ~5s inference
- Good balance
"""
)
with gr.Column():
gr.Markdown(
"""
### Key Takeaways
1. **Biggest jump**: tiny β base (15% β 10% WER)
2. **Diminishing returns**: After base, accuracy gains are smaller
3. **faster-whisper**: Same accuracy as OpenAI, 1.2x faster
4. **distil-whisper**: Unexpectedly slower AND less accurate on this sample
"""
)
gr.Markdown("## Interactive Visualizations")
with gr.Row():
gr.Plot(fig_wer, label="WER by Model Size")
with gr.Row():
gr.Plot(fig_scatter, label="Speed vs Accuracy")
with gr.Row():
gr.Plot(fig_engine, label="Engine Comparison")
gr.Markdown("## Original Charts from Benchmark")
with gr.Row():
with gr.Column():
gr.Image("results/wer_by_size.png", label="WER by Size")
with gr.Column():
gr.Image("results/speed_by_size.png", label="Speed by Size")
with gr.Row():
with gr.Column():
gr.Image("results/accuracy_speed_tradeoff.png", label="Accuracy vs Speed")
with gr.Column():
gr.Image("results/engine_comparison.png", label="Engine Comparison")
with gr.Row():
gr.Image("results/variants_comparison.png", label="All Variants Tested")
# Tab 3: Q&A
with gr.Tab("β Questions & Answers"):
gr.Markdown(
"""
# Research Questions & Findings
## Q1: How much does model size actually matter for accuracy?
**Answer:** On my hardware, diminishing returns set in around **medium**.
The biggest accuracy jump was from tiny (15.05% WER) β base (9.95% WER). After that, improvements are smaller:
- tiny β base: 5.1% improvement
- base β medium: 3.88% improvement
- medium β large-v3-turbo: Actually worse (1% regression)
The "sweet spot" depends on your use case:
- **Live transcription**: Even small lags matter β base or small
- **Batch processing**: Can afford slower β medium or large
---
## Q2: Is faster-whisper really as good as OpenAI Whisper?
**Answer:** Yes! On this test, identical accuracy with better speed.
Testing the base model:
- **faster-whisper**: 9.95% WER in 5.01s
- **openai-whisper**: 9.95% WER in 6.17s
faster-whisper was ~1.2x faster with no accuracy loss. Clear winner for my use case.
---
## Q3: What's the speed vs. accuracy tradeoff?
**Answer:** For daily transcription of my own voice, base or small hits the sweet spot.
- **tiny**: 2.73s but 15% WER is too rough
- **base**: 5s with 10% WER - acceptable for daily use
- **small**: Similar to base, slightly slower
- **medium**: 6% WER but 7x slower than tiny
- **large-v3-turbo**: 33s for 7% WER - overkill for casual use
---
## Q4: Which model should I use for my daily STT workflow?
**My personal answer:** base model with faster-whisper
**Why it works for me:**
- ~10% WER is acceptable for dictation (I can quickly fix errors)
- 5 seconds per clip is fast enough
- 140MB model size is manageable
- Good balance for daily workflow
**When I'd use something else:**
- **tiny**: Quick tests or very long recordings where speed matters most
- **medium/large**: Publishing or professional work needing better accuracy
---
## Bonus Finding: distil-whisper
I tested distil-whisper expecting it to be faster, but on my sample:
- **distil-whisper**: 21.6% WER in 38.49s β
Both slower AND less accurate than the standard models. Unexpected, but that's the data.
"""
)
# Tab 4: Hardware & Setup
with gr.Tab("π» Hardware & Setup"):
gr.Markdown(
"""
## Test Environment
### Hardware
- **GPU**: AMD Radeon RX 7700 XT (ROCm available but using CPU inference)
- **CPU**: Intel Core i7-12700F (12 cores, 20 threads)
- **RAM**: 64 GB
- **OS**: Ubuntu 25.04
### Why CPU Inference?
- AMD GPU with ROCm isn't ideal for STT workloads
- CPU inference provided more consistent results
- Your performance will differ based on your hardware
### Models Tested
**Whisper model sizes:**
- tiny (39M params)
- base (74M params)
- small (244M params)
- medium (769M params)
- large-v3-turbo (809M params)
**Engines compared:**
- OpenAI Whisper (original implementation)
- faster-whisper (optimized CTranslate2)
- distil-whisper (distilled variant)
### Metrics
- **WER (Word Error Rate)**: Lower is better - percentage of words transcribed incorrectly
- **Inference Time**: How long it takes to transcribe the audio sample
## Running Your Own Tests
Want to benchmark on your own voice and hardware?
1. Clone the repository: [github.com/danielrosehill/Local-ASR-STT-Benchmark](https://github.com/danielrosehill/Local-ASR-STT-Benchmark)
2. Set up the conda environment (see `setup.md`)
3. Record your own audio and create reference transcriptions
4. Run the benchmark scripts
5. Generate visualizations
Your results will likely differ based on:
- Your hardware (GPU/CPU)
- Your voice characteristics
- Your microphone quality
- Background noise conditions
- Speaking style and pace
"""
)
# Tab 5: About
with gr.Tab("βΉοΈ About"):
gr.Markdown(
"""
## About This Project
### Motivation
I was tired of guessing which Whisper model size to use for speech-to-text. There are plenty of
benchmarks out there, but they're often:
- Run on different hardware than mine
- Tested on different voice characteristics
- Using different microphones and conditions
So I decided to run my own evaluation on my actual setup with my actual voice.
### Why This Matters
If you're doing hours of transcription per day (like I am), optimizing your STT setup is worth it:
- Faster models = less waiting
- More accurate models = less editing
- Finding the sweet spot = better workflow
### Next Steps
For a more robust evaluation, I'd want to:
- Test on multiple audio samples
- Include different speaking styles (casual, technical, professional)
- Test on different microphones
- Evaluate punctuation and capitalization accuracy
- Compare ASR (Automatic Speech Recognition) vs traditional STT
- Test GPU inference on NVIDIA hardware
### Repository
Full benchmark code and results:
[github.com/danielrosehill/Local-ASR-STT-Benchmark](https://github.com/danielrosehill/Local-ASR-STT-Benchmark)
### License
MIT License - Feel free to use and adapt for your own benchmarks!
---
*Built with Gradio β’ Whisper models by OpenAI β’ Hosted on Hugging Face Spaces*
"""
)
gr.Markdown(
"""
---
### π§ Questions or feedback?
Visit the [GitHub repository](https://github.com/danielrosehill/Local-ASR-STT-Benchmark) to open an issue or contribute.
"""
)
gr.HTML(
"""
<div style="text-align: center; margin-top: 20px;">
<a href="https://danielrosehill.com" target="_blank">
<img src="/file/badge.png" alt="Daniel Rosehill" style="width: 480px;">
</a>
</div>
"""
)
if __name__ == "__main__":
demo.launch()
|