AVSpeechSynthesizer is broken on iOS 17 in Xcode 15

When you initialize AVSpeechSynthesizer as View prorety in SwiftUI project in Xcode 15 with iOS 17 simulator, you get some comments in console:

Failed to get sandbox extensions
Query for com.apple.MobileAsset.VoiceServicesVocalizerVoice failed: 2
#FactoryInstall Unable to query results, error: 5
Unable to list voice folder
Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2
Unable to list voice folder
Unable to list voice folder
Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2
Unable to list voice folder

When you try to run utterance inside a Button as synthesizer.speak(AVSpeechUtterance(string: "iOS 17 broke TextToSpeech")), you get endless stream of warnings that repeaths on and on in console like this:

AddInstanceForFactory: No factory registered for id <CFUUID 0x60000024f200> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Cannot find executable for CFBundle 0x600003b2cd20 </Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextToSpeechMauiSupport.framework> (not loaded)
Failed to load first party audio unit from TextToSpeechMauiSupport.framework
Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)"
Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)"
Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)"
Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)"
Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)"
Couldn't find audio unit for request SSML Length: 40, Voice: [AVSpeechSynthesisProviderVoice 0x600002127e30] Name: Samantha, Identifier: com.apple.voice.compact.en-US.Samantha, Supported Languages (
    "en-US"
), Age: 0, Gender: 0, Size: 0, Version: (null)
VoiceProvider: Could not start synthesis for request SSML Length: 40, Voice: [AVSpeechSynthesisProviderVoice 0x600002127e30] Name: Samantha, Identifier: com.apple.voice.compact.en-US.Samantha, Supported Languages (
    "en-US"
), Age: 0, Gender: 0, Size: 0, Version: (null), converted from tts request [TTSSpeechRequest 0x600003709680] iOS 17 broke TextToSpeech language: en-US footprint: compact rate: 0.500000 pitch: 1.000000 volume: 1.000000
Failed to speak request with error: Error Domain=TTSErrorDomain Code=-4010 "(null)". Attempting to speak again with fallback identifier: com.apple.voice.compact.en-US.Samantha

CPU is under pressure (more than 100%). AVSpeechSynthesizer doesn't speak. All works fine on iOS 16.

The code of View:

import SwiftUI
import AVFoundation

struct ContentView: View {
    let synthesizer = AVSpeechSynthesizer()
    
    var body: some View {
        VStack {
            Button {
                synthesizer.speak(AVSpeechUtterance(string: "iOS 17 broke TextToSpeech"))
            } label: {
                Text("speak")
            }
            .buttonStyle(.borderedProminent)

        }
        .padding()
    }
}

#Preview {
    ContentView()
}

On the real device nothing at all happened.

The same happens to my production app. I have so much crashes related to TextToSpeach and iOS 17. What's going on?

Check out these related threads:

https://developer.apple.com/forums/thread/730639?answerId=765237022#765237022

https://developer.apple.com/forums/thread/737685

-- Appears every app using AVSpeechSynthesizer has undefined behavior on iOS 17. This is blocking me from pushing an update I've been working on for months.

If you run Scheme on a device with "Adress sanitizer" connected, it crashes when trying to play something through AVSpeechSynthesizer.

AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00013fd04080

Address 0x00013fd04080 is a wild pointer inside of access range of size 0x000000000001. 
SUMMARY: AddressSanitizer: bad-free

And this is even in a completely empty application with only one button, synthesizer and an attempt to speak() something.

Yea. It's a pretty bad situation for us. Doesn't seem like there is anything we can do about...except wait and hope they'll fix it soon.

Well, checking on Xcode Version 15.0 (15A240d), and behavior is like this: I see this in the log: #FactoryInstall Unable to query results, error: 5 Unable to list voice folder Unable to list voice folder Unable to list voice folder Unable to list voice folder Unable to list voice folder Unable to list voice folder Unable to list voice folder Unable to list voice folder Unable to list voice folder Unable to list voice folder

-you have to have patience if you have enabled breakpoints and active debug session, because you need to pass 12 exceptions

-if you are lucky and xcode does not freeze, you will eventually hear the sound.

So the best at the moment is to switch off breakpoints for "Swift Error" (delete it from list of breakpoints)

Not ideal, but it works for now. I filled the bug report.

