I am using the AVAudioEngine for audio streaming. But when I speak any word into the mic, it repeats multiple times, just like echo effect. I want when I speak, it sounds only one time, not multiple times. I want to cancel the echo or extra noise.
How can I achieve this?
var peerAudioEngine: AVAudioEngine = AVAudioEngine()
var peerAudioPlayer: AVAudioPlayerNode = AVAudioPlayerNode()
var peerInput: AVAudioInputNode?
var peerInputFormat: AVAudioFormat?
func setUpAVPlayer() {
self.peerInput = self.peerAudioEngine.inputNode
self.peerAudioEngine.attach(self.peerAudioPlayer)
self.peerInputFormat = AVAudioFormat.init(commonFormat: .pcmFormatFloat32, sampleRate: 44100, channels: 1, interleaved: false)
self.peerAudioEngine.connect(self.peerAudioPlayer, to: self.peerAudioEngine.mainMixerNode, format: self.peerInputFormat)
print("\(#file) > \(#function) > peerInputFormat = \(self.peerInputFormat.debugDescription)")
}