Skip to main content

No project description provided

Project description

Torch Pitch Shift

Pitch-shift audio clips quickly with PyTorch (CUDA Supported)!

View on PyPI

Publish to PyPI

About

This library can pitch-shift audio clips quickly to using PyTorch. For any given sample rate, the library calculates pitch-shift ratios that can be run extremely fast.

Installation

pip install torch_pitch_shift

Usage

Example:

# import the libs
import torch
from torch_pitch_shift import *

# create a random sample
SAMPLE_RATE = 16000
NUM_SECONDS = 2
sample = torch.rand(2, SAMPLE_RATE * NUM_SECONDS)

# construct the pitch shifter (limit to between -1 and +1 octaves)
pitch_shift = PitchShifter(SAMPLE_RATE, lambda x: (x <= 2 and x >= 0.5))

for ratio in pitch_shift.fast_shifts:
    shifted = pitch_shift(sample, ratio)
    print(f"Ratio {ratio}:", shifted.shape)

Output:

Ratio 1/2: torch.Size([2, 32000])
Ratio 1: torch.Size([2, 32000])
Ratio 2: torch.Size([2, 32000])
Ratio 5/4: torch.Size([2, 32000])
Ratio 5/8: torch.Size([2, 32000])
Ratio 25/16: torch.Size([2, 32000])
Ratio 25/32: torch.Size([2, 32000])
Ratio 4/5: torch.Size([2, 32000])
Ratio 125/64: torch.Size([2, 32000])
Ratio 125/128: torch.Size([2, 32000])
Ratio 64/125: torch.Size([2, 32000])
Ratio 128/125: torch.Size([2, 32000])
Ratio 8/5: torch.Size([2, 32000])
Ratio 32/25: torch.Size([2, 32000])
Ratio 16/25: torch.Size([2, 32000])

Documentation

Documentation is built into the class and function docstrings. If anyone wants to properly document the package, please feel free to contribute!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torch_pitch_shift-1.0.5.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

torch_pitch_shift-1.0.5-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page