AVSpeechSynthesizer - just not working on 15.1.1

So get a swift file and put this in it

import Foundation
import AVFoundation

let synthesizer = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: "Hello, testing speech synthesis on macOS.")
if let voice = AVSpeechSynthesisVoice(identifier: "com.apple.voice.compact.en-GB.Daniel") {
    utterance.voice = voice
    print("Using voice: \(voice.name), \(voice.language)")
} else {
    print("Daniel voice not found on macOS.")
}
synthesizer.speak(utterance)

I get no speech output and this log output

Error reading languages in for local resources.
Error reading languages in for local resources.
Using voice: Daniel, en-GB
Program ended with exit code: 0

Why? and whats with "Error reading languages in for local resources." ?

Hello @willwade, thank you for your post. Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. I'd greatly appreciate it if you could open a bug report, include a sysdiagnose, and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

I am having the same problem as Will. I have expanded his code as follows:

        print("after let synthesizer")
        let utterance = AVSpeechUtterance(string: "Hello, testing speech synthesis on macOS.")
        print("after let utterance")
        if let voice = AVSpeechSynthesisVoice(identifier: "com.apple.voice.compact.en-GB.Daniel") {
            print("after let voice")
            utterance.voice = voice
            print("Using voice: \(voice.name), \(voice.language)")
        } else {
            print("Daniel voice not found on macOS.")
        }
        print("before synthesizer.speak")
        synthesizer.speak(utterance)
        print("after synthesizer.speak")

The error message "Error reading languages in for local resources" appears at the if let voice… call. Also at synthesizer.speak(utterance) there are three of these: _-[AFPreferences languageCodeWithFallback:] No language code saved, but Assistant is enabled - returning: en-GB

I am also getting: #FactoryInstall Unable to query results, error: 5

This is just MacOS (15.3ß), using Xcode 16.2 - I am not getting any of this for the identical code running in my iOS app.

just not working on macOS 15.2

AVSpeechSynthesizer - just not working on 15.1.1
 
 
Q