{"id":24658,"library":"stftpitchshift","title":"stftpitchshift","description":"STFT-based pitch and timbre shifting library for audio processing, supporting real-time and file-based transformations. Version 2.0 includes major API changes, improved latency, and WebAssembly support. Released under the MIT license.","status":"active","version":"2.0","language":"python","source_language":"en","source_url":"https://github.com/jurihock/stftPitchShift","tags":["audio","pitch-shift","timbre-shift","stft","dsp"],"install":[{"cmd":"pip install stftpitchshift","lang":"bash","label":"Install from PyPI"},{"cmd":"pip install stftpitchshift[fft]","lang":"bash","label":"Install with custom FFT backend support"}],"dependencies":[{"reason":"Used for array operations in Python implementation","package":"numpy","optional":false},{"reason":"Optional, provides additional FFT backends","package":"scipy","optional":true}],"imports":[{"note":"Main class for pitch shifting","wrong":"","symbol":"PitchShift","correct":"from stftpitchshift import PitchShift"},{"note":"For timbre shifting separately in v2.0","wrong":"from stftpitchshift import TimbreShift (old name was PitchShift with timbre parameter)","symbol":"TimbreShift","correct":"from stftpitchshift import TimbreShift"},{"note":"Use built-in load function for audio files","wrong":"from scipy.io import wavfile","symbol":"load","correct":"from stftpitchshift import load"},{"note":"Use built-in save function for audio files","wrong":"","symbol":"save","correct":"from stftpitchshift import save"}],"quickstart":{"code":"import numpy as np\nfrom stftpitchshift import PitchShift, load, save\n\n# Load audio (mono, float32)\naudio, samplerate = load('input.wav')\n\n# Create pitch shifter with default settings\nshifter = PitchShift()\n\n# Shift pitch by 2 semitones (factor = 2^(2/12) ≈ 1.1225)\nshifted = shifter.shiftpitch(audio, samplerate, 1.1225)\n\n# Save result\nsave('output.wav', samplerate, shifted.astype(np.float32))","lang":"python","description":"Load an audio file, apply pitch shifting, and save the result."},"warnings":[{"fix":"Update code to use `PitchShift().shiftpitch(audio, samplerate, factor)` instead of `stft(...)`.","message":"In v2.0, the API changed: `PitchShift.shiftpitch` replaces the old `stft` method. The timbre shifting is now a separate `TimbreShift` class.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Use `TimbreShift().shifttimbre(audio, samplerate, factor)` for timbre shifting.","message":"In v2.0, the `TimbreShift` class requires explicitly enabling timbre shifting via `shiftpitch` or separate `TimbreShift.shifttimbre`. The old `PitchShift` constructor parameter `timbre` no longer exists.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Convert audio to mono and float32 before processing: `audio = audio.mean(axis=1) if audio.ndim > 1 else audio; audio = audio.astype(np.float32)`.","message":"The input audio must be monaural (single channel) and of type `numpy.float32`. Multi-channel or different dtypes may cause errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the new `PitchShift` and `TimbreShift` classes.","message":"The previous `stft` function and the old import path `from stftpitchshift import stft` are removed in v2.0.","severity":"deprecated","affected_versions":">=2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from stftpitchshift import PitchShift` and call `PitchShift().shiftpitch(...)`.","cause":"The `stft` function was removed in v2.0.","error":"ImportError: cannot import name 'stft' from 'stftpitchshift'"},{"fix":"Ensure audio is mono (`audio.mean(axis=1)`) and convert to float32: `audio = audio.astype(np.float32)`.","cause":"Input audio is not mono or not float32.","error":"ValueError: Audio must be a 1D numpy array of float32"},{"fix":"Replace `shifter.stft(...)` with `shifter.shiftpitch(audio, samplerate, factor)`.","cause":"The `stft` method is removed; use `shiftpitch`.","error":"AttributeError: 'PitchShift' object has no attribute 'stft'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}