Playing Sounds

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.

Hello, please take a few minutes and paste this issue into a bug report so we can confirm this is tracked in our internal system. Doing this will help us get vital information about the issue like logs from your device. And of course please provide code samples including the one you posted here! You can file a report here: https://developer.apple.com/bug-reporting/

Once you do, feel free to reply with the Feedback ID number and I can make sure the right people are aware of this issue

Playing Sounds
 
 
Q