`
carywei
  • 浏览: 191343 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

BluetoothVoiceDialerActivity

 
阅读更多

当intent为空的时候,要求重试。

 public void onRecognitionFailure(final String msg) {
            if (Config.LOGD) Log.d(TAG, "onRecognitionFailure " + msg);
            // we had zero results.  Just try again.
            askToTryAgain();
        }

 

 

//加上文本阅读器

mTts = new TextToSpeech(this, new TtsInitListener());

 

 

 

两个线程在准备onSpeechCompletion();

   class FallbackRunnable implements Runnable {
        public void run() {
            Log.e(TAG, "utterance completion not delivered, using fallback");
            // This runnable is intended as a fallback to transition to
            // the next state is for some reason we never get a
            // TTS utterance completion.  It will behave just the same
            // as if we had received utterance completion.
            onSpeechCompletion();
        }
    }

    class GreetingRunnable implements Runnable {
        public void run() {
            mState = SPEAKING_GREETING;
            mTtsParams.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,
                    SPEAK_NOW_UTTERANCE);
            mTts.speak(getString(R.string.speak_now_tts),
                TextToSpeech.QUEUE_FLUSH,
                mTtsParams);
            // Normally, the we will begin listening for the command after the
            // utterance completes.  As a fallback in case the utterance
            // does not complete, post a delayed runnable to fire
            // the intent.
            mFallbackRunnable = new FallbackRunnable();
            mHandler.postDelayed(mFallbackRunnable, MAX_TTS_DELAY);
        }
    }

//listening command

listenForCommand();

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics