【问题标题】:TTS causing IllegalArgumentException:Invalid int: "OS" during onInit in some Samsung devices with android api 23TTS 导致 IllegalArgumentException:Invalid int: "OS" during onInit in some Samsung devices with android api 23
【发布时间】:2017-09-09 12:45:29
【问题描述】:

经过广泛的研究,我仍然找不到解决此问题的方法或解决方案。

TTS(Text-To-Speech) 导致 IllegalArgumentException:Invalid int: "OS" during onInit 在一些带有 android api 23 的三星设备中。

  • 代码:

    public void TTSInit(){
      mTextToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
    
        @Override
        public void onInit(int status) {
            if (status != TextToSpeech.ERROR) {
                Log.i(TAG, "entered ttsinit");
                mTextToSpeech.setLanguage(Locale.ENGLISH);   
            }
        }
      });
    }
    
  • 堆栈跟踪:

    java.lang.IllegalArgumentException: Invalid int: "OS"
      at android.os.Parcel.readException(Parcel.java:1624)
      at android.os.Parcel.readException(Parcel.java:1573)
      at android.speech.tts.ITextToSpeechService$Stub$Proxy.getVoices(ITextToSpeechService.java:796)
      at android.speech.tts.TextToSpeech.getVoice(TextToSpeech.java:1769)
      at android.speech.tts.TextToSpeech.access$1100(TextToSpeech.java:59)
      at android.speech.tts.TextToSpeech$12.run(TextToSpeech.java:1581)
      at android.speech.tts.TextToSpeech$12.run(TextToSpeech.java:1531)
      at android.speech.tts.TextToSpeech$Connection.runAction(TextToSpeech.java:2337)
      at android.speech.tts.TextToSpeech.runAction(TextToSpeech.java:747)
      at android.speech.tts.TextToSpeech.runAction(TextToSpeech.java:737)
      at android.speech.tts.TextToSpeech.setLanguage(TextToSpeech.java:1531)
      at com.jisoopaullee.myengvocamanager.MainActivity$3.onInit(MainActivity.java:325)
      at android.speech.tts.TextToSpeech.dispatchOnInit(TextToSpeech.java:820)
      at android.speech.tts.TextToSpeech.access$1900(TextToSpeech.java:59)
      at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute(TextToSpeech.java:2251)
      at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute(TextToSpeech.java:2206)
      at android.os.AsyncTask.finish(AsyncTask.java:651)
      at android.os.AsyncTask.access$500(AsyncTask.java:180)
      at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:158)
      at android.app.ActivityThread.main(ActivityThread.java:7225)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    

谢谢。

【问题讨论】:

标签: android text-to-speech illegalargumentexception


【解决方案1】:
        int iLcl=mTts.setLanguage(new Locale(stringsLcl[0],stringsLcl[1]));//
        if(iLcl == TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE){
            Voice voiceLcl = mTts.getVoice();
            if(null == voiceLcl)
                l.a(800);// pardon, my logging
            Set<String> featuresLcl=voiceLcl.getFeatures();
            l.a(featuresLcl.size());
            for(String sLcl : featuresLcl)
                l.a("feature = "+ sLcl);
        };
        l.a(stringsLcl[0]+stringsLcl[1]);

        String myText1 = hashtumPoraMatnash;
        mTts.speak(myText1, TextToSpeech.QUEUE_FLUSH, null);

【讨论】:

    猜你喜欢
    • 2014-12-31
    • 2023-02-16
    • 2023-03-08
    • 2017-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多