I am running the code sample here https://developer.apple.com/documentation/avfoundation/speech_synthesis/ in a REPL on Mac OS Ventura
import AVFoundation
// Create an utterance.
let utterance = AVSpeechUtterance(string: "The quick brown fox jumped over the lazy dog.")
// Configure the utterance.
utterance.rate = 0.57
utterance.pitchMultiplier = 0.8
utterance.postUtteranceDelay = 0.2
utterance.volume = 0.8
// Retrieve the British English voice.
let voice = AVSpeechSynthesisVoice(language: "en-GB")
// Assign the voice to the utterance.
utterance.voice = voice
// Create a speech synthesizer.
let synthesizer = AVSpeechSynthesizer()
// Tell the synthesizer to speak the utterance.
synthesizer.speak(utterance)
It runs without errors but I don't hear any sound and the call to
synthesizer.speak
returns immediately. How can I fix this? Note I am running in REPL so synthesizer is not going out of scope and getting garbage collected.