更改RecognizerIntent在结束语音之前完全静音等待的时间

时间:2018-08-09 16:08:40

标签: android google-speech-api

我正在使用RecognizerIntent,我的目标是记录所有内容,即使此人停止讲话一段时间。

因此我进行了搜索,有几个主题说我需要更改这两个变量:

EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS

所以,这就是我所做的:

public void promptSpeechInput() {
    Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "pt-BR");
    i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say something!");
    i.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, new Long(500000));
    i.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, new Long(5000000));

    try {
        startActivityForResult(i, 100);
    } catch(ActivityNotFoundException a) {
        Toast.makeText(MainActivity.this, "Sorry, your device doesn't support speech language!", Toast.LENGTH_LONG).show();
    }
}

我增加了EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLISEXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS的时间,但实际上没有什么区别。

我在做什么错了?

0 个答案:

没有答案