Faced the same issue and tried changing the voice from samantha to fred and that worked for me. Ref: https://developer.apple.com/forums/thread/735618

That probably is just a band aid. I'm noticing all sorts of strange behavior where speech synthesizer just stops for certain voices and not others, for certain speech strings and not others.

Version 15.0 beta 8 same thing here. On iPhone 13 Pro Max pushed from Testflight is fine.

Similar situation still waiting for fix to publish my app :

Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)" Couldn't find audio unit for request SSML Length: 54, Voice: [AVSpeechSynthesisProviderVoice 0x60000219d810] Name: Anna, Identifier: com.apple.voice.super-compact.de-DE.Anna, Supported Languages ( "de-DE" ), Age: 0, Gender: 0, Size: 0, Version: (null) VoiceProvider: Could not start synthesis for request SSML Length: 54, Voice: [AVSpeechSynthesisProviderVoice 0x60000219d810] Name: Anna, Identifier: com.apple.voice.super-compact.de-DE.Anna, Supported Languages ( "de-DE" ), Age: 0, Gender: 0, Size: 0, Version: (null), converted from tts request [TTSSpeechRequest 0x600003705e00] zugehen language: de-DE footprint: super-compact rate: 0.400000 pitch: 1.000000 volume: 1.000000

Anyone else file a bug and if so did anyone from Apple reply? I think a lot of apps use AVSpeechSynthesizer so hopefully they give the issue priority,. I ended up opening a TSI last week but still haven't heard back yet. My app release is completely jammed up.

We have also been facing this issue for weeks and have yet to find a workaround. Moreover, we are experiencing crashes on real devices running iOS 17 through 17.0.2.

I have created a FB and opened another TSI, but am still awaiting feedback.

Has anyone checked to see if this issue has been resolved in the 17.1 beta?

@dw_dw My TSI got credited back to my account and they said there is "no workaround" and the issue is being investigated.

I was wondering the same thing about 17.1 beta but haven't checked it out myself.

Sidenode for whatever reason e-mail notifications aren't working for me on this thread even though I'm watching it. Have to check back manually periodically to see if anyone is posting here.

