Swift version:
do {
try AVAudioSession.sharedInstance().setActive(true)
} catch let error {
print("\(error.localizedDescription)")
}
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .spokenAudio)
} catch let error {
print("\(error.localizedDescription)")
}