语音只有一次 [英] Speech only first time
本文介绍了语音只有一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我感兴趣的是Android中的语音识别,但我不能做到这一点:它是不连续的。如果你停止发言,它不会继续,你必须再次点击按钮。
我不希望这种行为。
没有任何人有任何建议,我可以解决这一问题?
中确认的演讲只有第一次我不希望这种行为。
下面是code:
私人SpeechRecognizer讲话; @覆盖
公共无效的onCreate(捆绑savedInstanceState)
{
super.onCreate(savedInstanceState);
的setContentView(R.layout.main); 演讲= SpeechRecognizer.createSpeechRecognizer(本);
speech.setRecognitionListener(本); 意向意图=新意图(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_ preFERENCE,恩);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName()); speech.startListening(意向);
} @覆盖
公共无效onBeginningOfSpeech()
{
} @覆盖
公共无效onBufferReceived(字节[]为arg0)
{
} @覆盖
公共无效onEndOfSpeech()
{
} @覆盖
公共无效onerror的(INT E)
{
} @覆盖
公共无效的onEvent(INT为arg0,ARG1捆绑)
{
} @覆盖
公共无效onPartialResults(捆绑为arg0)
{
}
公共无效onReadyForSpeech(捆绑为arg0)
{
} @覆盖
公共无效onResults(包数据)
{
ArrayList的<串GT;比赛= data.getStringArrayList(
SpeechRecognizer.RESULTS_RECOGNITION);
} @覆盖
公共无效onRmsChanged(浮点为arg0)
{
}
解决方案
再次尝试拨打
speech.startListening(意向);
里面的结果和的OnError。
I am interested in speech recognition in Android but I can't do it: it is not continuous. If you stop speaking, it doesn't continue, and you have to click on the button again.
I do not want this behaviour..
Does anybody have any suggestions as to what I can to fix this?
Recognise speech only first time I do not want this behaviour.
Here is the code:
private SpeechRecognizer speech;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
speech = SpeechRecognizer.createSpeechRecognizer(this);
speech.setRecognitionListener(this);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
speech.startListening(intent);
}
@Override
public void onBeginningOfSpeech()
{
}
@Override
public void onBufferReceived(byte[] arg0)
{
}
@Override
public void onEndOfSpeech()
{
}
@Override
public void onError(int e)
{
}
@Override
public void onEvent(int arg0, Bundle arg1)
{
}
@Override
public void onPartialResults(Bundle arg0)
{
}
public void onReadyForSpeech(Bundle arg0)
{
}
@Override
public void onResults(Bundle data)
{
ArrayList<String> matches = data.getStringArrayList(
SpeechRecognizer.RESULTS_RECOGNITION);
}
@Override
public void onRmsChanged(float arg0)
{
}
解决方案
Try to call again
speech.startListening(intent);
inside On Results and OnError.
这篇关于语音只有一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文