I'm developing a React Native application with the usage of React Native TTS package for text to speech functionality. After upgrading to XCode 15 and IOS 17, I've encountered on the issue that produces the same errors as described here. My "Samantha" voice id was unable to speak after the update and I followed some steps here that produced exactly the same outputs in my case (switching to Fred worked but it didn't solve my case because I need female voice). I've used simulators with the IOS 17.0 system.

Today I've upgraded my Iphone SE (2nd generation) to IOS 17.0.2 and I tested it and it was all working as before! So in my case it seems that testing the functionality on XCode 15 simulators with IOS 17.0 was unsuccessful, and I got success when testing it on the real device with the latest IOS system version (17.0.2), which seems to resolvee this issue at least in my case.

So I suggest anyone to try it on a real device with the system version higher than IOS 17.0. Cheers!

I'm on iOS 17.0.3 and still am still seeing all the same issues with AVSpeechSynthesizer.

The reason why certain voices seem to work while others don't is due to the nature of undefined behavior. All sorts of random and bad stuff can happen in unpredictable ways. The issue does not seem to be fixed.

Hello All, I am having very similar errors like the first original post since I updated to XCODE 15 and simulating on iOS 17.x.x. I did NOT have issues related to Text to Speech while I was working on XCODE 14.3.1 and simulating on iOS 16.4 before the update in development and in production.

Here are the errors I am getting from XCODE 15 simulating on iOS 17.x.x. The simulator freezes and I receive below errors:

Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2 Unable to list voice folder Unable to list voice folder Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2 Unable to list voice folder Query for com.apple.MobileAsset.VoiceServicesVocalizerVoice failed: 2 Unable to list voice folder Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2 Unable to list voice folder 1 log/signpost messages lost due to high rates in live mode recording. To guarantee delivery of all logs, set IDELogRedirectionPolicy to oslogToStdio in the environment of the executable. Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2 Unable to list voice folder 1 log/signpost messages lost due to high rates in live mode recording. To guarantee delivery of all logs, set IDELogRedirectionPolicy to oslogToStdio in the environment of the executable. ...

Followed by tens of thousands of these errors:

Couldn't find audio unit for request SSML Length: 17, Voice: [AVSpeechSynthesisProviderVoice 0x600006417520] Name: Tingting, Identifier: com.apple.voice.super-compact.zh-CN.Tingting, Supported Languages ( "zh-CN" ), Age: 0, Gender: 0, Size: 0, Version: (null) VoiceProvider: Could not start synthesis for request SSML Length: 17, Voice: [AVSpeechSynthesisProviderVoice 0x600006417520] Name: Tingting, Identifier: com.apple.voice.super-compact.zh-CN.Tingting, Supported Languages ( "zh-CN" ), Age: 0, Gender: 0, Size: 0, Version: (null), converted from tts request [TTSSpeechRequest 0x600013722040] 能够 language: zh-CN footprint: super-compact rate: 0.500000 pitch: 1.000000 volume: 1.000000 Failed to speak request with error: Error Domain=TTSErrorDomain Code=-4010 "(null)". Attempting to speak again with fallback identifier: com.apple.voice.compact.en-US.Samantha Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)" Couldn't find audio unit for request SSML Length: 19, Voice: [AVSpeechSynthesisProviderVoice 0x60000641fac0] Name: Samantha, Identifier: com.apple.voice.compact.en-US.Samantha, Supported Languages ( "en-US" ), Age: 0, Gender: 0, Size: 0, Version: (null) VoiceProvider: Could not start synthesis for request SSML Length: 19, Voice: [AVSpeechSynthesisProviderVoice 0x60000641fac0] Name: Samantha, Identifier: com.apple.voice.compact.en-US.Samantha, Supported Languages ( "en-US" ), Age: 0, Gender: 0, Size: 0, Version: (null), converted from tts request [TTSSpeechRequest 0x600013730000] able language: en-US footprint: compact rate: 0.500000 pitch: 1.000000 volume: 1.000000 Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)" ... Couldn't find audio unit for request SSML Length: 17, Voice: [AVSpeechSynthesisProviderVoice 0x6000064219f0] Name: Tingting, Identifier: com.apple.voice.super-compact.zh-CN.Tingting, Supported Languages ( "zh-CN" ), Age: 0, Gender: 0, Size: 0, Version: (null) VoiceProvider: Could not start synthesis for request SSML Length: 17, Voice: [AVSpeechSynthesisProviderVoice 0x6000064219f0] Name: Tingting, Identifier: com.apple.voice.super-compact.zh-CN.Tingting, Supported Languages ( "zh-CN" ... ... 1 log/signpost messages lost due to high rates in live mode recording. To guarantee delivery of all logs, set IDELogRedirectionPolicy to oslogToStdio in the environment of the executable. Failed to speak request with error: Error Domain=TTSErrorDomain Code=-4010 "(null)". Attempting to speak again with fallback identifier: com.apple.voice.compact.zh-CN.Tingting Could not instantiate audio unit. Error=Error Domain=NSOSStatusErrorDomain Code=-3000 "(null)" Couldn't find audio unit for request SSML Length: 19, Voice: [AVSpeechSynthesisProviderVoice 0x60000641ec60] Name: Samantha, Identifier: com.apple.voice.compact.en-US.Samantha, Supported Languages ( "en-US" ), Age: 0, Gender: 0, Size: 0, Version: (null)

So I moved back to XCODE 14.3.1 simulating on iOS 16.4. The app works fine but I receive these messages:

… [AXTTSCommon] MauiVocalizer: 11006 (Can't compile rule): regularExpression=Ne-\Yo, message=unrecognized character follows , characterPosition=4 … [AXTTSCommon] MauiVocalizer: 16038 (Resource load failed): component=ttt/re, uri=rlst/yosemite/set/mnc, contentType=application/x-vocalizer-rettt+text;loader=broker, lhError=88602000 … [catalog] Query for com.apple.MobileAsset.VoiceServices.VoiceResources failed: 2 … [catalog] Query for com.apple.MobileAsset.VoiceServices.VoiceResources failed: 2 … changing items while animating can result in a corrupted navigation bar … … [AXTTSCommon] MauiVocalizer: 11006 (Can't compile rule): regularExpression=Ne-\Yo, message=unrecognized character follows , characterPosition=4 … [AXTTSCommon] MauiVocalizer: 16038 (Resource load failed): component=ttt/re, uri=rlst/yosemite/set/mnc, contentType=application/x-vocalizer-rettt+text;loader=broker, lhError=88602000 …
… [AXTTSCommon] MauiVocalizer: 11006 (Can't compile rule): regularExpression=Ne-\Yo, message=unrecognized character follows , characterPosition=4 … [AXTTSCommon] MauiVocalizer: 16038 (Resource load failed): component=ttt/re, uri=rlst/yosemite/set/mnc, contentType=application/x-vocalizer-rettt+text;loader=broker, lhError=88602000 … [catalog] Query for com.apple.MobileAsset.VoiceServices.VoiceResources failed: 2 … … [AXTTSCommon] MauiVocalizer: 11006 (Can't compile rule): regularExpression=Ne-\Yo, message=unrecognized character follows , characterPosition=4 … [AXTTSCommon] MauiVocalizer: 16038 (Resource load failed): component=ttt/re, uri=rlst/yosemite/set/mnc, contentType=application/x-vocalizer-rettt+text;loader=broker, lhError=88602000

