My app uses the AVFoundation to pronounce some words. Running the app from Xcode, either to a simulator or device, I frequently get this crash at start-up
AXSpeech (13): EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
It seems to occur randomly, maybe 20%-30% of the time I launch the app. When it does not crash, audio works as expected. When launched from a device, it never crashes (at least, so far).
Here's the code that outputs speech:
Declared at the top level of the View struct
@State var synth = AVSpeechSynthesizer()
In the View, as part of a Button's closure:
let utterance = AVSpeechUtterance(string: answer)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US") synth.speak(utterance)
Any idea on how to stop this? It doesn't stop development, but sure slows it down, requiring multiple app starts often.