speexdsp-aec
ctypes 封装 libspeexdsp (Xiph) 的流式声学回声消除 (AEC) — 零编译纯 Python 轮子 (py3-none-any)。
为什么不用现成的 pip 包
| 包 | 状态 |
|---|---|
speexdsp (PyPI) |
2018 年后失修, 仅 sdist, 构建需要 swig + 系统头文件 |
webrtc-audio-processing (PyPI) |
2016 年后失修, 仅 cp36/armv7l |
pyaec (PyPI, 预编译 wheel) |
底层是 speexdsp 的 Rust 移植 (aec-rs), 实测纯回声 ERLE 仅 ~13dB 且双讲损伤语音 (相关度 0.84→0.65) |
而真 libspeexdsp 同场景实测: 纯回声 ERLE 53dB、双讲语音相关度 0.86 (比不处理还好); 其 C API 自 2008 年起未变, ctypes 直连稳定可靠。
安装
# 系统库 (二选一)
sudo apt install libspeexdsp1 # Ubuntu/Debian
brew install speexdsp # macOS
pip install speexdsp-aec
无系统库的特殊环境可用 SPEEXDSP_LIB 环境变量指向 .so/.dylib 文件。
用法
from speexdsp_aec import SpeexAec
aec = SpeexAec(sample_rate=16000, frame_ms=20, filter_tail_ms=200)
# near: 麦克风混音 int16 数组; ref: 与播放同步的参考信号 (如播放回采通道)
out_bytes = aec.process(near_int16, ref_int16) # 消回声后的 PCM, 不足一帧时返回 b""
aec.close()
参数
sample_rate: 采样率 (默认 16000)frame_ms: speex 内部帧长 (默认 20ms)filter_tail_ms: 回声拖尾长度 (默认 200ms, 覆盖 50ms 延迟 + 混响余量)
收敛特性
- 平稳参考: 数秒内 ERLE >40dB
- 语音参考 (TTS): 持续播放 3~5s 后 ERLE
1520dB; 声学路径固定时对话中保持收敛
开发
python -m venv venv && venv/bin/pip install -e ".[dev]"
venv/bin/python -m pytest
Metadata
Release files for speexdsp-aec 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| speexdsp_aec-0.1.0.tar.gz | 5.3 kB | Without provenance | Details for speexdsp_aec-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| speexdsp_aec-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for speexdsp_aec-0.1.0-py3-none-any.whl |
Total release size: 10.7 kB
Release files / speexdsp_aec-0.1.0.tar.gz
| Download URL | speexdsp_aec-0.1.0.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fac42f6ca74bb661fa414580c7977ebe4e5bbd32c44eda4cd3e2560d75bfd865
|
|
BLAKE2b-256 checksum How to use checksums |
9da1952b9112721ae54f94d45562e4e7983a063bf7fedc20072e8d855e9d3f01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|
Release files / speexdsp_aec-0.1.0-py3-none-any.whl
| Download URL | speexdsp_aec-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01f8f19cdaa79adf52033dbf37e7f73658dcc05352c8a5791dbb1aa000a4afa8
|
|
BLAKE2b-256 checksum How to use checksums |
fc25e4e4836b9cefc247ea312e2c9280163b926fc32d3569d5d48a57f285f859
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|
Security for speexdsp-aec 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.