Just downloaded Xcode 15.3 Beta then updated the phone to iOS 17.2
When running the simple example based code with all relevant suggestions eg. used Fred, use an @State to keep AVSpeechSynthesiser in scope.
the app still throws:
When the AVSpeechSynthesizer() instance is created in the @main:
I've appended the relevant code snippet of the test class for reference. Although the detail is irrelevant as the class won't create without the errors.
frankusu: what did you do that's different?
If this is still broken Apple really need to fix this.
I tried to use the CreatingACustomSpeechSynthesizer example app to make a work around but that has install issues.
Any new suggestions gladly received.
Thanks all,
Maz
class VoiceControl: NSObject, ObservableObject {
let synthesizer = AVSpeechSynthesizer() // tried the @State var synthesizer = AVSpeechSynthesizer() approach and that failed too
override init() {
super.init()
//AVSpeechSynthesisVoice.speechVoices() // <-- fetch voice dependencies I tried this and it throws: "Unable to list voice folder" at init
}
func askAQuestion (_ theQuestion: String){
// 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 Fred voice as it's the one that works for some.
if let voice = AVSpeechSynthesisVoice(identifier: "com.apple.speech.synthesis.voice.Fred"){
utterance.voice = voice
self.synthesizer.speak(utterance)
}
else {
print("Fred's not home man.")
}
} ...