Now the app store production version freezes in any device running 17.x.x and not usable anymore. I opened a case with Apple development team but I have not received a reply yet. The zh-CN.Tingting, and en-US.Samantha keep repeating over 350,000 times each in the errors.

It also seems that I am receiving: … [catalog] Query for com.apple.MobileAsset.VoiceServices.VoiceResources failed: 2 Without affecting the app in XCODE 14.x.

And a similar error: Query for com.apple.MobileAsset.VoiceServicesVocalizerVoice failed: 2 Unable to list voice folder Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2 Unable to list voice folder In XCODE 15.

Any help will be highly appreciated to find a quick work around or a fix. Thanks

Nothing in the iOS 17.1 Beta 2 Release Notes regarding AVFoundation. Anyone try the Beta?

I wrote this code to test the 158 available voices on XCODE15 and iOS17, so far the 10 I tested are crashing the app. Fred en-US is working. Can we get more hands to test the whole list and provide the working voices?

https://gist.github.com/Koze/d1de49c24fc28375a9e314c72f7fdae4

Thanks.

import SwiftUI import AVFoundation

// Define a struct to hold voice information struct VoiceInfo: Comparable { var name: String var language: String var identifier: String

static func < (lhs: VoiceInfo, rhs: VoiceInfo) -> Bool {
    if lhs.language == rhs.language {
        return lhs.name < rhs.name
    }
    return lhs.language < rhs.language
}

}

struct ContentView: View { @State private var selectedVoice = 0 @State private var textToSpeak = "Hello, World!" let synthesizer = AVSpeechSynthesizer()

// Create and sort the array of voice information
let voices: [VoiceInfo] = [
    VoiceInfo(name: "Majed", language: "ar-001", identifier: "com.apple.voice.compact.ar-001.Maged"),
    ...
].sorted()

var body: some View {
    VStack {
        Picker("Select a Voice", selection: $selectedVoice) {
            ForEach(0 ..< voices.count, id: \.self) { index in
                Text("\(voices[index].name) (\(voices[index].language))")
                    .tag(index)
            }
        }
        .pickerStyle(WheelPickerStyle())
        .padding()
        
        TextField("Enter text to speak", text: $textToSpeak)
            .textFieldStyle(RoundedBorderTextFieldStyle())
            .padding()
        
        Button("Speak") {
            speakText()
        }
        .padding()
    }
}

func speakText() {
    let utterance = AVSpeechUtterance(string: textToSpeak)
    utterance.voice = AVSpeechSynthesisVoice(identifier: voices[selectedVoice].identifier)
    synthesizer.speak(utterance)
}

}

struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }

#Preview { ContentView() }

Certain voices just stop at random points on speech strings in my app testing. Also the -willSpeakRange: delegate callback sometimes jumps all over the place.

Doesn't seem to be any rhyme or reason to it.

Does not appear to be fixed in the simulator.

Address sanitizer crash as soon as you call -speakUtterance: still occurs on iOS 17.1. Kind of surprising that this seems like it is being treated as a low priority issue. I'm pretty sure WebKit uses AVSpeechSynthesizer to implement the Web Speech API so even beyond use in native apps every WKWebView and maybe even Safari could be impacted?

It would be great if there was a little more communication from Apple on this to let devs know if a fix for this issue is coming anytime soon (and by soon I mean not in iOS 18) or if we should investigate other ways to implement this functionality.

That text to speech feature will be the most important part of my app. So it would be really really nice to be fixed soon.

