Android 我可以使用谷歌语音搜索来识别背景中的语音吗?

Android 我可以使用谷歌语音搜索来识别背景中的语音吗?,android,google-app-engine,Android,Google App Engine,我已经学习了Android ApiDemos的示例代码,当我对着麦克风说话时,下面的代码可以使用谷歌语音搜索识别语音 但是谷歌语音搜索有一些问题,谷歌语音搜索必须在线才能工作 我已将我的语音保存到一个文件中,如何进行谷歌语音搜索以识别语音文件并返回结果 private void startVoiceRecognitionActivity() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

我已经学习了Android ApiDemos的示例代码,当我对着麦克风说话时,下面的代码可以使用谷歌语音搜索识别语音

但是谷歌语音搜索有一些问题,谷歌语音搜索必须在线才能工作

我已将我的语音保存到一个文件中,如何进行谷歌语音搜索以识别语音文件并返回结果

private void startVoiceRecognitionActivity() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo");
    startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
        // Fill the list view with the strings the recognizer thought it could have heard
        ArrayList<String> matches = data.getStringArrayListExtra(
                RecognizerIntent.EXTRA_RESULTS);
        mList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
                matches));
    }

    super.onActivityResult(requestCode, resultCode, data);
}
private void startVoiceRecognitionActivity(){
意向意向=新意向(识别意向、行动、识别言语);
intent.putExtra(识别器intent.EXTRA_语言_模型,
识别者意图、语言、模型、自由形式);
intent.putExtra(RecognizerIntent.EXTRA_提示符,“语音识别演示”);
startActivityForResult(意图、语音识别、请求、代码);
}
@凌驾
受保护的void onActivityResult(int请求代码、int结果代码、意图数据){
if(requestCode==语音识别\请求\代码和结果代码==结果\确定){
//用识别器认为可能听到的字符串填充列表视图
ArrayList matches=data.getStringArrayListExtra(
识别者意图。额外结果);
mList.setAdapter(新的ArrayAdapter)(这是android.R.layout.simple_list_item_1,
火柴);
}
super.onActivityResult(请求代码、结果代码、数据);
}

除了使用提供的API操作麦克风外,没有任何方法可以让Google语音识别器在任何其他设备上运行。同样,也没有使用底层web服务的正式方法,尽管有一种基于chromium源代码的非正式方法

如果要脱机执行语音识别,可以在设备上运行。或者,您可以尝试找到一个在线API,用于语音识别,但大多数主要API要么无法获得许可,要么非常昂贵