Question: How can I get get text-to-speech working when delivered from the Apple Watch so that it does not stop my music and it gets delivered to a bluetooth device?
I am working on a running App that has an iPhone App and an Apple Watch App. I want to periodically read some information to the user.
With the iPhone App, I can do:
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, mode: .default, policy: .default, options: [.duckOthers, .mixWithOthers])
let text = "some text"
let utterance = AVSpeechUtterance(string: text)
synthesizer.speak(utterance)
This will lower the volume of my other music, read the text, and then raise the volume. This will also work on my connected headsets.
However when I try to run this from my Apple Watch it is playing through the Watch speaker phone, not through my bluetooth connected devices.
This question is related but the answer won't work in my case. If I try to use .longFormAudio
I get this in the console:
2020-10-16 13:12:29.750696-0400 [...] [avas] AVAudioSession.mm:308:ValidateRouteSharingPolicyParameters: 0x3 category option(s) not supported in combination with AVAudioSessionRouteSharingPolicyLongFormAudio
audioSession properties weren't set because of an error.
If I remove options: [.duckOthers, .mixWithOthers]
then no more console error, and the bluetooth picker in the Watch comes up but then I cannot keep bluetooth connected on my iPhone. Kinda pulling my hair out on this one.