我对Android中的语音识别感兴趣,但我不能这样做:它不是连续的。如果你停止说话,它就不会继续,你必须再次点击按钮。
我不想要这种行为..
有人对我能解决这个问题有任何建议吗?
首次识别语音我不想要这种行为。
以下是代码:
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)
{
}