No project description provided
Project description
Torch Pitch Shift
Pitch-shift audio clips quickly with PyTorch (CUDA Supported)!
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file torch_pitch_shift-1.0.5.tar.gz
.
File metadata
- Download URL: torch_pitch_shift-1.0.5.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74d248c0ff322491c236d764427696f54f878a056b3002bee30da75b758c2783 |
|
MD5 | 3c5fb385d05835320c3739e8cbe7c6f1 |
|
BLAKE2b-256 | 9098d53a25010c68cad3a2565e3130b15108f71445272c378f5f6d8027ae72c0 |
File details
Details for the file torch_pitch_shift-1.0.5-py3-none-any.whl
.
File metadata
- Download URL: torch_pitch_shift-1.0.5-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2e32dc6dbce06fd1ca334b85f6a44282f32be1f85f09121e34883a839ba9737 |
|
MD5 | dd5d42ada53e6754bc533be282d5da10 |
|
BLAKE2b-256 | adf8b7491f0601a0b4672f111b03780e29a17ec2bba78f528784e0041ea9332d |