From 1f81100378cabdab3ac9b21d01541c1a6e3c71ff Mon Sep 17 00:00:00 2001 From: Accusys Date: Sun, 27 Sep 2026 05:19:48 +0800 Subject: [PATCH] docs: add ASR common language polling feature documentation --- .../2026-09-27_asr_common_language_polling.md | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 docs_v1.0/M4_workspace/2026-09-27_asr_common_language_polling.md diff --git a/docs_v1.0/M4_workspace/2026-09-27_asr_common_language_polling.md b/docs_v1.0/M4_workspace/2026-09-27_asr_common_language_polling.md new file mode 100644 index 00000000..16a6699d --- /dev/null +++ b/docs_v1.0/M4_workspace/2026-09-27_asr_common_language_polling.md @@ -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 |