首页 > 解决方案 > 语音识别:备用子串始终为空,大部分时间置信度为 0

问题描述

我正在尝试在 iOS 中使用语音识别,但我想我们没有交到朋友……

我已经设置了一个SFSpeechRegonizer并相应地设置了它的委托。现在我实现委托方法如下:

func speechRecognitionTask(_ task: SFSpeechRecognitionTask, didHypothesizeTranscription transcription: SFTranscription) {
    print("transcription:         \(transcription.formattedString)")
    print("alternativeSubstrings: \(transcription.segments.map { $0.alternativeSubstrings })")
    print("confidence:            \(transcription.segments.map { $0.confidence })")
}

每当调用委托方法时,都会打印出如下内容:

transcription:         Space – the final frontier. These are the voyages…
alternativeSubstrings: [[], [], [], [], [], [], [], [], []]
confidence:            [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

转录很好。但是,alternativeSubstrings数组始终为空,并且confidence大多数时间值为 0。时不时地它们是非零的——但是当这种情况发生时它是不可预测的:

confidence:            [0.56, 0.049, 0.558, 0.545, 0.476, 0.6, 0.654, 0.647, 0.829]

为什么没有alternativeSubstrings,为什么confidence大部分时间都是 0,我该如何解决这个问题?我 Apple 的语音库只是坏了或有什么问题?

标签: iosspeech-recognitionspeech-to-texttranscriptionsfspeechrecognizer

解决方案


推荐阅读