Add deepfilternet

This commit is contained in:
Xin Wang
2026-05-27 16:37:14 +08:00
parent c4a53b5205
commit 673a54049a
6 changed files with 307 additions and 0 deletions

61
docs/deepfilternet.md Normal file
View File

@@ -0,0 +1,61 @@
# DeepFilterNet Input Filter
The engine can optionally run DeepFilterNet on inbound microphone audio before
Pipecat VAD and STT. The integration uses DeepFilterNet's real-time `libDF` C
API (`df_process_frame`) rather than the Python `df.enhance()` batch helper.
## Build DeepFilterNet
From the DeepFilterNet checkout:
```bash
cd /Users/wangx/Code/DeepFilterNet
cargo build --release -p deep_filter --features capi
```
Use the generated native library path as `audio_filter.lib_path`. On macOS this
is usually:
```text
/Users/wangx/Code/DeepFilterNet/target/release/libdf.dylib
```
Use an ONNX tar.gz model as `audio_filter.model_path`, for example:
```text
/Users/wangx/Code/DeepFilterNet/models/DeepFilterNet3_ll_onnx.tar.gz
```
The low-latency model is preferred for a live voice endpoint.
## Install Optional Python Dependencies
```bash
uv pip install -r requirements-deepfilternet.txt
```
## Enable
```json
"audio_filter": {
"enabled": true,
"provider": "deepfilternet",
"lib_path": "/Users/wangx/Code/DeepFilterNet/target/release/libdf.dylib",
"model_path": "/Users/wangx/Code/DeepFilterNet/models/DeepFilterNet3_ll_onnx.tar.gz",
"model_sample_rate_hz": 48000,
"atten_lim_db": 100.0,
"post_filter_beta": 0.0,
"log_level": null
}
```
`model_sample_rate_hz` defaults to `48000`, matching the bundled DeepFilterNet
models. The filter resamples from the engine sample rate to the model sample
rate, processes hop-sized frames, then resamples back to the engine sample rate.
You can also provide paths through environment variables:
```bash
export DEEPFILTERNET_LIB_PATH=/Users/wangx/Code/DeepFilterNet/target/release/libdf.dylib
export DEEPFILTERNET_MODEL_PATH=/Users/wangx/Code/DeepFilterNet/models/DeepFilterNet3_ll_onnx.tar.gz
```