Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.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
如何在Android wear中更改语音识别语言_Android_Speech Recognition_Wear Os_Recognizer Intent - Fatal编程技术网

如何在Android wear中更改语音识别语言

如何在Android wear中更改语音识别语言,android,speech-recognition,wear-os,recognizer-intent,Android,Speech Recognition,Wear Os,Recognizer Intent,我想使用RecogniterIntent和默认android wear UI实现关键词语音识别 问题是我无法更改android wear watch收听的默认语言。由于识别错误,我只想识别英语单词,不想更改手机的默认语言。我在做这样的事情: private void displaySpeechRecognizer() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.pu

我想使用RecogniterIntent和默认android wear UI实现关键词语音识别

问题是我无法更改android wear watch收听的默认语言。由于识别错误,我只想识别英语单词,不想更改手机的默认语言。我在做这样的事情:

private void displaySpeechRecognizer() {

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
    startActivityForResult(intent, SPEECH_REQUEST_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {
        List<String> results = data.getStringArrayListExtra(
                RecognizerIntent.EXTRA_RESULTS);
        String spokenText = results.get(0);
        mTextView.setText(spokenText);
        if (spokenText.contains("KeyWord")) {
            Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
            long[] vibrationPattern = {0, 500, 50, 300};
            //-1 - don't repeat
            final int indexInPatternToRepeat = -1;
            vibrator.vibrate(vibrationPattern, indexInPatternToRepeat);
        }
        // Do something with spokenText
    }
    super.onActivityResult(requestCode, resultCode, data);
}
这个解决方案有效,但也不能给我英语成绩。 语音识别是由android wear watch完成的。

对不起,我没有太多使用RecognitzerIntent,所以我可以给出一个建议,也许它可以做到这一点

但是,您不能在进行中切换识别语言。 启动谷歌搜索应用程序。转到“设置语言”并在那里检查西班牙语和英语。之后点击并按住西班牙语,然后保存

您也可以尝试使用es或fr标记,就像您使用en-USfor英语一样,它也可以工作。 但是你应该使用en_US而不是en US

这将强制您的android设备在默认情况下识别西班牙语。 为了更好地理解,您可以查看Android开发者网站:

还可以看到这个问题:

对不起,我没有太多地使用RecognitizerIntent,所以我可以给出一个建议,也许它可以起到作用

但是,您不能在进行中切换识别语言。 启动谷歌搜索应用程序。转到“设置语言”并在那里检查西班牙语和英语。之后点击并按住西班牙语,然后保存

您也可以尝试使用es或fr标记,就像您使用en-USfor英语一样,它也可以工作。 但是你应该使用en_US而不是en US

这将强制您的android设备在默认情况下识别西班牙语。 为了更好地理解,您可以查看Android开发者网站:


另请参见此问题:

对不同语言使用不同的ISO代码,例如:ja对日语,de对德语使用不同的ISO代码,例如:ja对日语,de对德语使用不同的ISO代码