【发布时间】:2020-04-17 04:32:11
【问题描述】:
我创建了 ionic 应用程序并使用 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 权限。
请帮我解决这个问题。提前致谢
【问题讨论】:
标签: ios iphone cordova-plugins speech-to-text ionic5