利用Speex进行回声消除,需要先利用SpeexEchoState* speex_echo_state_init(int frame_size, int filter_length)函数来初始化,那么frame_size和filter_length具体是什么含义,有什么作用呢?
首先看speex_echo_state_init的官方文档:
/*
SpeexEchoState* speex_echo_state_init(int frame_size, int filter_length)
Creates a new echo canceller state
Parameters:
frame_size Number of samples to process at one time
(should correspond to 10-20 ms)
filter_length Number of samples of echo to cancel
(should generally correspond to 100-500 ms)
Returns:
Newly-created echo canceller state
*/
从以上可以看出,frame_size一次处理的采样点个数,单位是samples,推荐是10-20ms,filter_length是回声消除滤波器的长度,单位是samples,推荐是100-500ms.
speex_echo_state_init
可以看出,frame_size最好是2的整次幂,这样便于FFT变换。
frame_size对收敛速度的影响

可以看出适度的增加frame_size可有效地减少收敛时间,即提高收敛速度。并发现对回声消除的效果没有影响,都能起到良好的消除效果。
将一个48k的样本,重采样为8k,16k,32k,再次进行测试。

可见,保持frame_size不变,减少采样率(重采样)可减少收敛时间。

可见,frame_size越大,收敛速度越快。可以理解为,frame_size越大,一次处理的数据越多,导致处理速度加快。
filter_length对回声消除的影响
When it comes to echo tail length (filter length), longer is not better. Actually, the longer the tail length,
the longer it takes for the filter to adapt.
Of course, a tail length that is too short will not cancel enough echo,
but the most common problem seen is that people set a very long tail length and then wonder why no echo is being cancelled.


可见,
- filter_length低于一定值,将无法实现回声消除。
- 采样率的变化,对是否可实现回声消除影响不大。
