Using text to speech APIs in android application

可紊 提交于 2019-12-30 12:14:51

问题


I want to use TTS (Text to Speech) APIs in my android application.Now i have one quetions - Is it support TURKISH language ? I also want to highlight word in textview when that perticular word is being spoke.

How can i do it ? Can anybody help me ?

Thanks in advance !


回答1:


Does it support TURKISH language

This may vary on different handsets/flavours of Android. You can check it out for yourself using the

   mTTS.isLanguageAvailable(new Locale("tr", "TUR"));

I also want to highlight word in textview when that particular word is being spoke.

Well you have a TextToSpeech.OnUtteranceCompletedListener(), to use this you have to speak() each word, one at a time.




回答2:


The TTS engine that ships with the Android platform supports a number of languages: English, French, German, Italian and Spanish. Also, depending on which side of the Atlantic you are on, American and British accents for English are both supported.

http://developer.android.com/resources/articles/tts.html




回答3:


You should use Locale type variable.

  final Locale locale = new Locale("tr", "TR");          

  tts = new TextToSpeech(getApplicationContext(), new
  TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {

             if (status == TextToSpeech.SUCCESS) {
                int result = tts.setLanguage(locale);
                if (result == TextToSpeech.LANG_MISSING_DATA
                        || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                    Log.d("class name", "tts error ");
                }
            } else {
                Log.d("class name", "tts error ");
            }
        }
    });
   tts.speak("write here what you want in Turkish", TextToSpeech.QUEUE_FLUSH, null);


来源:https://stackoverflow.com/questions/8381216/using-text-to-speech-apis-in-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!