Hello,
I’ve been trying to play system sounds in my app, but this hasn’t really been working. I am frequently switching between speech recognition (Speech framework) and sounds, so perhaps that’s where the issue lies. However, despite my best efforts, I haven't been able to solve the issue. I've been resetting the AVAudioSession category before playing a sound or starting speech recognition (as depicted in the code snippet below), to no avail. Has this happened to anyone else? Does anybody know how to fix the issue?
recognizer = nil
try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [])
try? AVAudioSession.sharedInstance().setActive(true)
AudioServicesPlaySystemSound(1113)
try? AVAudioSession.sharedInstance().setCategory(.record, mode: .spokenAudio, options: [])
try? AVAudioSession.sharedInstance().setActive(true)
recognizer = SpeechRecognition(word: wordSheet)
recognizer!.startRecognition()
Thank you.