我正在使用 AVAudioEngine 进行音频流传输。但是当我对着麦克风说任何单词时,它会重复多次,就像回声效果一样。我想当我说话的时候,声音只有一次,而不是多次。我想消除回声或额外的噪音。
我怎样才能做到这一点?
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)")
}