0

In my iOS app most users can hear the AVSpeechSynthesisVoice correctly, but some report that it simply does not work. I haven't been able to reproduce the issue locally, but here is how I use the API:

let sentence = "the sentence to be told"

let synthesizer = AVSpeechSynthesizer()

let utterance = AVSpeechUtterance(string: sentence)
utterance.voice = AVSpeechSynthesisVoice(
  language: "en-GB"
)
utterance.rate = AVSpeechUtteranceDefaultSpeechRate * 1.05

synthesizer.speak(utterance)

This works perfectly fine on iOS 13 (tested most minors), all iOS 14 versions, all the devices I could find... but I keep getting reports of people not getting any audio feedback.

Do you have any pointers on where to look, or at least reproduce the issue?

Asperi
  • 228,894
  • 20
  • 464
  • 690
marcgg
  • 65,020
  • 52
  • 178
  • 231
  • Some people have been tripped up by the "soft mute" on iPad - go to the control center and tap the bell icon to toggle this. That could be the problem. Or did you find out any other information about this issue? I am also seeing a similar problem that is NOT due to the soft mute being on. – tdl Apr 05 '21 at 16:49
  • I'm having it on my own device, but I haven't been able to figure out what is causing the issue. – meh Dec 15 '21 at 18:23

2 Answers2

1

Does your app support localisation? I had a similar issue. In my case whenever user changes the app language to Simplified-Chinese the text used to get localised so, I had to change the AVSpeechSynthesisVoice(language: "zh-TW") as well.

You can get the list of languages from here.

Anish
  • 595
  • 1
  • 4
  • 16
  • My app supports localisation, but I'm forcing the speech language to be `"en-GB"` as you can see in the code snippet – marcgg Nov 06 '20 at 12:37
0

After playing with the API I found that setting the usesApplicationAudioSession flag to false in the instance of AVSpeechSynthesizer.

Add the following line to your code:

synthesizer.usesApplicationAudioSession = false

The issue seems to be caused by the device being on 'silent mode'.

meh
  • 22,090
  • 8
  • 48
  • 58