IllegalArgumentException: Invalid int: “OS” with Samsung tts

前端 未结 2 1588
野趣味
野趣味 2020-12-10 10:42

I\'m using Text to speech in my android application.It is working Fine with Google TTs and espeak, But when i used with Samsung TTS it gives following Exception.

         


        
相关标签:
2条回答
  • 2020-12-10 11:12

    I have found that I get this exception also when I try to do something like TextToSpeech.getDefaultVoice, or TextToSpeech.getVoices(), or TextToSpeech.getVoice(). I worked around this by not calling them, and instead working through the default Locale to get what I was trying to get via the Voices object.

    So in my case I wanted to know the Locale so I could select a language, so I did the following

                Locale lTest = Locale.getDefault();
                res = mTTS.isLanguageAvailable(lTest);
    
    0 讨论(0)
  • 2020-12-10 11:21

    I used this to avoid raising the exception.

        int result = mTts.isLanguageAvailable(Locale.US);
        if(result >= 0)
            result = mTts.setLanguage(Locale.US);
        else {
            Locale def = Locale.getDefault();
            result = mTts.isLanguageAvailable(def);
            if(result >=0 )
                result = mTts.setLanguage(def);
        }
    
    0 讨论(0)
提交回复
热议问题