【问题标题】:Catch "Try Again" with ionic speech recognition用离子语音识别捕捉“再试一次”
【发布时间】:2019-09-10 02:43:46
【问题描述】:

我正在使用文档中所述的 Ionic Native 语音识别:https://ionicframework.com/docs/native/speech-recognition:

startListening() {
    this.speechRecognition.startListening()
      .subscribe(
        (matches: Array<string>) => {
          console.log(matches)
        },
        (onerror) => {
          console.log('error:', onerror)
        }
     )
}

但是,这只会监听一定的时间。如果什么都没说,或者讲话听不见,我会收到消息“点击讲话。再试一次”。然而,为此用户需要按下按钮才能再次说话。因此有没有办法在这种情况发生时捕捉到我可以再次触发this.startListening()

【问题讨论】:

    标签: ionic-framework speech-recognition ionic4 ionic-native


    【解决方案1】:

    我在文档中发现,语音识别只有 5 次,然后就停止了。

    https://github.com/pbakondy/cordova-plugin-speechrecognition

    您可以从选项开始收听:

    let options = { String language, Number matches, // increase this number if don't want to stop listening String prompt, // Android only Boolean showPopup, // Android only Boolean showPartial }

    this.speechRecognition.startListening(options) .subscribe( (matches: Array<string>) => console.log(matches), (onerror) => console.log('error:', onerror) )

    【讨论】:

    • 知道如何延长 5 秒吗?
    • 是的,就像我在选项中说的那样,您可以将数字匹配设置为您想要的 1500。它不是 5 秒,而是 5 匹配
    • let options = { matches: 1000 }
    • 它在文档中说:{Number} 返回匹配数(默认为 5,在 iOS 上:最大匹配数)。那不是我要问的对吗?
    • @JohnAndrews 您发现了如何实现这一点?延长 5 秒时间?
    猜你喜欢
    • 2020-03-08
    • 1970-01-01
    • 2015-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多