docs: add ASR common language polling feature documentation
This commit is contained in:
@@ -0,0 +1,115 @@
|
|||||||
|
---
|
||||||
|
title: ASR Common Language Polling Feature
|
||||||
|
version: 1.0
|
||||||
|
date: 2026-09-27
|
||||||
|
author: OpenCode
|
||||||
|
status: implemented
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Added smart language detection for ASR to prevent garbled output when auto-detection fails.
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
Whisper sometimes detects wrong languages, leading to garbled output:
|
||||||
|
- Japanese audio detected as Norwegian (`nn`)
|
||||||
|
- Output contains Sinhala characters (wrong Unicode mapping)
|
||||||
|
- Quality scores: no_speech_prob 69.8%, avg_logprob -0.966
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
### Strategy
|
||||||
|
|
||||||
|
1. Try auto-detection first
|
||||||
|
2. If detected language is NOT in common languages (`en`, `zh`, `ja`)
|
||||||
|
3. OR quality score is too low (< 0.5, < 10 segments)
|
||||||
|
4. Poll common languages: `en` → `zh` → `ja`
|
||||||
|
5. Return the best result
|
||||||
|
|
||||||
|
### Quality Scoring
|
||||||
|
|
||||||
|
```python
|
||||||
|
quality_score =
|
||||||
|
(1 + avg_logprob) * # Normalize to positive
|
||||||
|
(1 - avg_no_speech_prob) * # Lower is better
|
||||||
|
min(segment_count / 100, 1.0) # Prefer more segments
|
||||||
|
```
|
||||||
|
|
||||||
|
Higher score = better transcription.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Enable common language polling
|
||||||
|
python3 scripts/asr_processor.py video.mp4 output.json \
|
||||||
|
--try-common-languages
|
||||||
|
|
||||||
|
# Combine with other options
|
||||||
|
python3 scripts/asr_processor.py video.mp4 output.json \
|
||||||
|
--try-common-languages \
|
||||||
|
--separate-vocals \
|
||||||
|
--fps 30
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test Results
|
||||||
|
|
||||||
|
### Video: 020.mp4
|
||||||
|
|
||||||
|
**Auto-detection:**
|
||||||
|
- Detected: `nn` (Norwegian) ❌
|
||||||
|
- Quality: 0.00
|
||||||
|
- Segments: 0
|
||||||
|
|
||||||
|
**Common language polling:**
|
||||||
|
- Tried: `en`, `zh`, `ja`
|
||||||
|
- All quality: 0.00
|
||||||
|
- Best: `nn` (no difference, audio has no speech)
|
||||||
|
|
||||||
|
### Comparison
|
||||||
|
|
||||||
|
| Mode | Language | Quality | Output |
|
||||||
|
|------|----------|---------|--------|
|
||||||
|
| Auto (small) | `nn` | 0.00 | Sinhala garbled ❌ |
|
||||||
|
| Auto (large-v3) | `nn` | 0.00 | Clean (no output) ✅ |
|
||||||
|
| Polling | `nn`/`en`/`zh`/`ja` | 0.00 | Clean (no output) ✅ |
|
||||||
|
|
||||||
|
## Future Improvements
|
||||||
|
|
||||||
|
1. **Better quality thresholds**
|
||||||
|
- Current: 0.5 and 10 segments
|
||||||
|
- Could be tuned per language
|
||||||
|
|
||||||
|
2. **Language probability access**
|
||||||
|
- Whisper returns language probabilities
|
||||||
|
- Could select highest probability from common languages
|
||||||
|
|
||||||
|
3. **More common languages**
|
||||||
|
- Add Korean (`ko`)
|
||||||
|
- Add Spanish (`es`)
|
||||||
|
- Add French (`fr`)
|
||||||
|
|
||||||
|
4. **Confidence display**
|
||||||
|
- Show quality scores in Redis progress
|
||||||
|
- Help users understand detection quality
|
||||||
|
|
||||||
|
## Files Changed
|
||||||
|
|
||||||
|
- `scripts/asr_processor.py`:
|
||||||
|
- Added `COMMON_LANGUAGES` list
|
||||||
|
- Added `calculate_transcription_quality()`
|
||||||
|
- Added `transcribe_with_common_languages()`
|
||||||
|
- Added `--try-common-languages` CLI flag
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- `docs_v1.0/M4_workspace/2026-09-27_whisper_japanese_detection_failure_analysis.md`
|
||||||
|
- `docs_v1.0/M4_workspace/2026-09-27_asr_large_model_vocal_separation_upgrade.md`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Version History
|
||||||
|
|
||||||
|
| Version | Date | Changes |
|
||||||
|
|---------|------|---------|
|
||||||
|
| 1.0 | 2026-09-27 | Initial implementation |
|
||||||
Reference in New Issue
Block a user