I need to use AVSpeechSynthesizer to read a text to my user.
User will control reading with AirPods, so I need to use MPRemoteCommandCenter.
For now, I need to prepare my audio files using AVSpeechSynthesizer.write(_:toBufferCallback:) the create a playlist and read it using AVQueuePlayer.
It works. But preparing audio files take time. I prefer to use AVSpeechSynthesizer.speak(_:) directly in background mode, and activate it via MPRemoteCommandCenter commands.
Is this possible? Or perhaps any workaround?
Thank you!
i have the same issue, and now figure out the only thing you need to do
at the begining. don't use
.duckOthers,.mixWithOthersaddTarget to RemoteCommand
at the
speechSynthesizer(_:didStart:)andspeechSynthesizer(_:willSpeakRangeOfSpeechString:utterance:)update the UI