SwiftUI AVFoundation doesn't work

Why doesn't it work?? There're no errors. My speaker is turned on and not muted I have tried to run the code below on the simulator ( iPhone 13 Pro ( iOS 16.4 & iOS 17.0)) Xcode V14.3.1

//  ContentView.swift
//  HelloWorld
//
//  Created by JerryNL on 2023/8/12.
//

import SwiftUI
import AVFoundation

struct ContentView: View {
    var body: some View {
        VStack {
            Button {

                let utterance = AVSpeechUtterance(string: "what")
                utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
                let synthesizer = AVSpeechSynthesizer()
                synthesizer.speak(utterance)

            } label: {
                Text("Hello World")
                    .fontWeight(.bold)
                    .font(.system(.title, design: .rounded))
            }
            .padding()
            .foregroundColor(.white)
            .background(Color.purple)
            .cornerRadius(20)

        }
        .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
SwiftUI AVFoundation doesn't work
 
 
Q