2014-11-04 22 views
25

我正在使用文本到我的android應用程序中的語音。它與Google TTs和espeak工作良好,但是當我與三星TTS一起使用時,它給出以下異常。IllegalArgumentException:無效int:「操作系統」與三星tts

java.lang.IllegalArgumentException: Invalid int: "OS" 
at android.os.Parcel.readException(Parcel.java:1429) 
at android.os.Parcel.readException(Parcel.java:1379) 
at android.speech.tts.ITextToSpeechService$Stub$Proxy.isLanguageAvailable(ITextToSpeechService.java:482) 
at android.speech.tts.TextToSpeech$10.run(TextToSpeech.java:1084) 

at android.speech.tts.TextToSpeech$10.run(TextToSpeech.java:1081) 
at android.speech.tts.TextToSpeech$Connection.runAction(TextToSpeech.java:1329) 

at android.speech.tts.TextToSpeech.runAction(TextToSpeech.java:570) 

at android.speech.tts.TextToSpeech.runAction(TextToSpeech.java:561) 

at android.speech.tts.TextToSpeech.isLanguageAvailable(TextToSpeech.java:1081) 
+3

對我來說,三星的設備返回true上isLanguageAvailable但在後來失敗,正是這種例外setLanguage() – 2017-02-20 07:17:25

+2

@MartinVysny找到解決方法的任何運氣?我遇到了與setLanguage(...)相同的問題。 – Dogcat 2017-04-16 17:26:18

+0

不好意思,對不起。我所想到的只是向用戶傳播,以便向三星發送垃圾郵件來解決這個問題;) – 2017-04-18 06:04:50

回答

3

我發現,我得到這個例外,也當我試圖做類似TextToSpeech.getDefaultVoice,或TextToSpeech.getVoices(),或TextToSpeech.getVoice()。我通過不調用它們來解決這個問題,而是通過默認的Locale來獲取我想通過Voices對象獲得的內容。

所以在我的情況,我想知道的語言環境,所以我可以選擇一種語言,所以我做了以下

  Locale lTest = Locale.getDefault(); 
      res = mTTS.isLanguageAvailable(lTest); 
相關問題