Facing trouble to cancel acoustic echo using speex in Android

4.1k views Asked by At

i am trying to cancel echo but couldn't able to cancel even using a very simple example.Frame size 160 Tile Length 100

audioRecord.read(mic,0,mic.length);
audioData = speex.encode(mic,0,mic.length);
speakerData=speex.decode(audioData);
audioTrack.write(speakerData, 0, speakerData.length);
speex.DoAEC(mic,speakerData,outref);
fos.write(outref);

why above code example didn't cancel echo did i miss anything? When i play the file no echo was removed.

also following simple example didn't work still echo is there.

    short[] buf=new short[160];
audioRecord.read(buf,0,buf.length);
if(sData==null){
sData=buf;
}
short[] outref=new short[160];

speex.cancelecho(buf,sData,outref);
audioTrack.write(outref, 0, outref.length);
sData=buf;
1

There are 1 answers

1
SirKnigget On

You need to understand the requirements for the AEC to work - all documented in the Speex docs - and know how to debug your flow to achieve that.

You can get more pointers from my answer here: Android Speex echo cancellation problems

Also, I have a project that does a loopback sample of Speex AEC - video coverage is here: http://www.youtube.com/watch?v=e1-HwidHMy0

It's a whole project so no point in trying to squeeze it to an answer, but the pointers I gave should give you a start - and the video proves it's possible.