"将音频保存到..... @ gmail.com"使用RecognizerIntent.ACTION_RECOGNIZE_SPEECH时吐司

时间:2018-01-07 10:49:20

标签: android audio

我正在使用RecognizerIntent.ACTION_RECOGNIZE_SPEECH使用以下代码捕获音频:

public void promptSpeechInput() {
        if (checkAudioPermission()) {
            Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                    RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
            intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speak Your Query Now");
            startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
        } else {
            showShortSnackBar("Record Permission Required");
        }
    }

我已经实现了onActivityResult,如下所示:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case REQ_CODE_SPEECH_INPUT: {
                if (resultCode == RESULT_OK && null != data) {
                    ArrayList<String> result = data
                            .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                    String userQuery = result.get(0);
                    addMessage(false, "Query: \n" + userQuery);
                    txtSpeechInput.setText(userQuery);
                }
                break;
            }

        }
    }

一切都很好,除非我得到一个恼人的吐司说: &#34;将音频保存到..... @ gmail.com&#34; 我怎样才能摆脱这个祝酒词?

0 个答案:

没有答案