2014-11-04 27 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); 
相关问题