4

在我的 iOS 应用程序中,我正在尝试使用 iOS 10 的最新功能 Speech API 转录预先录制的音频。

包括文档在内的多个来源都指出,语音 API(更具体地说是 SFSpeechRecognizer)的音频持续时间限制为 1 分钟。

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

错误域=kAFAssistantErrorDomain 代码=203“SessionId=com.siri.cortex.ace.speech.session.event.SpeechSessionId@50a8e246,消息=在 30000 毫秒后等待命令超时”UserInfo={NSLocalizedDescription=SessionId=com.siri.cortex .ace.speech.session.event.SpeechSessionId@50a8e246, Message=Timeout waiting for command after 30000 ms, NSUnderlyingError=0x170248c40 {Error Domain=SiriSpeechErrorDomain Code=100 "(null)"}}

我在整个互联网上进行了搜索,但无法找到解决此问题的方法。也有人遇到同样的问题。有些人怀疑这是 Nuance 的问题。

还值得注意的是,我确实从转录过程中获得了部分结果。

这是我的 iOS 应用程序的代码。` // 创建一个语音识别器请求对象。让 srRequest = SFSpeechURLRecognitionRequest(url: location) srRequest.shouldReportPartialResults = false

    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)
                    }
                }
            }
        }
    }`

感谢您的帮助。

4

3 回答 3

2

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

于 2017-07-28T22:11:44.017 回答
1

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

于 2017-07-22T20:39:20.227 回答
0

确实如此,我从视频中提取了音频文件,如果超过15秒就会报如下错误:

Domain = kAFAssistantErrorDomain Code = 203 "Timeout" UserInfo = {
    NSLocalizedDescription = Timeout,
    NSUnderlyingError = 0x1c0647950 {Error Domain=SiriSpeechErrorDomain Code=100 "(null)"}
}

关键问题是超过 15 秒后的音频文件识别。 result.isFinalis always 0,很郁闷的是没有准确的时间戳,虽然是“Timeout”,但识别内容却很完整,让我觉得很奇怪。

如果打印出结果遍历,可以看到有一些限制,也就是15秒,但是原因是音频文件的时间戳反馈被限制在一个有限的数量,比如15或者4或者9,领先到最后。超时反馈更不稳定。

但是在实时语音识别中,你可以在一分钟内突破15秒,如官方文档中描述的那样。

于 2019-04-22T05:40:37.050 回答