AVSpeechSynthesizer iOS 15/16 lagging for seconds when switching to (different) German language voice

Whenever switching the AVSpeechSynthesizer voice to a (different) German voice the app waits/hangs for a few seconds (depending on device) before speech output starts.

Looking into the console output I see that the German language rules data is five to nine times large than e.g. English or Italian:

10:55:16.137820+0200	...	#MobileAsset listing ...'[Available: true, Language: de-DE]'
...
10:55:07.636488+0200	...	Loading on disk rule data: 4392529
10:55:10.818661+0200	...	processing rules: 459, NS: 28669
10:55:10.840711+0200	...	Creating playback session rate: 22050, channels 1

showing the loading on disk rules took about 3.2 secs in this German voice case.

If I look into loading of an English or Italian voice those load times are much shorter:

10:55:16.137820+0200	...	#MobileAsset listing ...'[Available: true, Language: en-US]'
...
10:55:16.148741+0200	...	Loading on disk rule data: 862210
10:55:16.407063+0200	...	processing rules: 12192, NS: 1611
10:55:16.428606+0200	...	Creating playback session rate: 22050, channels 1
10:55:16.137820+0200	...	#MobileAsset listing ...'[Available: true, Language: it-IT]'
...
10:54:50.816431+0200	...	Loading on disk rule data: 536565
10:54:51.493129+0200	...	processing rules: 2567, NS: 4149
10:54:51.514703+0200	...	Creating playback session rate: 22050, channels 1

showing load times of 0.25 and 0.7 secs, only!

Interestingly, if I do a small test app which has exactly the same setup and usage of AVSpeechSynthesizer as in my main app, I can NOT reproduce those lengthy load times, respectively lags/waits until speech output starts following a voice change to a (different) German voice.

This is my code for calling AVSpeechSynthesizer.speak(_):

    func speak(_ textToSpeak: String) {

        appState.isPrePause = true
                
        // Detect language of incoming text to speak.

        var lang = ""
        if let dominantLanguage = NLLanguageRecognizer.dominantLanguage(for: textToSpeak) {
            lang = dominantLanguage.rawValue
        } else {
            lang = "en"
        }
        
        // Select a voice based on the detected lanuage.

        let voice = AVSpeechSynthesisVoice(language: lang)
        if voice == nil {
            print("WARNING: no voice for the current language \(lang). Falling back to default voice.")
        }
        
        let utterance = AVSpeechUtterance(string: textToSpeak)

        utterance.voice = voice
        utterance.preUtteranceDelay = appState.preUtteranceDelay
        utterance.postUtteranceDelay = appState.postUtteranceDelay

        avSpeechSynth.speak(utterance)
    }

The described lag is happening between calling avSpeechSynth.speak(utterance) and the Synthesizer Delegate callback "didStart".

I have files a feedback report to Apple (FB11380447) about three weeks ago with regular updates afterwards.

Has anybody experienced something like this? Any suggestions on where to dig further?

Hello @khm2. I was just researching on why german seems to be slower and just found your post here. I do have the exact same problem as you describe. English seems to have no noticeable delay at all and german does have a very noticeable delay before I can hear the TTS. Did you find a solution to the problem yet? I also made sure I downloaded all languages for german, with no change in the delay.

Also... how do you get the logs you are posting? I can't see those in my console?!?

Cheers, Georg

Hi @georgbachmann,

I have not found a solution, yet.

Apple has been requesting additional infos two weeks ago (sysdiagnose file with with a Siri logging profile installed). No further comms from Apple so far. It would be really(!) helpful if you could file a Feedback regarding your (same) issue referencing my Feedback ID (FB11380447). Thanks!

Regarding the logs: I connected the device to the Mac running Xcode and then selected the device in Console.

I suggest we keep each other updated on the issue here in this forum. Best, Klaus.

@khm2 filed a bug-report (FB11716182) Thx for your reply and I'll keep you posted

I have the same problem. And something else interesting...

German only seems to load slowly when you set a delegate:

Set just German -- fastSet just a delegate -- fastSet German and a delegate -- slow

I have the same problem. And something else interesting... German only seems to load slowly when you set a delegate:

Set just German -- fast

Set just a delegate -- fast

Set German and a delegate -- slow —  openingapps less than a minute ago 

We have the same problem. As we develop an app (with Flutter) for German users that can not read, it is critical to us. The older German sound packages are working fast, but sound very bad. Any other language package that we tried (en, it, fr) works fine / fast.

3 seconds delay:

  • {locale: de-DE, name: Anna}
  • {locale: de-DE, name: Martin}
  • {locale: de-DE, name: Helena}

fast (but old):

  • {locale: de-DE, name: Sandy}
  • {locale: de-DE, name: Shelley}
  • {locale: de-DE, name: Grandma}
  • {locale: de-DE, name: Grandpa}
  • {locale: de-DE, name: Eddy}
  • {locale: de-DE, name: Reed}
  • {locale: de-DE, name: Rocko}
  • {locale: de-DE, name: Flo}

This issue is still relevant. I found that when using expo-speech package for react native German voices perform fine. Has anyone found a solution to this?

Today I have been testing something unrelated in my SpeechApp on the iOS 16.4 Simulator with Xcode 14.2 (and later 14.3) and to my surprise, the change of German languages from one utterance to the next worked as fast as it should be, no more 3+ secs delay! Cool, has Apple finally solved the bug?! I moved to a device. But no: on device with iOS 16.4.1 installed, the same issue as always, the delays between utterances with different German voices are back. Reinstalled the app on the device, re-downloaded the German voices used. But no luck.

This is the console output of the app running on device. The delay happens after the first "[AXTTSCommon] Invalid rule:" appears in the console.

Speech Synthesizer - Current utterance voice: Optional("Viktor (Enhanced)") | language: Optional("de-DE")
2023-04-09 13:04:06.172618+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule:           <----- DELAY HAPPENS AFTER THIS LINE
2023-04-09 13:04:10.052499+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule:
2023-04-09 13:04:10.053138+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule:
2023-04-09 13:04:10.055567+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule:
2023-04-09 13:04:10.113567+0200 SpeechApp[914:31164] [audio] 

--- SpeechSynthesizer Delegate - did START speaking utterance.

The console output of the Simulator. It shows only one line with "[AXTTSCommon] Invalid rule:" and moves over it quickly, without any delay:

Speech Synthesizer - Current utterance voice: Optional("Viktor (Enhanced)") | language: Optional("de-DE")
2023-04-09 13:01:59.764986+0200 SpeechApp[7145:111421] [AXTTSCommon] Invalid rule:
2023-04-09 13:01:59.778640+0200 SpeechApp[7145:108690] [audio] 

--- SpeechSynthesizer Delegate - did START speaking utterance.

Can anybody confirm that German voices work correctly on Simulator while switching german voices between utterances, while still showing unacceptable delays between utterances on device?

AVSpeechSynthesizer iOS 15/16 lagging for seconds when switching to (different) German language voice
 
 
Q