【问题标题】:IllegalArgumentException: Invalid int: "OS" with Samsung ttsIllegalArgumentException: Invalid int: "OS" with Samsung tts
【发布时间】:2014-12-31 01:03:46
【问题描述】:

我在我的 android 应用程序中使用文本到语音。它与 Google TT 和 espeak 一起工作正常,但是当我与三星 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)

【问题讨论】:

  • 对我来说,三星设备在 isLanguageAvailable 上返回 true,但稍后在 setLanguage() 期间失败并出现此异常
  • @MartinVysny 运气好能找到解决方法吗?我对 setLanguage(...) 有同样的问题。
  • 不走运,抱歉。我只想向用户宣讲,向三星发送垃圾邮件以解决此问题;)
  • 当您将默认引擎更改为 google tts 时是否解决了问题?

标签: android exception text-to-speech


【解决方案1】:

我发现当我尝试执行TextToSpeech.getDefaultVoiceTextToSpeech.getVoices()TextToSpeech.getVoice() 之类的操作时,也会出现此异常。我通过不调用它们来解决此问题,而是通过默认区域设置来获取我试图通过 Voices 对象获取的内容。

所以在我的情况下,我想知道语言环境以便我可以选择一种语言,所以我做了以下操作

            Locale lTest = Locale.getDefault();
            res = mTTS.isLanguageAvailable(lTest);

【讨论】:

    【解决方案2】:

    我用它来避免引发异常。

        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);
        }
    

    【讨论】:

      猜你喜欢
      • 2017-09-09
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 2011-02-06
      • 1970-01-01
      • 2022-01-09
      相关资源
      最近更新 更多