PitchUNet: a refiner for WORLD pitch shifts

PitchUNet shifts the pitch of a single voice, sung or spoken, while keeping its timbre. A formant-preserving WORLD shift moves the pitch; this model, a conditional U-Net over 80-band log-mel spectrograms, then removes WORLD's artifacts; the BigVGAN base vocoder (22.05 kHz, not included here) turns the result back into audio.

Code, training and evaluation: SelfSupervised-Pitch-Shifter. Training and evaluation ran at commit 6d811ff. Loading model.safetensors from the command line and --engine auto need commit bd61808 or later.

Model

  • 25.42 M parameters; FiLM conditioning on the shift, F0 features from CREPE, gated skip connections, self-attention in the bottleneck, a residual output (it starts as the identity) and a harmonic-template input channel that marks where the F0's harmonics fall on the mel axis.
  • model.safetensors holds the EMA weights of the step-60,000 checkpoint (validation L1 0.3082), float32. config.json records the model, audio and vocoder settings it expects.

Training

Self-supervised, with no parallel data. Each clip is shifted by +s semitones and back by -s with WORLD (|s| up to 6), and the model learns to recover the original log-mel. Losses: L1, multi-resolution and difference terms on the mel, plus a multi-resolution STFT loss on audio rendered through the frozen vocoder.

  • Data: VCTK speech (up to 10 h), OpenSinger (female and male subsets) and GTSinger (20 singers in nine languages, 30 minutes each). Validation holds out whole speakers and singers.
  • 60,000 steps, batch 32, peak learning rate 2e-4, on one RTX 5090 in 3 h 38 min.

Evaluation

300 held-out clips, shifts of 1, 3 and 6 semitones up and down, averaged over all shifts. A single shift has no ground truth, so it is scored on pitch accuracy (CREPE on the output against the source F0 scaled by the shift) and on how far the spectral envelope moved; a round trip (+s then -s) is scored against the original. Lower is better except "voiced kept".

System Pitch error (cents, median) Frames > 50 cents off Voiced kept Envelope distance Round-trip mel L1 Round-trip MCD (dB)
Rubber Band (R3, formants kept) 3.14 0.56% 98.2% 0.326 0.342 19.5
PSOLA (Praat) 3.03 1.09% 97.9% 0.290 0.425 17.8
WORLD 4.36 1.01% 99.2% 0.418 0.568 23.2
WORLD + vocoder 8.97 2.51% 99.0% 0.409 0.604 24.2
WORLD + PitchUNet + vocoder 7.57 2.15% 97.5% 0.291 0.445 16.7
librosa phase vocoder 7.36 4.95% 97.5% 0.637 0.768 20.0
  • Against its own input (WORLD + vocoder), the model lowers envelope distance by 29% and round-trip MCD by 31%.
  • At 6 semitones it scores ahead of Rubber Band on envelope distance and both round-trip measures, but mostly in the top of the mel range. The clips are 22.05 kHz and hold nothing above about 11 kHz, so on a 6-semitone shift Rubber Band has nothing to move into that band, while WORLD rebuilds it. That is also why Rubber Band's round-trip MCD at ±6 is 32.8 and 41.1 dB, against 8 to 14 dB at smaller shifts, and it inflates Rubber Band's average in the table. Scored below 6 kHz on 14 clips of separated vocals from two songs the model never saw, Rubber Band was ahead at ±6 on all three measures.
  • At 1 semitone Rubber Band is ahead on every measure. The model's pitch error is higher than Rubber Band's, PSOLA's and WORLD's at every shift size, most of it added by the vocoder.
  • The round trip is close to what the model was trained to minimise, so it favours the model.

Listening (one listener, informal): on separated vocals from two commercial songs at 6 semitones, the model was preferred over Rubber Band in a small blind comparison, but it still sounds robotic and somewhat squeezed. That preference, not the measures, is the case for the model at large shifts. Resynthesising without a shift was inaudible through both WORLD and the vocoder, so the robotic quality comes from WORLD's pitch change, which this model reduces but does not remove.

Use

With the repository:

git clone https://github.com/AlexAlexBabarika/SelfSupervised-Pitch-Shifter && cd SelfSupervised-Pitch-Shifter
uv sync
hf download AlexAlexBabarika/SelfSupervised-Pitch-Shifter model.safetensors --local-dir .
uv run inference.py song.mp3 -s -3 --engine model --ckpt model.safetensors

In Python:

from safetensors.torch import load_file
from model import PitchUNet  # from the repository

unet = PitchUNet()
unet.load_state_dict(load_file("model.safetensors"))
unet.eval()

inference.pipeline.shift_audio_through_model runs the whole chain (CREPE, WORLD, this model, BigVGAN) on a mono signal.

Limitations

  • Large shifts still sound robotic; for small shifts Rubber Band is better.
  • Trained on shifts up to 6 semitones; beyond that it is extrapolating.
  • One voice at a time. For songs, separate the vocal first (the repository uses Demucs).
  • Works at 22.05 kHz up to 8 kHz; the repository takes the band above 8 kHz from WORLD.
  • On Apple Silicon, model.py uses a Metal-only activation kernel, so run it on mps, not cpu.

License

CC BY-NC-SA 4.0: non-commercial use only, and derivatives under the same terms. The weights are trained on GTSinger, which is CC BY-NC-SA 4.0. VCTK is CC BY 4.0; for OpenSinger see the dataset's own terms. BigVGAN, CREPE and WORLD are separate projects under their own licences and are not included here.

Downloads last month
43
Safetensors
Model size
25.4M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train AlexAlexBabarika/SelfSupervised-Pitch-Shifter