如何增加android语音识别监听的时间?

时间:2021-02-22 16:15:14

标签: android speech-recognition

我尝试放入以下意图数据:
Long googleVoiceTimeout = new Long(15000);

speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, googleVoiceTimeout);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, googleVoiceTimeout);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS,googleVoiceTimeout);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS,true);

但即使做了这一切,它仍然有时会在一秒钟的沉默后停止聆听。没有一致性。帮助?

非常感谢

1 个答案:

答案 0 :(得分:1)

根据文档,这些值可能无效。这取决于语音识别器的实现,这可能会因 Android 版本和/或不同手机型号而异。

例如这里是 EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS 的文档:

/**
 * The amount of time that it should take after we stop hearing speech to consider the input
 * possibly complete. This is used to prevent the endpointer cutting off during very short
 * mid-speech pauses. 
 * 
 * Note that it is extremely rare you'd want to specify this value in an intent. If
 * you don't have a very good reason to change these, you should leave them as they are. Note
 * also that certain values may cause undesired or unexpected results - use judiciously!
 * Additionally, depending on the recognizer implementation, these values may have no effect.
 */
public static final String EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS =
        "android.speech.extras.SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS";

您可以找到 here 中描述的所有 Intent 属性。