我已经创建了ionic应用程序,并使用cordova-plugin- speech进行语音到文本的转换。
应用程序中使用的代码如下:
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();
}这段代码在android上运行良好,google speech Api就是在android上调用的。当我在iOS上运行它时,我做了必要的更改,比如在ios的info.plist中添加了NSSpeechRecognitionUsageDescription权限。
不确定,但语音识别不能在iOS13.3上工作,当我通过苹果开发人员帐户测试飞行应用程序测试它时。
提前感谢
发布于 2021-02-04 15:26:55
很抱歉,"speechRecognition“只能在网络上使用。我试着在手机上运行了2-3天,但不起作用。

https://stackoverflow.com/questions/61315995
复制相似问题