Hi all,
I am using AVSpeechSynthesizer for Text-To-Speak functionality. If headphones connected to device, the AVSpeechSynthesizer should speak in particular channel ie Headphone Left (MONO 2). I tried the below code to achieve this functionality. It works but It suports from iOS 10.0.
func initalizeSpeechForRightChannel(){
let avSession = AVAudioSession.sharedInstance()
let route = avSession.currentRoute
let outputPorts = route.outputs
var leftChannels:[AVAudioSessionChannelDescription] = []
for outputPort in outputPorts {
for channel in outputPort.channels! {
if channel.channelName == "Headphones Left" {
leftChannels.append(channel)
}
}
}
if channels.count > 0 {
if #available(iOS 10.0, *) {
print("Setting Left Channel")
speechSynthesizer.outputChannels = leftChannels /
print("Checking output channel : \(speechSynthesizer.outputChannels?.count)")
}
}
}
Is there any option to do this functionality for iOS 8.2?
Or is there any other option to achieve this functionality (playing the speech only on Left or Right HeadPhone)?