Skip to main content

PyO3 bindings for the official DeepFilterNet Rust realtime runtime

Project description

DeepFilterNet-rs

Python bindings for the official DeepFilterNet Rust realtime runtime.

This package exposes a small PyO3 wrapper around DeepFilterNet's Rust DfTract streaming runtime. It is intended for realtime audio enhancement pipelines that need a Python API without shelling out to the deep-filter binary.

The required DeepFilterNet Rust runtime source is inlined under rust/src/deep_filter from upstream Rikorose/DeepFilterNet tag v0.5.6. The bundled default model now ships as Python package data under python/deepfilternet_rs/models. Builds do not depend on the upstream Git repository at compile time.

The package also includes a small deepfilternet command line tool for denoising common audio files through ffmpeg-based decode and encode steps.

Install

pip install deepfilternet-rs

When installing from source, a Rust toolchain is required because the package is built with maturin. Prebuilt wheels do not require Rust on the target machine.

Usage

import numpy as np
from deepfilternet_rs import DeepFilterNetRealtime

processor = DeepFilterNetRealtime(
    model_path=None,
    atten_lim=100.0,
    log_level="warn",
    compensate_delay=True,
    post_filter_beta=0.0,
)

audio = np.zeros(processor.frame_length, dtype=np.float32)
enhanced = processor.process_chunk(audio)
tail = processor.finalize()

When model_path=None, the Python package automatically resolves the bundled default model file from deepfilternet_rs.models and passes its path into the Rust runtime.

CLI

deepfilternet input.wav output.wav

The CLI accepts common input formats that ffmpeg can decode, such as WAV, FLAC, MP3, and M4A. Audio is automatically converted to mono 48kHz before running the DeepFilterNet model, and the output format follows the destination file extension.

Optional runtime parameters mirror the Python API defaults:

deepfilternet input.wav output.wav \
  --model-path custom_model.tar.gz \
  --atten-lim 100.0 \
  --log-level warn \
  --compensate-delay \
  --post-filter-beta 0.0 \
  --min-db-thresh -15.0 \
  --max-db-erb-thresh 35.0 \
  --max-db-df-thresh 35.0

Parameter tuning notes:

  • --atten-lim: controls how aggressively extra attenuation is allowed. Lower values usually keep more room tone and background ambience, but noise may remain more obvious. Higher values push stronger suppression. 100.0 is the least restrictive default.
  • --post-filter-beta: controls extra residual-noise cleanup after the main model pass. 0.0 is the most natural starting point. Raising it can make noisy clips sound cleaner, but if it is too high, speech may become thinner, duller, or slightly watery.
  • --compensate-delay: enabled by default and recommended for normal file output. It removes the model delay so the result lines up better with the source timing. Turning it off is mostly useful for debugging or low-level alignment experiments.
  • --log-level: now controls both the Rust runtime logger and ffmpeg -v .... Use warn or error for normal runs. Use info or debug when you want more diagnostics. trace is intentionally very noisy and may print large amounts of model-loading and graph-parsing output.
  • --model-path: leave unset to use the bundled default model. Set it when you want to test or ship a different official DeepFilterNet model package.
  • --min-db-thresh, --max-db-erb-thresh, --max-db-df-thresh: advanced SNR threshold parameters passed directly to the underlying DeepFilterNet runtime. They affect when different decoder paths remain active across noisier or cleaner regions. These are useful for controlled experiments and model tuning, but they are much easier to mis-tune than --atten-lim or --post-filter-beta, so most users should leave them at their defaults.

Current CLI constraints:

  • ffmpeg must be installed and available on PATH.
  • Input and output formats are limited to what the local ffmpeg build supports.
  • The model still runs internally at mono 48000 Hz.

API

DeepFilterNetRealtime

Constructor arguments:

Argument Type Default Description
model_path `str None` None
atten_lim float 100.0 Attenuation limit in dB. 100.0 means no explicit limit.
log_level `str None` None
compensate_delay bool True Drop initial algorithmic-delay samples from output.
post_filter_beta float 0.0 Post-filter beta. 0.0 disables the post-filter.
min_db_thresh float -15.0 Advanced local SNR threshold for the decoder DNN path.
max_db_erb_thresh float 35.0 Advanced upper SNR threshold for the ERB decoder path.
max_db_df_thresh float 35.0 Advanced upper SNR threshold for the DF decoder path.

Properties:

Property Description
sample_rate Backend processing sample rate. Official DeepFilterNet models use 48000 Hz.
frame_length Frame length in samples. Official DeepFilterNet models use 480 samples.

