RecognitionListener.onReadyForSpeech()中的DTMF音调被误认为是语音

srf*_*srf 9 android speech-recognition voice-recognition

从您通过startActivityForResult()调用它之前,Google语音搜索会显着延迟,直到显示其对话框,准备好发表演讲.

这要求用户在说话之前始终查看屏幕,等待显示对话框.

所以我想通过实现RecognitionListener并在onReadyForSpeech()中发出DTMF音来生成声音信号而不是对话框,如下面的代码片段所示:

  @Override
  public void onReadyForSpeech(Bundle params) {
    Log.d(LCTAG, "Called when the endpointer is ready for the user to start speaking.");
    mToneGenerator.startTone(ToneGenerator.TONE_DTMF_1);
    try {
      Thread.sleep(50);
    } catch (InterruptedException e) {
      Log.e(LCTAG, "InterruptedException while in Thread.sleep(50).");        
      e.printStackTrace();
    } // SystemClock.sleep(50);
    mToneGenerator.stopTone();
  }
Run Code Online (Sandbox Code Playgroud)

音调听起来很漂亮但是......它也被麦克风"听到",到达语音识别服务并始终产生识别错误ERROR_NO_MATCH.

有办法解决这个问题吗?

Ebo*_*ike 5

这是一个随机的想法,它可能不起作用.

您可以尝试在AudioManager.setMicrophoneMute播放音调时禁用麦克风(可能是通过)吗?