Speech recognition 语音识别器是否仅在Android Wear连接到智能手机时可用?

Speech recognition 语音识别器是否仅在Android Wear连接到智能手机时可用?,speech-recognition,wear-os,Speech Recognition,Wear Os,我使用的是android.speech.SpeechRecognitor,只有通过蓝牙连接到配对手机时,它才会工作。如果我禁用手机的蓝牙,SpeechRecognizer将停止工作。这适用于与iPhone或Android手机配对。激活的电话连接真的是一种限制吗?查看文档,看起来仍然可以通过使用系统的SpeechRecognitor活动来完成 您只需使用ACTION\u RECOGNIZE\u SPEECH集合调用startActivityForResult,它将启动活动并通过活动结果返回数据 p

我使用的是android.speech.SpeechRecognitor,只有通过蓝牙连接到配对手机时,它才会工作。如果我禁用手机的蓝牙,
SpeechRecognizer
将停止工作。这适用于与iPhone或Android手机配对。激活的电话连接真的是一种限制吗?

查看文档,看起来仍然可以通过使用系统的SpeechRecognitor活动来完成

您只需使用
ACTION\u RECOGNIZE\u SPEECH
集合调用
startActivityForResult
,它将启动活动并通过活动结果返回数据

private static final int SPEECH_REQUEST_CODE = 0;

// Create an intent that can start the Speech Recognizer activity
private void displaySpeechRecognizer() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
    RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    // Start the activity, the intent will be populated with the speech text
    startActivityForResult(intent, SPEECH_REQUEST_CODE);
}

// This callback is invoked when the Speech Recognizer returns.
// This is where you process the intent and extract the speech text from the intent.
@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);
        // Do something with spokenText
    }
    super.onActivityResult(requestCode, resultCode, data);
}
private static final int SPEECH\u REQUEST\u code=0;
//创建可以启动语音识别器活动的意图
私有void displaySpeechRecognizer(){
意向意向=新意向(识别意向、行动、识别言语);
intent.putExtra(识别器intent.EXTRA_语言_模型,
识别者意图、语言、模型、自由形式);
//开始活动时,将用语音文本填充意图
startActivityForResult(意图、言语请求代码);
}
//语音识别器返回时调用此回调。
//这是您处理意图并从意图中提取语音文本的地方。
@凌驾
受保护的void onActivityResult(int请求代码、int结果代码、意图数据){
if(requestCode==SPEECH\u REQUEST\u CODE&&resultCode==RESULT\u OK){
列表结果=data.getStringArrayListExtra(
识别者意图。额外结果);
字符串spokenText=results.get(0);
//用spokenText做点什么
}
super.onActivityResult(请求代码、结果代码、数据);
}

你能给我指一下文档吗?文档中说,如果我们直接使用
SpeechRecognizer
,我们只需要蓝牙连接。我的目标是不使用系统活动(因为它会离开我们的UI),而是在我们的应用程序中识别语音。我指的是。它将系统提供的语音动作定义为基于任务的,内置于wear平台本身。我相信这就是你可能需要在wear应用程序中识别语音的地方。谢谢你的链接!恐怕这段视频无法回答我的问题,我是否只能在蓝牙连接有效的情况下使用SpeechRecognitor。