Android 如何将音频文件作为输入而不是录制的语音传递到Google search voice?

Android 如何将音频文件作为输入而不是录制的语音传递到Google search voice?,android,speech-recognition,speech-to-text,Android,Speech Recognition,Speech To Text,当我对着麦克风说话时,下面的代码可以使用谷歌语音搜索识别语音 如何将音频文件作为输入而不是麦克风传递到Google search voice private void startVoiceRecognitionActivity() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,

当我对着麦克风说话时,下面的代码可以使用谷歌语音搜索识别语音

如何将音频文件作为输入而不是麦克风传递到Google search voice

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(请求代码、结果代码、数据);
}

您无法通过Android语音识别API传递音频文件(从Android v4.3开始)。

谢谢,还有其他API可以将音频文件作为输入传递吗?@Paul我不知道其他SDK(例如Nuance)是否支持此功能,请就此提出新问题。这个问题的答案是Android的
RecognizerIntent
从Android v4.3开始就不支持这一点。