1

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.

Dr. Mr. Uncle
  • 484
  • 5
  • 12
  • Did you find a solution for this? I am experiencing the exact same problem. I found out that if the music is not playing, the audio will play normally through the headphones, but as soon as I start playing music, the audio will come out through apple watch's speakers. I tried every combination possible, but there is still something missing. The best I could do was to stop the music altogether, play my audio, but then I can't enable the music back again. – tf.alves Jan 22 '21 at 10:25
  • 1
    Nope unfortunately not. I’m pretty sure this is a limitation of the OS – Dr. Mr. Uncle Jan 22 '21 at 12:32
  • Thank you for your prompt reply! I have given up for now. The best I could achieve was to stop music, play sound, resume music. It's not optimal, but it is something... – tf.alves Jan 22 '21 at 12:43
  • @tf.alves how did you achieve pausing and resuming the music from watch? – Kushagra Sep 19 '22 at 08:49
  • @Kushagra Unfortunately I ended up abandoning the project, since it was not possible to achieve most of the things I wanted to develop. I can't recall how I played / paused the audio, but I recall it was not too reliable, as it would fail more often than not. – tf.alves Sep 20 '22 at 16:54

0 Answers0