Same issue here with german and english voices.

Does anyone have an update on this issue? Neither the iOS 17.2 beta 2 nor the Xcode 15.1 Beta 2 release notes mention it

@s43 that works, thx!! Still weird that it happens tho, we are almost at midlife of iOS 17, it should have been fixed by now...

And to be clear, this is not just a simulator issue? " ... nothing at all happened ... " on real device means no problems on the device (so it works)? Or no sound on the device (it's broken there too)?

Other devs / other posts report that voices that don't work seem to also have their .audioFileSettings property like this [ : ] ... empty!

I ran

 func testVoices() {
        let voiceList = AVSpeechSynthesisVoice.speechVoices()
        for voice in voiceList {
            print(voice.name + ": \(voice.audioFileSettings)")
        }
   }

Output shows a handful of voices (including Fred) have data in their .audioFileSettings property ( and unfortunately most have [ : ] )
Voices that have settings seem to work in the simulator - although it's spotty on an actual iOS 17 device. Fred, for example, works only 1/30 of the time when tested on my iPhone but is fine in the simulator.

~~ My Voice Settings Output~~ Majed: [:] Daria: [:] Montse: [:] Zuzana: [:] Sara: [:] Anna: [:] Melina: [:] Karen: [:] Daniel: [:] Moira: [:] Rishi: [:]

Trinoids: ["AVFormatIDKey": 1819304813, "AVLinearPCMIsBigEndianKey": 0, "AVSampleRateKey": 22050, "AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsFloatKey": 1, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsNonInterleaved": 1]

Albert: ["AVLinearPCMBitDepthKey": 32, "AVSampleRateKey": 22050, "AVLinearPCMIsBigEndianKey": 0, "AVFormatIDKey": 1819304813, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsNonInterleaved": 1]

ester: ["AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVNumberOfChannelsKey": 1, "AVFormatIDKey": 1819304813, "AVLinearPCMIsBigEndianKey": 0, "AVSampleRateKey": 22050, "AVLinearPCMBitDepthKey": 32]

Samantha: [:]

Whisper: ["AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVNumberOfChannelsKey": 1, "AVFormatIDKey": 1819304813, "AVLinearPCMIsBigEndianKey": 0, "AVSampleRateKey": 22050, "AVLinearPCMBitDepthKey": 32]

Superstar: ["AVNumberOfChannelsKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVLinearPCMIsFloatKey": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813, "AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsBigEndianKey": 0]

Bells: ["AVLinearPCMBitDepthKey": 32, "AVNumberOfChannelsKey": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813, "AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMIsNonInterleaved": 1, "AVLinearPCMIsFloatKey": 1]

Organ: ["AVLinearPCMBitDepthKey": 32, "AVNumberOfChannelsKey": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813, "AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMIsNonInterleaved": 1, "AVLinearPCMIsFloatKey": 1]

Bad News: ["AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVNumberOfChannelsKey": 1, "AVFormatIDKey": 1819304813, "AVLinearPCMIsBigEndianKey": 0, "AVSampleRateKey": 22050, "AVLinearPCMBitDepthKey": 32]

Bubbles: ["AVFormatIDKey": 1819304813, "AVLinearPCMIsNonInterleaved": 1, "AVLinearPCMBitDepthKey": 32, "AVSampleRateKey": 22050, "AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsBigEndianKey": 0, "AVNumberOfChannelsKey": 1]

Junior: ["AVLinearPCMBitDepthKey": 32, "AVFormatIDKey": 1819304813, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVSampleRateKey": 22050]

Bahh: ["AVLinearPCMBitDepthKey": 32, "AVFormatIDKey": 1819304813, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVSampleRateKey": 22050]

Wobble: ["AVLinearPCMBitDepthKey": 32, "AVFormatIDKey": 1819304813, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMIsFloatKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVSampleRateKey": 22050]

Boing: ["AVNumberOfChannelsKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVLinearPCMBitDepthKey": 32, "AVSampleRateKey": 22050, "AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMIsFloatKey": 1, "AVFormatIDKey": 1819304813]

Good News: ["AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsFloatKey": 1, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813]

Zarvox: ["AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsFloatKey": 1, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813]

Ralph: ["AVLinearPCMIsBigEndianKey": 0, "AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsFloatKey": 1, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsNonInterleaved": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813]

Cellos: ["AVLinearPCMIsBigEndianKey": 0, "AVFormatIDKey": 1819304813, "AVLinearPCMIsNonInterleaved": 1, "AVSampleRateKey": 22050, "AVNumberOfChannelsKey": 1, "AVLinearPCMIsFloatKey": 1, "AVLinearPCMBitDepthKey": 32]

Kathy: ["AVNumberOfChannelsKey": 1, "AVLinearPCMIsFloatKey": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813, "AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsNonInterleaved": 1, "AVLinearPCMIsBigEndianKey": 0]

Fred: ["AVNumberOfChannelsKey": 1, "AVLinearPCMIsFloatKey": 1, "AVSampleRateKey": 22050, "AVFormatIDKey": 1819304813, "AVLinearPCMBitDepthKey": 32, "AVLinearPCMIsNonInterleaved": 1, "AVLinearPCMIsBigEndianKey": 0]

Tessa: [:] Mónica: [:] Paulina: [:] Satu: [:] Amélie: [:] Thomas: [:] Carmit: [:] Lekha: [:] Lana: [:] Tünde: [:] Damayanti: [:] Alice: [:] Kyoko: [:] Yuna: [:] Amira: [:] Nora: [:] Ellen: [:] Xander: [:] Zosia: [:] Luciana: [:] Joana: [:] Ioana: [:] Milena: [:] Laura: [:] Alva: [:] Kanya: [:] Yelda: [:] Lesya: [:] Linh: [:] Tingting: [:] Sinji: [:] Meijia: [:]

OK. After some experimenting I have a solution. This works consistently on both the simulator and my iOS 17 iPhone.

Manually downloaded voices simply work.

Settings > Accessibility > Live Speech (English US) on both the sim and my iphone. I downloaded Alex, Ava (Premium), Evan(Enhanced)

Then used this block to obtain the exact identifier for the voice:

        let englishVoices = AVSpeechSynthesisVoice.speechVoices().filter { $0.language.starts(with: "en") }
        for voice in englishVoices {
            let quality = voice.quality == .enhanced ? "Enhanced" : "Default"
            print("\(voice.identifier): \(quality)")
        }

TTS as usual:

func speak(text: String) {
        let utterance = AVSpeechUtterance(string: text)
        
        if let voice = AVSpeechSynthesisVoice(identifier: "com.apple.voice.enhanced.en-US.Evan") {
            utterance.voice = voice
        }

        // Other configs
        utterance.rate = AVSpeechUtteranceDefaultSpeechRate
        utterance.pitchMultiplier = 1.0
        utterance.volume = 1.0

        speechSynthesizer.speak(utterance)
    }

It works for Alex, Evan, and Ava which are all that I've tested so far. I'm planning on popping up an alert in my app for the user to download one of these (or another once I test) if they initiate TTS and don't already have one of these voices available. No, it's not ideal to do that but it's a functional workaround in the meantime. Otherwise I can fall back on one of the very terrible old voices (Trinoids, anyone?) that are working by default as listed in my reply above.

Also, I was incorrect about Fred and similar voices that have data in their .audioFileSettings dictionary not working on my device. I was, in fact, failing to release the audio context after speech recognition. My app uses both STT and TTS, although STT doesn't work reliably in the sim (this is a known issue) so I wasn't initiating it there. On my test iPhone, failing to return the AVAudioSession to category .ambient or .playback after SST caused the issue. Fred, Tessa, Kathy, Ralph, Zarvox etc. all work on both the simulator and my test iPhone now. Of course a) no one want's to use those voices; and b) The rest definitely don't work.

I tried setting values in the .audioFileSettings dictionary for other voices like Sara, Ellen etc. thinking that I might have some success. But of course, that property is read-only.

I think at this point I'm comfortable concluding that the issue is those empty .audioFileSettings dictionaries that are properties of each voice in the bundled iOS 17 SDK. Specifically, it is this class: https://developer.apple.com/documentation/avfaudio/avspeechsynthesisvoice that's the problem

New, user downloaded voices will have the necessary data in their audioFileSettings dictionaries, as do very old (and somewhat useless Apple voices bundled in the SDK)

This should be an easy, quick fix for an AV Framework engineer at Apple.

AVSpeechSynthesizer is broken on iOS 17 in Xcode 15
 
 
Q