Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Text-To-Speech speak Cantonese with "alphabet" programmatically

I would like to speak "A13" with "A" pronounced in "English" and "13" in "Cantonese"; Below is the code I used but it just gives me "13" in Putonghua.

tts.setLanguage(Locale.ENGLISH);
tts.speak("A", TextToSpeech.QUEUE_FLUSH, null);

tts.setLanguage(Locale.TRADITIONAL_CHINESE);
tts.speak("13", TextToSpeech.QUEUE_FLUSH, null);

I have followed the link below and installed the tts package for "cantonese", but I still would not set "Cantonese" in my app. However, if I use Ekho tts engine, it would achieve the desired result but the voice is a bit strange versus google engine.

http://www.android-apk.com/2015/07/google-tts-%E6%96%87%E5%AD%97%E8%BD%89%E8%AA%9E%E9%9F%B3%E5%B7%B2%E6%94%AF%E6%8F%B4-%E7%B2%B5%E8%AA%9E-%E5%92%8C-%E4%B8%AD%E6%96%87/

like image 627
Antoine Murion Avatar asked Jan 07 '23 06:01

Antoine Murion


1 Answers

You may want to try tts.setLanguage(new Locale("zh", "HK")) or tts.setLanguage(new Locale("yue", "HK")). TRADITIONAL_CHINESE most likely refers to the writing, not to the spoken language. Taiwan for example uses traditional writing, but the spoken language is Mandarin (zh_TW). Cantonese is spoken in Hong Kong, therefore the "HK" variant should be used. Recent changes in Google's tts consider Cantonese ("yue") to be a different language altogether.

like image 53
Peter Avatar answered Jan 14 '23 13:01

Peter