Methods:

Method Description
process_chunk(audio) Process a one-dimensional float32 numpy array and return enhanced float32 samples. The input can be any length; incomplete frames are buffered.
finalize() Flush buffered samples with zero padding and close the processor.
close() Clear buffers and close the processor without flushing.

Release

Publishing is handled by GitHub Actions. Create a GitHub release or run the release workflow manually after configuring the PYPI_API_TOKEN repository secret.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepfilternet_rs-0.1.1.tar.gz (8.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

deepfilternet_rs-0.1.1-cp312-cp312-win_amd64.whl (13.4 MB view details)

Uploaded CPython 3.12Windows x86-64

deepfilternet_rs-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

deepfilternet_rs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (13.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

deepfilternet_rs-0.1.1-cp311-cp311-win_amd64.whl (13.4 MB view details)

Uploaded CPython 3.11Windows x86-64

deepfilternet_rs-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

deepfilternet_rs-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (13.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

deepfilternet_rs-0.1.1-cp310-cp310-win_amd64.whl (13.4 MB view details)

Uploaded CPython 3.10Windows x86-64

deepfilternet_rs-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

deepfilternet_rs-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (13.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file deepfilternet_rs-0.1.1.tar.gz.

File metadata

  • Download URL: deepfilternet_rs-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepfilternet_rs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 35151a5d179fa9367318b5d781c4dd5e9a16a9558fdca9ed29fee1480ff5db2f
MD5 ec22d58d05606e9d84f070ea2ecd982d
BLAKE2b-256 91d4c8f4afafcab2a854de5fbc86438d9d8221ad52802422c0fb95bb700a92c3

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6e3c1f7c49fc8f84e01cff684be5db204c946185c312030b379f9cfa265662c6
MD5 4d88806250a35da8fe647f409eb71fa4
BLAKE2b-256 9874bd67b0101c73e9d5b77b2038802b0659c6eaa8fe6b9432ef7ebcdd4924be

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45bd825ab1ae06476fa2dd23b7dc222d64f42691cff9e9f1c0bbdc9b48ab5b43
MD5 cb124d44023a6f2894f69d7362e9f864
BLAKE2b-256 ad1e290210cf2ac3bdc1a083244d72f3b0149eaf01476e950893ddc4fd5bac27

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf89f5ec91fc3ef465468849e3f6462fb9e711a3ee9cf5912e12c70f5cc931b4
MD5 9f7aeba3730931e3d4c5f0ece3c24ee9
BLAKE2b-256 0faffe92f508eef5431514b878d9886f9d1d429f2272f4f9ef7fadc6e6a1c1e2

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1263047154d06dc1b6eb4a6fcd6c80309336c9f7cfe668a0ddf318212ac0776c
MD5 176d6e36c15ddf912b30c8f6c81d5d43
BLAKE2b-256 48fe913b2cef6502ec0551bf4731b12a96a93b6e4848611a441d79e65799f527

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16c6e6fcaca50a58d9b67df10a23e34ca6679467457db673ca2760a83758c7c3
MD5 0dceffee3f97484700c4f0796aea143d
BLAKE2b-256 1972139b4f6263a00723160ec3ae80e79cdde1e6ba27c12aa08de7f2c162aeaf

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c492a69736378154d147859eeffde97272f6b470d9782f528adeafab8ef2c457
MD5 bb416c22674e961645874405cd0c1823
BLAKE2b-256 3575b54d481e38b867e9a7053a559bb620aafb734d61a6c9d742645c97009492

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b7c14b97b9b77453e6b39ab6156b2f1445a81901f064e2724c009c273bc5596f
MD5 26bb6275fdc3d6b5eec30ce224d5f678
BLAKE2b-256 bf18465a2cdc50207066d0832e154c6eba92ceb5fa50e880b4170c58780d38ab

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a2b6fe08fc51138153c6e81c28f1b272d8a6c41db09077cf7f0e560f0696313
MD5 eb94262709ccb73a7047953b2f299295
BLAKE2b-256 58f114aa600e75c841fad36aa5b65d2cbee6763894ba96213db23ff07dc52f38

See more details on using hashes here.

File details

Details for the file deepfilternet_rs-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for deepfilternet_rs-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca113f052dc91049132eb56318f4060693b2178992880fc51dd563765dc8f12c
MD5 1c2d558c91b7cca2ffc0ce5937a2d86d
BLAKE2b-256 07d17f6c3da9997f7b0b30d676d2a21cd61aae178577167bd0ded10690d60b85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page