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, using audio works as expected. When launched from the device, it never crashes (so far, at least).
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 action closure:
let utterance = AVSpeechUtterance(string: answer)
utterance.voice = AVSpeechSynthesisVoice(language: "en_US") synth.speak(utterance)
Any idea on how to stop this? It's annoying having to launch the app multiple times to test on a simulator or device.