Text to Speech API (AVSpeechSynthesisVoice) broken in iOS 13 GM

4.4k Views Asked by At

Update

I installed the iOS 13 GM on a different device, and did not encounter this issue. So I'm no longer sure if this is specific to the iOS 13 GM, or something about the way I installed it. On the first device (an iPhone X), I did an upgrade (via the "Option Key + Check for Update Button" in iTunes). On the second device (an iPhone SE), I did a full restore. Not sure yet what caused it to get into this state.

Original Question

AVSpeechSynthesisVoice.speechVoices() reports that there are no voices available when I run it on my device with the iOS 13 GM. And indeed, when I try to load a voice using AVSpeechSynthesisVoice(identifier:) it always returns nil. It works in the simulator. I don't believe this was an issue with the previous betas, and it seems to work in iOS 13.1 beta 2 and 3.

Has anyone encountered this, and figured out any sort of workaround? I don't see any documentation of an intentional change to this behavior, so I suspect this is a bug. I intend to file a radar. But that won't help me for the impending release of iOS 13.

This behavior is reproducible in a newly created Single View project, with the following trivial viewDidLoad function added to the included view controller.

override func viewDidLoad() {
    super.viewDidLoad()

    let voices = AVSpeechSynthesisVoice.speechVoices()
    print("Voice Count: \(voices.count)")
}

The output is very long:

2019-09-11 10:43:09.370992-0400 SpeechTest[1617:412065] Creating client/daemon connection: C591307C-313E-4B5F-91A8-184B7E662819
2019-09-11 10:43:09.396250-0400 SpeechTest[1617:412065] Got the query meta data reply for: com.apple.MobileAsset.MacinTalkVoiceAssets, response: 0
2019-09-11 10:43:09.397519-0400 SpeechTest[1617:412065] Consumed extension
2019-09-11 10:43:09.401982-0400 SpeechTest[1617:412065] Got the query meta data reply for: com.apple.MobileAsset.MacinTalkVoiceAssets, response: 0
Voice Count: 0
2019-09-11 10:43:09.435890-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.445269-0400 SpeechTest[1617:412066] Consumed extension
2019-09-11 10:43:09.468849-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.499573-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.520244-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.GryphonVoice, response: 0
2019-09-11 10:43:09.545243-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CustomVoice, response: 0
2019-09-11 10:43:09.549941-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CombinedVocalizerVoices, response: 2
2019-09-11 10:43:09.550075-0400 SpeechTest[1617:412066] [AXTTSCommon] Error running custom voice query XML not present
2019-09-11 10:43:09.569114-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.599459-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.630763-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.650161-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.GryphonVoice, response: 0
2019-09-11 10:43:09.666885-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CustomVoice, response: 0
2019-09-11 10:43:09.671279-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CombinedVocalizerVoices, response: 2
2019-09-11 10:43:09.671412-0400 SpeechTest[1617:412066] [AXTTSCommon] Error running custom voice query XML not present
...

It repeats those last 7 lines 39 times, presumably corresponding to the 39 voices it's supposed to know about.

3

There are 3 best solutions below

0
On

This didn't crash my app but caused a memory leak every time AVSpeechSynthesizer was declared. I solved this by declaring the AVSpeechSynthesizer as a global variable

static let synth = AVSpeechSynthesizer()
0
On

I had the same AVSpeechUtterance issue, it appears to have resolved itself over time on my devices. I no longer crash on iOS 13 or 13.1 after some time using the app where it had crashed before, or from a fresh install.

0
On

I had the same issue, what I did to solve it:

  1. Go to Settings > Accessibility > Spoken Content > Voices > English (depends on your app's config).

    • My app use com.apple.ttsbundle.Samantha-compact so I download Samantha and Samantha (Enhanced)
  2. Reboot iPad

Now I can run my app normally.