AVSpeechSynthesisMarker - iOS 18 - Sync lost

Hello,

in an AVSpeechSynthesisProviderAudioUnit sending word position to host using AVSpeechSynthesisMarker / AVSpeechSynthesisMarker.Mark.word seems to be broken on iOS 18.

On the app/client side all the events are received immediately whereas they should be received synchronised with the audio.

The exact same code works perfectly on iOS 17

On the AVSpeechSynthesisProviderAudioUnit the AVSpeechSynthesisMarker are appended with the correct Position/SampleOffset

 let wordPos = NSMakeRange(characterRange.location, characterRange.length)

let marker = AVSpeechSynthesisMarker(markerType: AVSpeechSynthesisMarker.Mark.word, forTextRange:wordPos, atByteSampleOffset:byteSampleOffset)

// also tried with
// let marker = AVSpeechSynthesisMarker(wordRange:wordPos, atByteSampleOffset:byteSampleOffset)
           
markerArray.append(marker)

print("word : pos \(characterRange) - offset \(byteSampleOffset)")
        
// send events to host
 speechSynthesisOutputMetadataBlock?(markerArray, self.request!)
word : pos {7, 7} - offset 2208
word : pos {15, 8} - offset 37612
word : pos {24, 6} - offset 80368
word : pos {31, 3} - offset 118652
word : pos {35, 2} - offset 128796
...

But on the client side they are all received in the same time (at the beginning of speech) whereas on iOS 17 they arrive sync to the audio.

func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, willSpeakRangeOfSpeechString characterRange: NSRange, utterance: AVSpeechUtterance) { 
        print("characterRange : \(characterRange)")
}

Using Apple Voice/engine works so there is obviously something to change but documentation of AVSpeechSynthesisProviderAudioUnit / AVSpeechSynthesisMarker seems unchanged

Thanks in advance

AVSpeechSynthesisMarker - iOS 18 - Sync lost
 
 
Q