本文介绍了如何传递的音频文件作为输入,而不是录制的语音到谷歌搜索的声音吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我对麦克风说话以下code可以使用谷歌语音搜索识别的声音。
我如何传递的音频文件作为输入,而不是麦克风谷歌搜索的声音吗?
私人无效startVoiceRecognitionActivity(){
意向意图=新意图(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,语音识别演示);
startActivityForResult(意向,VOICE_RECOGNITION_REQUEST_ code);
}@覆盖
保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
如果(要求code == VOICE_RECOGNITION_REQUEST_ code和;&安培;结果code == RESULT_OK){
//装满字符串列表视图中的识别器认为它可能已经听说
ArrayList的<串GT;比赛= data.getStringArrayListExtra(
RecognizerIntent.EXTRA_RESULTS);
mList.setAdapter(新ArrayAdapter<串GT;(这一点,android.R.layout.simple_list_item_1,
火柴));
} super.onActivityResult(要求code,结果code,数据);
}
解决方案
您无法通过Android的语音识别API将音频文件(如Android版V4.3的)。
The following code can recognise voice using Google voice search when I speak to microphone.
How can I pass an audio file as input instead of microphone to 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);
}
解决方案
You cannot pass an audio file through the Android speech recognition API (as of Android v4.3).
这篇关于如何传递的音频文件作为输入,而不是录制的语音到谷歌搜索的声音吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!