2017-07-20 93 views
0

在我的iOS应用程序中,我试图使用iOS 10的最新功能Speech API转录预先录制的音频。SFSpeechRecognizer(Siri转录)iOS应用程序超时错误

包括documentation在内的多个源声明,Speech API(更具体而言,SFSpeechRecognizer)的音频持续时间限制为1分钟。

在我的代码中,我发现任何长度大约为15秒或更长的音频文件都会得到以下错误。

Error Domain = kAFAssistantErrorDomain Code = 203“Ses[email protected]50a8e246,Message =超时等待30000 ms后的命令”UserInfo = {NSLocalizedDescription = SessionId = com .msi.cortex.ace.speech.session.event.SpeechSessionId @ 50a8e246,Message =在30000 ms后等待命令超时,NSUnderlyingError = 0x170248c40 {Error Domain = SiriSpeechErrorDomain Code = 100“(null)”}}

I已经在互联网上搜索,并没有找到解决办法。也有一些人有同样的问题。有些人怀疑这是Nuance的问题。

同样值得注意的是,我从转录过程中得到了部分结果。

以下是我的iOS应用程序中的代码。 `//创建一个语音识别器请求对象。 让srRequest = SFSpeechURLRecognitionRequest(网址:位置) srRequest.shouldReportPartialResults =假

sr?.recognitionTask(with: srRequest) { (result, error) in 
     if let error = error { 
      // Something wrong happened 
      print(error.localizedDescription) 
     } else { 
      if let result = result { 
       print(4) 
       print(result.bestTranscription.formattedString) 
       if result.isFinal { 
        print(5) 
        transcript = result.bestTranscription.formattedString 
        print(result.bestTranscription.formattedString) 

        // Store the transcript into the database. 
        print("\nSiri-Transcript: " + transcript!) 

        // Store the audio transcript into Firebase Realtime Database 
        self.firebaseRef = FIRDatabase.database().reference() 

        let ud = UserDefaults.standard 
        if let uid = ud.string(forKey: "uid") { 
         print("Storing the transcript into the database.") 
         let path = "users" + "/" + uid + "/" + "siri_transcripts" + "/" + date_recorded + "/" + filename.components(separatedBy: ".")[0] 
         print("transcript database path: \(path)") 
         self.firebaseRef.child(path).setValue(transcript) 
        } 
       } 
      } 
     } 
    }` 

谢谢您的帮助。

回答

1

我还没有确认我的答案,除了别人遇到同样的问题,但我相信这是对预先录制的音频的无证限制。

0

删除result.isFinal,并对结果进行空检查。参考:https://github.com/mssodhi/Jarvis-ios/blob/master/Jarvis-ios/HomeCell%2Bspeech.swift

+0

谢谢你的回应。不幸的是,问题依然存在。我认为这与Apple在不改变文档的情况下改变音频文件长度的限制有关。它也可能是预先录制音频的无证限制。 – itsSLO

+0

@itsSLO您是否尝试使用实况音频馈送,即使用麦克风而不是预先录制的文件? –

+0

我还没有,因为我目前没有用于此情况的用户案例。据说,我相信使用实时音频馈送将具有比预先录制的音频更高的限制。 – itsSLO

相关问题