I'm trying to work with speech recognition in iOS, but I guess we're not getting friends...
I've set up an SFSpeechRegonizer
and set its delegate accordingly. Now I implement the delegate method as follows:
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 })")
}
This prints out something as follows whenever the delegate method is called:
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]
The transcription is good. However, the alternativeSubstrings
arrays are always empty and the confidence
values are 0 most of the time. Every now and then they are non-zero – but it's unpredictable when this happens:
confidence: [0.56, 0.049, 0.558, 0.545, 0.476, 0.6, 0.654, 0.647, 0.829]
Why are there no alternativeSubstrings
, why is the confidence
0 most of the time and how can I fix this? I Apple's Speech library simply broken or what's wrong?