Skip to main content

df0: Differentiable Variants of Classical Fundamental Frequency Estimators

PyPI version tests License: MIT

This is a Python package containing Pytorch implementations of differentiable variants of classical fundamental frequency estimators (dYIN and dSWIPE). This code accompanies the following paper:

@article{StrahlM25_df0_TASLPRO,
  author  = {Sebastian Strahl and Meinard M{\"u}ller},
  title   = {{dYIN} and {dSWIPE}: {D}ifferentiable Variants of Classical Fundamental Frequency Estimators},
  journal = {{IEEE/ACM} Transactions on Audio, Speech, and Language Processing},
  volume  = {33},
  pages   = {2622--2633},
  year    = {2025},
  doi     = {10.1109/TASLPRO.2025.3581119}
}

For details and references, please check out this paper.

Installation

1. Set up Python environment

We recommend setting up a Python environment including Pytorch before installing df0. You may use the example environment provided as part of this package:

git clone https://github.com/groupmm/df0.git
cd df0
conda env create -f environment.yaml
conda activate df0

2. Install df0

Option 1: Install from PyPI

pip install df0-pitch

To also install the dependencies required to run the demo notebook:

pip install "df0-pitch[demo]"

Option 2: Install by cloning this repository (for development)

git clone https://github.com/groupmm/df0.git
cd df0
pip install -e .

Usage

Python

import torch
import librosa
from df0.dyin import dYIN
from df0.dswipe import dSWIPE

x, fs = librosa.load("audio.wav", sr=16000)
x = torch.from_numpy(x)

dyin = dYIN(fs=fs, hop_size=160)
f0_hz = dyin(x)["f0_hz"]  # shape: (n_frames,)

dswipe = dSWIPE(fs=fs, hop_size=160)
f0_hz = dswipe(x)["f0_hz"]  # shape: (n_frames,)

For more details, see demo.ipynb.

Command-line interface

To get the F0 predictions for an audio file, you can use the command-line interface, running one of the following commands in a terminal:

dswipe audio.wav
dyin audio.wav

To get the predictions for all .wav files in dir_audio/, use:

dswipe dir_audio/*.wav

By running these commands, the F0 predictions are stored as .csv files in a folder specified by the command-line argument dir_out (default: f0_csv). Example usage:

dswipe dir_audio/*.wav --dir_out f0_dswipe_csv

Use dswipe -h or dyin -h for an overview of available command-line options.

The output format of our methods is similar to that of CREPE and PESTO, except that there is no confidence:

time,frequency
0.000,63.544
0.010,651.683
0.020,655.458
0.030,651.683
0.040,666.915
0.050,678.573
...

Tests

We provide automated tests for each algorithm. To run them:

pip install "df0-pitch[test]"
pytest

Contribution

Automated code style checks via pre-commit:

pip install pre-commit
pre-commit install
pre-commit run --all-files

License

The code for this toolbox is published under an MIT license.

Acknowledgements

This work was funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Grant No. 500643750 (MU 2686/15-1). The authors are with the International Audio Laboratories Erlangen, a joint institution of the Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU) and Fraunhofer Institute for Integrated Circuits IIS.

Metadata

Release files for df0-pitch 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for df0-pitch 1.0.1
File Size Uploaded
df0_pitch-1.0.1.tar.gz 18.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for df0-pitch 1.0.1
File Interpreter ABI Platform
df0_pitch-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.3 kB

Release files / df0_pitch-1.0.1.tar.gz

Download URL df0_pitch-1.0.1.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
08c6f95ed5e9dd54d58c451c0bc76a96e5a7bbc974212b65a34094101aabd544
BLAKE2b-256 checksum
How to use checksums
ec2028f25837e0d713ac76d8dfffd3a9b22bafd7fc468d35a561c7f9c4b4197f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / df0_pitch-1.0.1-py3-none-any.whl

Download URL df0_pitch-1.0.1-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aae383b3db3995afab404b7db4ade34d5b62ac240999e2b63f8493e9d1808dcb
BLAKE2b-256 checksum
How to use checksums
9ef28b10f96af12e36a841642e8970246a2611d204ba5f7b1abd432cd7cef853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page