如何用AVAudioEngine取消或删除回声/重复声音?

问题描述:

我正在使用AVAudioEngine进行音频流式传输。但是,当我对麦克风说出任何词语时,它会重复多次,就像回声效果一样。我想说话时,听起来只有一次,而不是多次。我想取消回声或额外的噪音。如何用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)") 
} 
+0

请给我们介绍一下你有什么迄今所做的一些代码。 –

+0

@ParasGorasiya请检查我的代码 –

+0

您是否在创建回声的环境中录制了某些内容? –

我想你应该能够通过这个代码

var reverbNode = AVAudioUnitReverb() 
reverbNode.loadFactoryPreset(AVAudioUnitReverbPreset.Cathedral) 
reverbNode.wetDryMix = 60 
// Attach the audio effect node corresponding to the user selected effect 
peerAudioEngine.attachNode(reverbNode) 

你也可能要考虑其他办法,你说之后就可以听不到您的麦克风和,你必须解决您的问题当您的peerAudioEngine没有收到任何您将其静音的输入音频时手动检测。

这将完全消除您的语音回声。

欲了解更多信息,您可以访问 http://asciiwwdc.com/2014/sessions/502

+0

不工作,回声不取消:( –

+0

你有任何其他的解决方案? –