相关疑难解决方法(0)

有关语音识别的Android附加功能不起作用

我目前正在忙于语音识别,我希望语音识别器能够永远地听我说话.该应用程序的目的是,它将等待特定关键字的语音:当用户说出此关键字时,服务就可以接收用户语音命令了.经过研究,我发现我们可以完成识别器监听的时间.通过这些常数:

顺便说一句,默认识别器服务侦听大约10秒.(谷歌api)

     String EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS   The amount of time that it should take after we stop hearing speech to consider the input complete.
     String EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS    The minimum length of an utterance.
     String 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.
Run Code Online (Sandbox Code Playgroud)

http://java.llp2.dcc.ufmg.br/apiminer/docs/reference/android/speech/RecognizerIntent.html

这些是bundle类的附加功能.

问题是,当我在我的代码中使用这些常量时,它不起作用.

这是我的代码:

   intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 5000);
   intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 5000);
   intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 5000);
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,虽然我写了5000毫秒,识别器仍然会听我大约10秒钟.

你能想到这个问题吗?也许我不知道如何使用额外的或者它是关于权限,也许它跳过我的代码或我应该添加一些其他代码.

任何帮助都会得到满足.

编辑:这是我的完整代码:

VoiceRecognitionActivity.java

public class VoiceRecognitionActivity extends Activity implements
    TextToSpeech.OnInitListener {

private static final int REQUEST_CODE = …
Run Code Online (Sandbox Code Playgroud)

android speech-recognition speech-to-text

8
推荐指数
2
解决办法
6673
查看次数