mirror of
https://github.com/THU-MAIC/OpenMAIC.git
synced 2026-10-04 10:18:22 +08:00
Browser TTS auto-detection only distinguished Chinese (CJK ratio) from everything else (en-US), so Vietnamese narration was spoken by an English voice. Add Vietnamese detection to the shared language helper and bind an installed vi voice in the playback engine when the user has not picked one explicitly: - lib/audio/browser-tts-preview.ts: new detectSpeechLang() (zh-CN / vi-VN / en-US), used by both the Test TTS preview and playback. A hit on đ/ơ/ư or the U+1EA0-U+1EF9 precomposed block (ớ, ừ, ồ, ế, …) — absent from French/Romanian Latin — marks Vietnamese; bare ă/â/ê/ô only count toward a low ratio. - lib/playback/engine.ts: use the shared helper; when it reports vi-VN, prefer an installed vi voice so pronunciation is correct out of the box. An explicitly configured voice still wins. - tests/audio/detect-speech-lang.test.ts: zh/vi/en/fr cases. Verified end-to-end (Playwright WebKit): utterances carry lang vi-VN with an installed Vietnamese voice auto-selected, advancing through every line. Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>