I am using AVSpeechSynthesizer for TextToSpeech. I need to play in the left channel HeadPhone Channel (Mono 2). I have the following to set the output channel.
func initalizeSpeechForRightChannel(){ let avSession = AVAudioSession.sharedInstance() let route = avSession.currentRoute let outputPorts = route.outputs var channels:[AVAudioSessionChannelDescription] = [] //NSMutableArray *channels = [NSMutableArray array]; var leftAudioChannel:AVAudioSessionChannelDescription? = nil var leftAudioPortDesc:AVAudioSessionPortDescription? = nil for outputPort in outputPorts { for channel in outputPort.channels! { leftAudioPortDesc = outputPort //print("Name: \(channel.channelName)") if channel.channelName == "Headphones Left" { channels.append(channel) leftAudioChannel = channel }else { // leftAudioPortDesc?.channels?.removeObject(channel) } } } if channels.count > 0 { if
I have 2 problems in code
1. It is impossible to set the output channels, always nil (this happens when you first call this method, consecutive calls work fine)
2. Support for output channels from iOS 10. * But I need to support it with iOS 8.0
Please provide the best way to do this.
source share