[英]Ionic Cordova Speech Recognition not working when running in android version 9 or higher
Ionic Cordova 语音识别在 android 版本 8 或更低版本中工作。 但是每当我在 android 版本 9 或更高版本中运行该应用程序时,谷歌点击说话都不会显示。
还分享语音识别代码以便更好地理解:
getPermission() {
this.speechRecognition.hasPermission().then((hasPermission: boolean) => {
if (!hasPermission) {
this.speechRecognition.requestPermission();
}
});
}
startListening() {
let options = {
showPopup: true,
language: "en-US",
};
this.speechRecognition.startListening(options).subscribe((matches) => {
this.matches = matches;
this.cd.detectChanges();
});
this.isRecording = true;
}
stopListening() {
this.speechRecognition.stopListening().then(() => {
this.isRecording = false;
});
}
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<queries>
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
</queries>
将上面的代码添加到AndroidManifest.xml 已经解决了我的问题。 Ionic Cordova 语音识别正在与 Android 11 合作。
虽然在我的例子中环境不是离子的,但只有 cordova。 我检查了 android10 和 7,8 设备,它们正在工作。 下载android SDK对应的API,安装cordova-plugin-speechrecognition,cordova版本为v11.0。
我知道它不适用于 android11 设备,所以我一直在寻找解决方案。 根据一些信息,androidManifest.xml 似乎包含“android.speech.RecognitionService”。 但我不知道该怎么做...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.