如何实现多语言语音识别ok-google风格

时间:2015-04-03 16:23:21

标签: android android-intent speech-recognition

一般来说,我们可以通过这个意图识别语音:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, locale.toString());
try {
    startActivityForResult(intent, RESULT_SPEECH);
} catch (ActivityNotFoundException a) {}

但是,当您不需要定义要识别的语言时,我想用ok-google风格实现调用。

1 个答案:

答案 0 :(得分:0)

another answer所述,没有简单的方法来调用自定义应用操作。如果您可以坚持使用预定义的系统操作之一,那么实现应该是直截了当的(拦截相对广播的Intent),但是如果您要具有自己的特定功能,则应该要求Custom one