Update custom model files, README, and requirements
Browse files- README.md +67 -80
- asr_config.py +1 -1
- asr_pipeline.py +4 -1
README.md
CHANGED
|
@@ -1,84 +1,71 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
tags:
|
| 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 |
-
| 0.3792 | 0.4469 | 12000 | 0.3185 |
|
| 63 |
-
| 0.3723 | 0.4841 | 13000 | 0.3140 |
|
| 64 |
-
| 0.3696 | 0.5214 | 14000 | 0.3109 |
|
| 65 |
-
| 0.3920 | 0.5586 | 15000 | 0.3104 |
|
| 66 |
-
| 0.3827 | 0.5958 | 16000 | 0.3070 |
|
| 67 |
-
| 0.3593 | 0.6331 | 17000 | 0.3054 |
|
| 68 |
-
| 0.3832 | 0.6703 | 18000 | 0.3056 |
|
| 69 |
-
| 0.3772 | 0.7076 | 19000 | 0.3038 |
|
| 70 |
-
| 0.3887 | 0.7448 | 20000 | 0.3035 |
|
| 71 |
-
| 0.3666 | 0.7821 | 21000 | 0.3034 |
|
| 72 |
-
| 0.3690 | 0.8193 | 22000 | 0.3033 |
|
| 73 |
-
| 0.3568 | 0.8565 | 23000 | 0.3031 |
|
| 74 |
-
| 0.3809 | 0.8938 | 24000 | 0.3029 |
|
| 75 |
-
| 0.3736 | 0.9310 | 25000 | 0.3032 |
|
| 76 |
-
| 0.3553 | 0.9683 | 26000 | 0.3030 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
### Framework versions
|
| 80 |
-
|
| 81 |
-
- Transformers 5.0.0.dev0
|
| 82 |
-
- Pytorch 2.8.0+cu128
|
| 83 |
-
- Datasets 3.6.0
|
| 84 |
-
- Tokenizers 0.22.1
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
datasets:
|
| 6 |
+
- speechbrain/LoquaciousSet
|
| 7 |
+
base_model:
|
| 8 |
+
- openai/whisper-large-v3-turbo
|
| 9 |
+
- HuggingFaceTB/SmolLM3-3B
|
| 10 |
+
pipeline_tag: automatic-speech-recognition
|
| 11 |
tags:
|
| 12 |
+
- asr
|
| 13 |
+
- speech-recognition
|
| 14 |
+
- audio
|
| 15 |
+
- smollm
|
| 16 |
+
- whisper
|
| 17 |
+
- mlp
|
| 18 |
---
|
| 19 |
|
| 20 |
+
# Tiny Audio
|
| 21 |
+
|
| 22 |
+
A speech recognition model trained in 24 hours on a single GPU for ~$12. Built with the [Tiny Audio](https://github.com/alexkroman/tiny-audio) codebase—a minimal, hackable framework for training ASR models.
|
| 23 |
+
|
| 24 |
+
## Architecture
|
| 25 |
+
|
| 26 |
+
```
|
| 27 |
+
Audio (16kHz) → Whisper Encoder (frozen) → MLP Projector (trained) → SmolLM3-3B (frozen) → Text
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
**MLP Projector:**
|
| 31 |
+
- Convolutional downsampling: 4x sequence compression via two stride-2 conv layers
|
| 32 |
+
- Linear (1280 → 2048) → GELU → Linear (2048 → 2048)
|
| 33 |
+
- Output normalization: RMSNorm
|
| 34 |
+
|
| 35 |
+
## Training Details
|
| 36 |
+
|
| 37 |
+
| | |
|
| 38 |
+
|---|---|
|
| 39 |
+
| **Dataset** | LoquaciousSet (25,000 hours) |
|
| 40 |
+
| **Hardware** | Single NVIDIA A40 40GB |
|
| 41 |
+
| **Training Time** | ~24 hours |
|
| 42 |
+
| **Cost** | ~$12 |
|
| 43 |
+
| **Trainable Parameters** | ~12M (projector only) |
|
| 44 |
+
|
| 45 |
+
## Performance
|
| 46 |
+
|
| 47 |
+
**Word Error Rate (WER): 12.14%** on LoquaciousSet test set.
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
## Usage
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
from transformers import pipeline
|
| 54 |
+
|
| 55 |
+
pipe = pipeline("automatic-speech-recognition", model="mazesmazes/tiny-audio", trust_remote_code=True)
|
| 56 |
+
|
| 57 |
+
result = pipe("path/to/audio.wav")
|
| 58 |
+
print(result["text"])
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Limitations
|
| 62 |
+
|
| 63 |
+
- English only
|
| 64 |
+
- Optimized for 16kHz audio; other sample rates are resampled automatically
|
| 65 |
+
- Performance may degrade on heavily accented speech, noisy environments, or domain-specific jargon
|
| 66 |
+
- Maximum audio length limited by context window
|
| 67 |
+
|
| 68 |
+
## Learn More
|
| 69 |
+
|
| 70 |
+
- **[Train your own model](https://github.com/alexkroman/tiny-audio)** — The full codebase with training scripts
|
| 71 |
+
- **[Free 3.5-hour course](https://github.com/alexkroman/tiny-audio/blob/main/docs/course/0-course-overview.md)** — Build your own ASR system from scratch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
asr_config.py
CHANGED
|
@@ -71,7 +71,7 @@ class ASRConfig(transformers.PretrainedConfig):
|
|
| 71 |
"min_new_tokens": 0,
|
| 72 |
"repetition_penalty": 1.0,
|
| 73 |
"length_penalty": 1.0,
|
| 74 |
-
"no_repeat_ngram_size":
|
| 75 |
"use_cache": True,
|
| 76 |
}
|
| 77 |
|
|
|
|
| 71 |
"min_new_tokens": 0,
|
| 72 |
"repetition_penalty": 1.0,
|
| 73 |
"length_penalty": 1.0,
|
| 74 |
+
"no_repeat_ngram_size": 3, # Prevent repeating 3-grams like "so so so"
|
| 75 |
"use_cache": True,
|
| 76 |
}
|
| 77 |
|
asr_pipeline.py
CHANGED
|
@@ -486,6 +486,7 @@ class ASRPipeline(transformers.AutomaticSpeechRecognitionPipeline):
|
|
| 486 |
return ""
|
| 487 |
|
| 488 |
original_len = len(text.split())
|
|
|
|
| 489 |
|
| 490 |
# 1. LOWERCASE
|
| 491 |
text = text.lower()
|
|
@@ -505,8 +506,10 @@ class ASRPipeline(transformers.AutomaticSpeechRecognitionPipeline):
|
|
| 505 |
words = words[: idx + n]
|
| 506 |
text = " ".join(words)
|
| 507 |
print(
|
| 508 |
-
f"[
|
| 509 |
)
|
|
|
|
|
|
|
| 510 |
break
|
| 511 |
|
| 512 |
# 3. COMBINE ACRONYMS
|
|
|
|
| 486 |
return ""
|
| 487 |
|
| 488 |
original_len = len(text.split())
|
| 489 |
+
original_text = text # Keep for debug
|
| 490 |
|
| 491 |
# 1. LOWERCASE
|
| 492 |
text = text.lower()
|
|
|
|
| 506 |
words = words[: idx + n]
|
| 507 |
text = " ".join(words)
|
| 508 |
print(
|
| 509 |
+
f"[POSTPROCESS] Truncated repetition: {original_len} -> {len(words)} words (n={n}, repeats={repeat_count})"
|
| 510 |
)
|
| 511 |
+
print(f"[POSTPROCESS] Before: {original_text[:100]}...")
|
| 512 |
+
print(f"[POSTPROCESS] After: {text[:100]}...")
|
| 513 |
break
|
| 514 |
|
| 515 |
# 3. COMBINE ACRONYMS
|