Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About echo cancellation #103

Open
TurboTu opened this issue Apr 24, 2023 · 12 comments
Open

About echo cancellation #103

TurboTu opened this issue Apr 24, 2023 · 12 comments

Comments

@TurboTu
Copy link

TurboTu commented Apr 24, 2023

When two device output via speakphone and there will be much echo. Is there any method to add echo cancellation process?

@TurboTu
Copy link
Author

TurboTu commented Apr 24, 2023

I found webrtc has aec module, is there any hint about how to integrate it into the code

@mwarning
Copy link
Member

I have some local code to enable AEC, but it is not tested yet.

@TurboTu
Copy link
Author

TurboTu commented Apr 24, 2023

I can do some test, can u share the code, or some tips how to ? I have tried use android.media.AudioTrack(not webrtc AudioTrack) and Speex to cancel the echo, and it worked. But I have no idea how to add the code into this project.

@TurboTu
Copy link
Author

TurboTu commented Apr 24, 2023

In my code, I should set sample rate at 8k and single track, enable aec, and use Speex at audio encoder and decoder, but webrtc has no entry. And in this project, I also tried disable the hardware echo cancellation and other code like below:
WebRtcAudioUtils.setDefaultSampleRateHz(8000)
WebRtcAudioUtils.setWebRtcBasedNoiseSuppressor(true)
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true)
WebRtcAudioUtils.setWebRtcBasedAutomaticGainControl(true)
var audioDeviceModule = JavaAudioDeviceModule.builder(App.getInstance())
.setUseHardwareAcousticEchoCanceler(false)
.setUseHardwareNoiseSuppressor(false)
.setSampleRate(8000)
.createAudioDeviceModule()
var initializationOptions = PeerConnectionFactory.InitializationOptions.builder(App.getInstance())
.createInitializationOptions()
PeerConnectionFactory.initialize(initializationOptions)
factory = PeerConnectionFactory.builder()
.setAudioDeviceModule(audioDeviceModule)
.setVideoEncoderFactory(encoderFactory)
.setVideoDecoderFactory(decoderFactory)
.createPeerConnectionFactory()

but all failed

@mwarning
Copy link
Member

@TurboTu
Copy link
Author

TurboTu commented Apr 25, 2023

I have seen this code, dump the stream into a tmp file(like the aecDump method), and do aec ops? Am i right?

@mwarning
Copy link
Member

Yes. But I would leave out the recording stuff.

@TurboTu
Copy link
Author

TurboTu commented Apr 25, 2023

Any detailed information? I don't understand? I searched over the internet, not too much talked about aec based on webrtc.

@mwarning
Copy link
Member

The line with setSamplesReadyCallback seems to be for recording audio. Let's leave out that line out if you plan to make a merge request.

@TurboTu
Copy link
Author

TurboTu commented Apr 26, 2023

I'll have a try, thanks

@mwarning
Copy link
Member

Did you get echo cancellation to work?

@mwarning
Copy link
Member

I have added the JavaAudioDevice code. But it does not seem to work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants