DeepFilterNet Documentation

repository·main·Indexed 26 days ago

https://github.com/rikorose/deepfilternet

A low-complexity speech enhancement framework for full-band (48kHz) audio. It provides tools for real-time noise suppression, offline audio enhancement via CLI or Python, and a complete framework for training new models. Features include a LADSPA plugin, Pipewire filter-chain integration for virtual microphones and outputs, and a Python API for programmatic audio processing.

Tokens
8.1K
Snippets
15
Records
71
Agent score
88%

What's inside DeepFilterNet

  1. Use DeepFilterNet as a Pipewire filter-chain source (Virtual Microphone)

    main

    To create a virtual microphone that suppresses noise for applications like Zoom or Discord, use a Pipewire filter-chain source.

    1. Configure your filter-chain using the template provided in filter-chain-configs/deepfilter-mono-source.conf.
    2. Run the Pipewire filter-chain module with your configuration file.

    To debug the setup, you can increase the log level using the RUST_LOG environment variable.

  2. Start DeepFilterNet training

    main

    Once datasets are prepared in HDF5 format and a configuration file is created, run the training script.

    Usage: python df/train.py <DATA_CONFIG_FILE> <DATA_DIR> <BASE_DIR>

    • <DATA_CONFIG_FILE>: Path to your dataset.cfg.
    • <DATA_DIR>: Directory containing the HDF5 datasets.
    • <BASE_DIR>: Directory where logs, checkpoints, and config will be stored.
    python df/train.py path/to/dataset.cfg path/to/data_dir/ path/to/base_dir/
  3. Manual Installation for Development

    main

    For developers working within the repository, follow these steps to build and install the necessary components using maturin and poetry.

    1. Install build dependencies:
      pip install maturin poetry
    2. Install Python dependencies via Poetry:
      • Option A (Global/Environment): poetry -C DeepFilterNet install -E train -E eval
      • Option B (In-repo development): poetry -C DeepFilterNet install -E train -E eval --no-root (requires setting PYTHONPATH=$PWD/DeepFilterNet).
    3. Build and install libdf (required for enhance.py):
      maturin develop --release -m pyDF/Cargo.toml
    4. (Optional) Build `libdfdata` for training functionality:
       ```bash
    maturin develop --release -m pyDF-data/Cargo.toml

    Note: If HDF5 errors occur, try building with the static feature: maturin develop --release --features hdf5-static -m pyDF-data/Cargo.toml

  4. Install Ubuntu system requirements for DeepFilterNet

    main

    If you are using Ubuntu, you must install the following system dependencies to build and run the project:

    • build-essential
    • cmake
    • libfontconfig1-dev
    • libasound2-dev
    sudo apt -y install build-essential cmake libfontconfig1-dev libasound2-dev
  5. Prepare HDF5 datasets for training

    main

    Before training, you must convert your audio files into HDF5 format using prepare_data.py.

    Usage: python df/scripts/prepare_data.py --sr <SR> <TYPE> <AUDIO_FILES_TXT> <HDF5_DB>

    • --sr: Sampling rate (e.g., 48000).
    • <TYPE>: One of speech, noise, or rir.
    • <AUDIO_FILES_TXT>: Text file containing paths to audio files.
    • <HDF5_DB>: Output HDF5 filename.
    pip install h5py librosa soundfile
    python df/scripts/prepare_data.py --sr 48000 speech training_set.txt TRAIN_SET_SPEECH.hdf5
  6. Install DeepFilterNet via PyPI

    main

    You can install DeepFilterNet as a Python package using pip. It is recommended to install torch and torchaudio first.

    To install the standard package:

    pip install torch torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html
    pip install deepfilternet

    To install with data loading functionality for training (Linux only):

    pip install deepfilternet[train]
    pip install torch torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html
    pip install deepfilternet
    # Or install DeepFilterNet including data loading functionality for training (Linux only)
    pip install deepfilternet[train]
  7. Install the DeepFilterNet LADSPA Plugin

    main

    You can install the LADSPA plugin using one of two methods:

    1. Release Build: Download the pre-compiled libdeep_filter_ladspa from the DeepFilterNet releases page.
    2. Manual Build: Build the plugin from source using cargo.

    Note: The plugin uses a model without lookahead, resulting in a minimum latency of 20 ms (STFT processing), plus any additional latency introduced by your LADSPA host (e.g., Pipewire).

  8. Use DeepFilterNet as a Pipewire filter-chain sink (Virtual Output)

    main

    To create a virtual output that suppresses noise from applications (like browsers or video players), use a Pipewire filter-chain sink. The output will contain speech while suppressing most background noise.

    1. Configure your filter-chain using the template provided in filter-chain-configs/deepfilter-stereo-sink.conf.
    2. Refer to the Pipewire wiki for detailed information on Pipewire filter chains.
  9. Configure training with a dataset JSON

    main

    The training script requires a dataset configuration file (e.g., dataset.cfg) that defines the train, valid, and test splits. Each split is a list of arrays containing the HDF5 file path and a sampling factor (usually 1.0).

    Example dataset.cfg structure:

    {
      "train": [
        ["TRAIN_SET_SPEECH.hdf5", 1.0],
        ["TRAIN_SET_NOISE.hdf5", 1.0],
        ["TRAIN_SET_RIR.hdf5", 1.0]
      ],
      "valid": [...],
      "test": [...]
    }
    {
      "train": [
        [
          "TRAIN_SET_SPEECH.hdf5",
          1.0
        ],
        [
          "TRAIN_SET_NOISE.hdf5",
          1.0
        ],
        [
          "TRAIN_SET_RIR.hdf5",
          1.0
        ]
      ],
      "valid": [
        [
          "VALID_SET_SPEECH.hdf5",
          1.0
        ],
        [
          "VALID_SET_NOISE.hdf5",
          1.0
        ],
        [
          "VALID_SET_RIR.hdf5",
          1.0
        ]
      ],
      "test": [
        [
          "TEST_SET_SPEECH.hdf5",
          1.0
        ],
        [
          "TEST_SET_NOISE.hdf5",
          1.0
        ],
        [
          "TEST_SET_RIR.hdf5",
          1.0
        ]
      ]
    }