Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android:Speech to Text-URI from";“关于结果”;捆_Java_Android - Fatal编程技术网

Java Android:Speech to Text-URI from";“关于结果”;捆

Java Android:Speech to Text-URI from";“关于结果”;捆,java,android,Java,Android,我知道这个问题已经被问过了,但我似乎找不到有答案的人,所以我只是在碰运气 当我使用GoogleSpeech-to-Text API时,我正试图找回音频文件。到目前为止,我已经成功了,但我只能通过语音对话框来完成。我正在尝试在没有对话框的情况下做同样的事情 基本上,我正在尝试获取“onResults”中“Bundle Results”的URI,以便获取音频文件 我正在尝试这样做(请求代码语音输入为100): private void promptSpeechInput(){ 意向意向=新意向(识别

我知道这个问题已经被问过了,但我似乎找不到有答案的人,所以我只是在碰运气

当我使用GoogleSpeech-to-Text API时,我正试图找回音频文件。到目前为止,我已经成功了,但我只能通过语音对话框来完成。我正在尝试在没有对话框的情况下做同样的事情

基本上,我正在尝试获取“onResults”中“Bundle Results”的URI,以便获取音频文件

我正在尝试这样做(请求代码语音输入为100):

private void promptSpeechInput(){
意向意向=新意向(识别意向、行动、识别言语);
intent.putExtra(识别器intent.EXTRA_语言_模型,
识别者意图、语言、模型、自由形式);
intent.putExtra(RecognizerIntent.EXTRA_语言,Locale.getDefault());
intent.putExtra(识别器intent.EXTRA\u提示符,
getString(R.string.speech_提示符);
//用于获取返回的音频文件
intent.putExtra(“android.speech.extra.GET_AUDIO_FORMAT”,“AUDIO/AMR”);
intent.putExtra(“android.speech.extra.GET_AUDIO”,true);
startActivityForResult(意图、请求代码、语音输入);
受保护的void onActivityResult(int请求代码、int结果代码、意图数据){
super.onActivityResult(请求代码、结果代码、数据);
开关(请求代码){
案例请求代码语音输入:{
if(resultCode==RESULT\u OK&&null!=数据){
Bundle=data.getExtras();
ArrayList result_text=data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
ArrayList results\u audio=bundle.getStringArrayList(RecognizerIntent.EXTRA\u results);
txtSpeechInput.setText(result_text.get(0));
Uri audioUri=data.getData();
ContentResolver ContentResolver=getContentResolver();
}
}
}
}
在这里:

    speech = SpeechRecognizer.createSpeechRecognizer(this);
    speech.setRecognitionListener(this);
    recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE,
            "en-us");
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
            this.getPackageName());



    // for getting audio file returned
    recognizerIntent.putExtra("android.speech.extra.GET_AUDIO_FORMAT", "audio/AMR");
    recognizerIntent.putExtra("android.speech.extra.GET_AUDIO", true);

@Override
public void onResults(Bundle results) {

    //Bundle bundle = data.getExtras();

    ArrayList<String> result_text = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    //ArrayList<String> results_audio = results.getStringArrayList(RecognizerIntent.EXTRA_RESULTS);

    returnedText.setText(result_text.get(0));

    Uri audioUri = recognizerIntent.getExtras();
    ContentResolver contentResolver = getContentResolver();
SpeechRecognizer=SpeechRecognizer.createSpeechRecognizer(this);
speech.setRecognitionListener(此);
recognizerIntent=新意图(recognizerIntent.ACTION\u recognizer\u SPEECH);
recognizerIntent.putExtra(recognizerIntent.EXTRA_语言_首选项,
“美国”);
recognizerIntent.putExtra(recognizerIntent.EXTRA_调用_包,
这个.getPackageName());
//用于获取返回的音频文件
recognizerIntent.putExtra(“android.speech.extra.GET_AUDIO_FORMAT”,“AUDIO/AMR”);
recognizerIntent.putExtra(“android.speech.extra.GET_AUDIO”,true);
@凌驾
公共结果(捆绑结果){
//Bundle=data.getExtras();
ArrayList result\u text=results.getStringArrayList(SpeechRecognitor.results\u RECOGNITION);
//ArrayList results\u audio=results.getStringArrayList(RecognizerIntent.EXTRA\u results);
returnedText.setText(result_text.get(0));
Uri audioUri=recognizerIntent.getExtras();
ContentResolver ContentResolver=getContentResolver();
有可能吗?或者至少,有可能使对话框不可见吗?非常感谢

    speech = SpeechRecognizer.createSpeechRecognizer(this);
    speech.setRecognitionListener(this);
    recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE,
            "en-us");
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
            this.getPackageName());



    // for getting audio file returned
    recognizerIntent.putExtra("android.speech.extra.GET_AUDIO_FORMAT", "audio/AMR");
    recognizerIntent.putExtra("android.speech.extra.GET_AUDIO", true);

@Override
public void onResults(Bundle results) {

    //Bundle bundle = data.getExtras();

    ArrayList<String> result_text = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    //ArrayList<String> results_audio = results.getStringArrayList(RecognizerIntent.EXTRA_RESULTS);

    returnedText.setText(result_text.get(0));

    Uri audioUri = recognizerIntent.getExtras();
    ContentResolver contentResolver = getContentResolver();