android - 如何在 Android 中隐藏 toast 消息 “Your audio will be sent to google to provide speech recognition service.”?

标签 android speech-recognition speech-to-text

我正在使用谷歌语音识别器在 Android 中集成语音服务,但在按下麦克风按钮时,显示了这条烦人的 toast 消息。请建议我隐藏此 toast 消息的方法。

这是我的java代码

public class FormActivity extends AppCompatActivity {

    AppCompatEditText mFeedbackView; 
    ImageView mFeedbackVoiceView;
    private final int REQ_CODE_SPEECH_INPUT_FEEDBACK = 100;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_form);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        mVisitFeedbackView = findViewById(R.id.feedback);
        mFeedbackVoiceView = findViewById(R.id.feedback_voice);

        mFeedbackVoiceView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                promptSpeechInputFeedback();
            }
        });
    }
    private void promptSpeechInputFeedback() {
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speech_prompt));
        try {
            startActivityForResult(intent, REQ_CODE_SPEECH_INPUT_FEEDBACK);
        } catch (ActivityNotFoundException a) {
            Toast.makeText(getApplicationContext(), getString(R.string.speech_not_supported), Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode) {
            case REQ_CODE_SPEECH_INPUT_FEEDBACK: {
                if (resultCode == RESULT_OK && null != data) {
                    ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); 
                    mFeedbackView.setText(result.get(0));
                }
                break;
            }  
        }
    }
}

此问题与 How to hide toast“ Your audio will be sent to google to provide speech recognition service.” in Speech Recognizer? 重复但目前还没有解决方案。

我们将不胜感激。

最佳答案

基于安卓规定 你不能隐藏系统 toast 消息,因为你无权访问系统 View ,

只有在你可以访问终端的越狱 android 中,你才能尝试这样做。

关于android - 如何在 Android 中隐藏 toast 消息 “Your audio will be sent to google to provide speech recognition service.”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50692620/

相关文章:

c# - 使用 C# 将新词添加到 Windows 语音识别

javascript - 使用java访问任何网页的Textfield和Button

android - 在 APK Android 中复制的重复文件 - 可以合并吗?

android - 警报对话框和异步任务

python - 如何删除pyspeech windows语音识别命令?

android - 增加语音识别android中RESULTS_RECOGNITION的数量

android - 如何在android中获取JsonResponse的值?

android - 快速滚动 Gridview 时项目消失。快速滚动时图像尺寸也会发生变化

python - 通过 websockets 流式传输音频 IBM 不工作

c# - 使用 SemanticResultKey 时出现 TargetInvocationException