### Install Python Dependencies Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Sets up a virtual environment and installs required Python packages from requirements.txt. ```bash python -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Install dpdfnet Package Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Install the dpdfnet package using pip. This command installs the core package for CPU-only inference. ```bash pip install dpdfnet ``` -------------------------------- ### Download Models from Hugging Face Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Installs the huggingface_hub CLI and downloads PyTorch, ONNX, and TFLite models to local directories. ```bash pip install -U "huggingface_hub[cli]" # create target dirs mkdir -p model_zoo/{checkpoints,onnx,tflite} # PyTorch checkpoints (HF path: checkpoints/* -> local: model_zoo/checkpoints/*) hf download Ceva-IP/DPDFNet \ --include "checkpoints/*.pth" \ --local-dir model_zoo \ # ONNX models (HF path: onnx/* -> local: model_zoo/onnx/*) hf download Ceva-IP/DPDFNet \ --include "onnx/*.onnx" \ --local-dir model_zoo \ # TFLite models (HF path: *.tflite at repo root -> local: model_zoo/tflite/*) hf download Ceva-IP/DPDFNet \ --include "*.tflite" \ --local-dir model_zoo/tflite \ ``` -------------------------------- ### Install dpdfnet with MP3 Support Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Install dpdfnet with optional MP3 support, which requires additional dependencies and FFmpeg. ```bash pip install 'dpdfnet[mp3]' ``` -------------------------------- ### Install Sounddevice for Real-time Enhancement Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Installs the 'sounddevice' library, which is required for real-time microphone processing with DPDFNet but not included in its dependencies. ```bash pip install sounddevice ``` -------------------------------- ### Run DNSMOS Local Inference Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Utilize the official DNSMOS local inference script from the DNS Challenge repository for P.835 & P.808 metrics. Ensure you follow their installation and model download instructions. ```python dnsmos_local.py ``` -------------------------------- ### Predict NISQA v2 Scores Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Use the official NISQA project for NISQA v2 predictions. Refer to their README for environment setup, model weights, and inference commands like running `nisqa_predict.py` on a folder of WAVs. ```python nisqa_predict.py ``` -------------------------------- ### Enhance Single File with Python API Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Use the dpdfnet Python API to enhance a single audio file and get the output path. ```python # Enhance one file: out_path = dpdfnet.enhance_file("noisy.wav", model="dpdfnet2", attn_limit_db=12) print(out_path) ``` -------------------------------- ### Real-time Microphone Enhancement with DPDFNet StreamEnhancer Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Processes audio from a microphone in real-time using `StreamEnhancer`. This class preserves RNN state across processing calls. The `callback` function handles incoming audio chunks, processes them, and outputs enhanced audio. Ensure `sounddevice` is installed. ```python import numpy as np import sounddevice as sd import dpdfnet INPUT_SR = 48000 # Use one model hop (10 ms) as the block size so process() returns # exactly one hop's worth of enhanced audio on every callback. BLOCK_SIZE = int(INPUT_SR * 0.010) # 480 samples at 48 kHz enhancer = dpdfnet.StreamEnhancer(model="dpdfnet2_48khz_hr") def callback(indata, outdata, frames, time, status): mono_in = indata[:, 0] if indata.ndim > 1 else indata.ravel() enhanced = enhancer.process(mono_in, sample_rate=INPUT_SR) n = min(len(enhanced), frames) outdata[:n, 0] = enhanced[:n] if n < frames: outdata[n:] = 0.0 # silence while the first window accumulates with sd.Stream( samplerate=INPUT_SR, blocksize=BLOCK_SIZE, channels=1, dtype="float32", callback=callback, ): print("Enhancing microphone input - press Ctrl+C to stop") try: while True: sd.sleep(100) except KeyboardInterrupt: pass # Optional: drain the final partial window at the end of a recording tail = enhancer.flush() ``` -------------------------------- ### Run Real-Time DPDFNet Demo Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Execute the real-time demo script from the command line. Ensure you are in the repository root and have activated your virtual environment. ```bash python -m real_time_demo ``` -------------------------------- ### Download All Models Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Download all available speech enhancement models for dpdfnet. ```bash dpdfnet download ``` -------------------------------- ### Available Models Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Lists all available enhancement models. Iterates through the models and prints their name, readiness status, and whether they are cached. ```APIDOC ## dpdfnet.available_models ### Description Retrieves a list of available enhancement models, including their status. ### Returns - **list** - A list of dictionaries, where each dictionary contains 'name', 'ready', and 'cached' keys for a model. ### Request Example ```python import dpdfnet for row in dpdfnet.available_models(): print(row["name"], row["ready"], row["cached"]) ``` ``` -------------------------------- ### Enhance Directory with CLI (Default Workers) Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Use the dpdfnet CLI to enhance all WAV files in a directory. It uses all available CPU cores by default. ```bash # Enhance a directory (uses all CPU cores by default) dpdfnet enhance-dir ./noisy_wavs ./enhanced_wavs --model dpdfnet2 --attn-limit-db 12 ``` -------------------------------- ### Download Specific Model with Force Option Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Download a specific speech enhancement model, forcing the download even if it already exists locally. ```bash dpdfnet download dpdfnet4 --force ``` -------------------------------- ### Display dpdfnet CLI Help Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Show the help message for the dpdfnet command-line interface to understand available commands and options. ```bash dpdfnet --help ``` -------------------------------- ### Download dpdfnet Models with CLI Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Use the dpdfnet CLI to download available audio enhancement models. You can download all models, a specific model, or force a download. ```bash # Download models dpdfnet download dpdfnet download dpdfnet8 dpdfnet download dpdfnet4 --force ``` -------------------------------- ### Enhance Directory with CLI (Fixed Workers) Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Use the dpdfnet CLI to enhance WAV files in a directory with a specified number of worker processes. ```bash # Enhance a directory with a fixed worker count dpdfnet enhance-dir ./noisy_wavs ./enhanced_wavs --model dpdfnet2 --workers 4 --attn-limit-db 12 ``` -------------------------------- ### List Available DPDFNet Models Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Retrieves and prints information about available DPDFNet models. The output includes the model name, readiness status, and caching status. ```python import dpdfnet for row in dpdfnet.available_models(): print(row["name"], row["ready"], row["cached"]) ``` -------------------------------- ### Calculate PESQ, STOI, SI-SNR Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Use this script to compute PESQ, STOI, and SI-SNR for reference and enhanced audio. It includes auto-alignment for fair comparisons. ```python pesq_stoi_sisnr_calc.py ``` -------------------------------- ### Enhance Directory of Audio Files (Default Workers) Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Enhance all supported audio files within a directory using the 'enhance-dir' command. This utilizes all available CPU cores by default. ```bash dpdfnet enhance-dir ./noisy_wavs ./enhanced_wavs --model dpdfnet2 --attn-limit-db 12 ``` -------------------------------- ### Download Specific Model Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Download a specific speech enhancement model by its name. ```bash dpdfnet download dpdfnet8 ``` -------------------------------- ### Enhance Single Audio File with CLI Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Use the dpdfnet CLI to enhance a single WAV file. Specify the model and attention limit in decibels. ```bash # Enhance one file dpdfnet enhance noisy.wav enhanced.wav --model dpdfnet4 --attn-limit-db 12 ``` -------------------------------- ### Enhance Audio In Memory with DPDFNet Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Enhances audio data loaded into memory. Requires 'soundfile' for reading/writing audio and 'dpdfnet' for enhancement. Specify the audio data, sample rate, model, and optionally attention limit in decibels. ```python import soundfile as sf import dpdfnet audio, sr = sf.read("noisy.wav") enhanced = dpdfnet.enhance(audio, sample_rate=sr, model="dpdfnet4", attn_limit_db=12) sf.write("enhanced.wav", enhanced, sr) ``` -------------------------------- ### Run Offline Enhancement with ONNX Model Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Performs audio enhancement using an ONNX model. Place noisy WAV files in './noisy_wavs' and specify model details. ```bash python -m onnx_model.infer_dpdfnet_onnx \ --noisy_dir ./noisy_wavs \ --enhanced_dir ./enhanced_wavs \ --model_name dpdfnet4 \ --workers 5 \ --attn-limit-db 12 ``` -------------------------------- ### Download DPDFNet Models Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Downloads DPDFNet models. Call without arguments to download all available models, or specify a model name to download a particular one. ```python import dpdfnet dpdfnet.download() dpdfnet.download("dpdfnet4") ``` -------------------------------- ### Download Models Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Downloads enhancement models. Can download all available models or a specific model by name. ```APIDOC ## dpdfnet.download ### Description Downloads enhancement models from the API. ### Parameters - **model_name** (str, optional) - The name of a specific model to download. If not provided, all available models are downloaded. ### Request Example ```python import dpdfnet # Download all models dpdfnet.download() # Download a specific model dpdfnet.download("dpdfnet4") ``` ``` -------------------------------- ### List Available Models with Python API Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Retrieve a list of available dpdfnet models and their status (ready, cached) using the Python API. ```python # Model listing: for row in dpdfnet.available_models(): print(row["name"], row["ready"], row["cached"]) ``` -------------------------------- ### In-Memory Audio Enhancement with Python API Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Enhance audio data directly in memory using the dpdfnet Python API. Requires the soundfile library for reading and writing audio. ```python import soundfile as sf import dpdfnet # In-memory enhancement: audio, sr = sf.read("noisy.wav") enhanced = dpdfnet.enhance(audio, sample_rate=sr, model="dpdfnet4", attn_limit_db=12) sf.write("enhanced.wav", enhanced, sr) ``` -------------------------------- ### Enhance Directory with Fixed Worker Count Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Enhance audio files in a directory with a specified number of worker threads using the 'enhance-dir' command. ```bash dpdfnet enhance-dir ./noisy_wavs ./enhanced_wavs --model dpdfnet2 --workers 4 --attn-limit-db 12 ``` -------------------------------- ### Benchmark ONNX Runtime Performance Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Benchmark the ONNX runtime for DPDFNet to assess its performance and compare its Real-Time Factor (RTF). This is useful for CPU performance troubleshooting. ```python python -m onnx_model.infer_dpdfnet_onnx --noisy_dir /path/to/noisy/audio --enhanced_dir /path/to/enhanced/audio ``` -------------------------------- ### Enhance File Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Enhances a single audio file. Takes the path to an input audio file, enhances it using a specified model and parameters, and returns the path to the output enhanced file. ```APIDOC ## dpdfnet.enhance_file ### Description Enhances a single audio file, saving the output to a new file. ### Parameters - **input_path** (str) - The path to the input audio file. - **model** (str) - The name of the model to use for enhancement. - **attn_limit_db** (float, optional) - The attention limit in decibels. Defaults to None. ### Returns - **str** - The path to the enhanced output audio file. ### Request Example ```python import dpdfnet out_path = dpdfnet.enhance_file("noisy.wav", model="dpdfnet2", attn_limit_db=12) print(out_path) ``` ``` -------------------------------- ### In-memory Enhancement Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Enhances an audio array in memory. Reads audio from a file, enhances it using a specified model and parameters, and writes the enhanced audio to a new file. ```APIDOC ## dpdfnet.enhance ### Description Enhances an audio array in memory using a specified model and parameters. ### Parameters - **audio** (numpy.ndarray) - The input audio data. - **sample_rate** (int) - The sample rate of the audio. - **model** (str) - The name of the model to use for enhancement. - **attn_limit_db** (float, optional) - The attention limit in decibels. Defaults to None. ### Request Example ```python import soundfile as sf import dpdfnet audio, sr = sf.read("noisy.wav") enhanced = dpdfnet.enhance(audio, sample_rate=sr, model="dpdfnet4", attn_limit_db=12) sf.write("enhanced.wav", enhanced, sr) ``` ``` -------------------------------- ### Enhance Single Audio File Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Enhance a single audio file using the 'enhance' command. Specify the input file, output file, model, and optional attention limit. ```bash dpdfnet enhance noisy.wav enhanced.wav --model dpdfnet4 --attn-limit-db 12 ``` -------------------------------- ### Run Offline Enhancement with TFLite Model Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Performs audio enhancement using a TFLite model. Place noisy WAV files in './noisy_wavs' and specify model details. ```bash python -m tflite_model.infer_dpdfnet_tflite \ --noisy_dir ./noisy_wavs \ --enhanced_dir ./enhanced_wavs \ --model_name dpdfnet4 \ --workers 5 \ --attn-limit-db 12 ``` -------------------------------- ### Enhanced Audio File Naming Convention Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md Describes the naming format for enhanced audio files generated by the model. ```text _.wav ``` -------------------------------- ### Enhance Audio File with DPDFNet Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Enhances a single audio file directly. Specify the input file path, model, and optionally attention limit in decibels. The function returns the path to the enhanced output file. ```python import dpdfnet out_path = dpdfnet.enhance_file("noisy.wav", model="dpdfnet2", attn_limit_db=12) print(out_path) ``` -------------------------------- ### DPDFNet Citation Source: https://github.com/ceva-ip/dpdfnet/blob/main/README.md BibTeX entry for citing the DPDFNet paper. ```bibtex @article{rika2025dpdfnet, title = {DPDFNet: Boosting DeepFilterNet2 via Dual-Path RNN}, author = {Rika, Daniel and Sapir, Nino and Gus, Ido}, year = {2025}, } ``` -------------------------------- ### StreamEnhancer Source: https://github.com/ceva-ip/dpdfnet/blob/main/package/README.md Processes audio chunk-by-chunk for real-time enhancement, preserving RNN state across calls. Suitable for microphone input. ```APIDOC ## dpdfnet.StreamEnhancer ### Description Processes audio in real-time, maintaining RNN state for continuous enhancement. ### Initialization - **model** (str) - The name of the model to use for enhancement. ### Methods - **process(audio_chunk, sample_rate)**: Processes a chunk of audio data. - **audio_chunk** (numpy.ndarray): The input audio data chunk. - **sample_rate** (int): The sample rate of the audio. - **Returns**: numpy.ndarray - The enhanced audio data chunk. - **flush()**: Processes any remaining buffered audio data. - **Returns**: numpy.ndarray - The remaining enhanced audio data. - **reset()**: Clears the RNN state, useful for processing independent audio segments. ### Notes - Latency: The first enhanced output arrives after one full model window (~20 ms). - Sample Rate: `StreamEnhancer` resamples internally. Pass your device's native rate. - Block Size: Using a block size of one model hop (e.g., 10 ms) yields one enhanced block per callback. ### Real-time Microphone Enhancement Example ```python import numpy as np import sounddevice as sd import dpdfnet INPUT_SR = 48000 BLOCK_SIZE = int(INPUT_SR * 0.010) # 480 samples at 48 kHz enhancer = dpdfnet.StreamEnhancer(model="dpdfnet2_48khz_hr") def callback(indata, outdata, frames, time, status): mono_in = indata[:, 0] if indata.ndim > 1 else indata.ravel() enhanced = enhancer.process(mono_in, sample_rate=INPUT_SR) n = min(len(enhanced), frames) outdata[:n, 0] = enhanced[:n] if n < frames: outdata[n:] = 0.0 with sd.Stream( samplerate=INPUT_SR, blocksize=BLOCK_SIZE, channels=1, dtype="float32", callback=callback, ): print("Enhancing microphone input - press Ctrl+C to stop") try: while True: sd.sleep(100) except KeyboardInterrupt: pass # Optional: drain the final partial window tail = enhancer.flush() ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.