我创建了离子应用程序,并使用了cordova-plugin-speechrecognition进行语音到文本的转换。这在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权限。
请帮助我。在此先感谢
它实际上有效,但有延迟,因此无法识别其触发。