ionic cordova语音识别插件在Android上运行良好,但在ios上失败

时间:2020-04-20 05:59:47

标签: ios ionic-framework cordova-plugins speech-recognition xcode8

我创建了离子应用程序,并使用了cordova-plugin-speechreognition进行语音到文本的转换。

应用中使用的代码如下:

              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();

 }

此代码在调用Google语音Api的android上运行良好。 当我在iOS上运行它时,我做了必要的更改,例如添加 ios的info.plist中的NSSpeechRecognitionUsageDescription权限。

不确定,但是当我通过Apple开发者帐户测试飞行应用程序对其进行测试时,语音识别在ios 13.3上不起作用。

预先感谢

1 个答案:

答案 0 :(得分:0)

抱歉,“speechRecognition”仅适用于网络。我尝试在移动设备上运行了 2-3 天,但没有成功。

enter image description here