I'm trying to use AV Speech Synthesizer on an ARKit app (I've never used it before), but I keep getting the same error message "Unable to list voice folder."
I saw the same question being asked before, and all the answers mentioned ios 16 being the difference, so they suggested moving the synthesizer declaration line outside the function or moving it directly under where I import AVFoundation.
let synthesizer = AVSpeechSynthesizer()
However, I still get the same error message no matter where I put this line. I'm pretty new to Swift and app development, so I suspect there's another problem, but the relevant code roughly looks like this:
import AVFoundation
let synthesizer = AVSpeechSynthesizer()
//within the view controller class:
func testSpeak() {
let utterance = AVSpeechUtterance(string: "screen has been tapped")
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
synthesizer.speak(utterance)
}
Are there any alternatives to using AVSpeechSynthesizer if I can't get it to work? I just need something that can read a few strings aloud to users.