我创建了离子应用程序,并使用了cordova-plugin-speechreognition进行语音到文本的转换。 这在android mobile和ios模拟器中效果很好,但在IOS 13.3上不起作用
initSpeech() {
this.speechRecognition.hasPermission()
.then((hasPermission: boolean) => {
console.log(hasPermission)
if (!hasPermission) {
this.speechRecognition.requestPermission()
.then(
() => console.log('granted'),
() => console.log('Denied')
)
}
})
}
start() {
// Start the recognition process
this.speechRecognition.startListening()
.subscribe(
(matches: Array<string>) => { this.voicetext = matches[0]; this.mainForm.controls['comments'].setValue(matches[0]); },
(onerror) => console.log('error:', onerror)
)
}
//stop listening for(ios only)
stop() {
this.speechRecognition.stopListening();
}
链接https://ionicframework.com/docs/native/speech-recognition中指定的代码就是我使用的代码。
对于IOS,我还实现了停止监听并添加了NSMicrophoneUsageDescription权限 ios的info.list中的NSSpeechRecognitionUsageDescription权限。
请帮助我。预先感谢
答案 0 :(得分:0)
它实际上有效,但是有延迟,因此无法识别其触发。