我在我的一个项目中实现了SpeechToText函数。我想知道是否可以检测到SpeechToText函数何时完成,以便我可以立即实现振动。任何人都可以告诉我这是否可能?如果是的话,请给我一些细节。谢谢!这是我实施的代码:
@Override
public void onUtteranceCompleted(String utteranceId) {
// TODO Auto-generated method stub
// Get instance of Vibrator from current Context
Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// Vibrate for 300 milliseconds
mVibrator.vibrate(300);
Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
try {
startActivityForResult(intent, RESULT_SPEECH);
feedbackTextView.setText("");
} catch (ActivityNotFoundException a) {
Toast t = Toast.makeText(getApplicationContext(),
"Opps! Your device doesn't support Speech to Text",
Toast.LENGTH_SHORT);
t.show();
}
}