android voice recognition,语音识别作为Service实现。 语音识别API在android.speech中 API大致分成应用端API和service端API
RecognizerIntent
(运行例子1的前提是,google voice search应用已经安装,这样确保Service已经安装了) 注意,需要微调程序中的RecognizerIntent的三个参数,可以得到不同的运行效果,简单,参考javadoc即可。
Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
以上是最简单的方式,只需要RecognizerIntent一个类就搞定
自己实现RecognitionService
如果要自己做一个识别引擎Service,是可以的。Android提供了RecognitionService抽象类 识别引擎作为Service存在,要实现这个抽象类. This RecognitionService class should be extended only in case you wish to implement a new speech recognizer.
Android SDK提供了一个sample VoiceRecognitionService extends RecognitionServiceÿ