我想迅速识别来自SFSpeechRecognizer的单词

问题描述

所以基本上我想在我的应用程序中使用语音来文本,用户可以通过呼叫他们的答案号码来选择一个选项,例如:12,35等,他们是多个答案,除了可以合并数字之外,其他一切都很好,例如 如果用户通过语音选择了30号答案,它将很好地解决问题(将选择30号),但是当用户可以更改20号答案时,结果将是3020,且无法识别

这是我的代码

  func startSpeechRecognization(){
   
   
          let node = audioEngine.inputNode
          let recordingFormat = node.outputFormat(forBus: 0)
          
          node.installTap(onBus: 0,bufferSize: 1024,format: recordingFormat) { (buffer,_) 
          in
              self.request.append(buffer)
          }
          
          audioEngine.prepare()
          do {
              try audioEngine.start()
          } catch let error {
            //  alertView(message: "Error comes here for starting the audio listner =\(error.localizedDescription)")
          }
          
          guard let myRecognization = SFSpeechRecognizer() else {
             // self.alertView(message: "Recognization is not allow on your local")
              return
          }
          
          if !myRecognization.isAvailable {
             // self.alertView(message: "Recognization is free right Now,Please try again after some time.")
          }
          
    self.task = speechReconizer?.recognitionTask(with: request,resultHandler: { (response,error) in
              guard let response = response else {
                var isFinal = false
                
                  if error != nil {
  //                    self.alertView(message: error.debugDescription)
                  }else {
  //                    self.alertView(message: "Problem in giving the response")
                  }
                  return
              }
               self.texting = ""
            let message = response.bestTranscription.formattedString
       
             self.texting = message
            print(self.texting)
            self.table.reloadData()

              
          })
  }

语音对文本的第一,第二和第三结果:first result :40(works fine) second result 4039(unrecognisable) it will be only 39

third result 40 3940(unrecognisable) it will be only 40 because i choose 40 again

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)