SFSpeechRecognitionResult discards previous transcripts with on-device option set to true

Hi everyone, I might need some help with on-device recognition. It seems that the speech recognition task will discard whatever it has transcribed after a new sentence starts (or it believes it becomes a new sentence) during a single audio session, with requiresOnDeviceRecognition is set to true.

This doesn't happen with requiresOnDeviceRecognition set to false.

System environment: macOS 14 with Xcode 15, deploying to iOS 17

Thank you all!

  • Hi, did you find a way to resolve this weird behaviour?

Add a Comment

Replies

Did some further research into this topic. It seem that the SFTranscriptSegment array of the result will be cleared after certain standards were meet.

By doing

if let result {
    print("Segment.size:  \(result.bestTranscription.segments.count)")
    //reset of the code... 
}

At the time when the contents get cleared, it prints out like this on console:

...
Segment.size:  108
Segment.size:  110
Segment.size:  111
Segment.size:  112
Segment.size:  112
Segment.size:  114
Segment.size:  105
Segment.size:  1
Segment.size:  2
Segment.size:  3
Segment.size:  4
Segment.size:  5
Segment.size:  6
...

The question can be how to determine which one will be the final result? By the way, the isFinal variable of the request never turned true during the contents being discarded.

  • Hi, did you find a way to resolve this weird behaviour?

Add a Comment

Hi, did you find a way to resolve this weird behaviour?