New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

python-stretch

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-stretch

Simple python library for pitch shifting and time stretching

  • 0.3.1
  • PyPI
  • Socket score

Maintainers
1

python-stretch: pitch shifting and time stretching

License: MIT Supported Platforms Pip Action Status Pip Action Status

A simple Python Wrapper of the Signalsmith Stretch C++ library for pitch and time stretching.

Features

  • Time stretching
  • Pitch shifting
  • Multichannel support: Works with mono and multichannel audio files.
  • Seamless integration: Works natively with NumPy arrays for compatibility with libraries such as librosa and many others used in audio processing pipelines.

Installation

python-stretch is available in PyPI (via Platform Wheels):

pip install python-stretch

Alternatevly, you can easly build it from source (You need a c++ compiler and cmake).

# Clone from github
git clone --recurse-submodules https://github.com/gregogiudici/python-stretch.git
# Install
pip install ./python-stretch

Examples

Quick Start

import numpy as np
import librosa
import python_stretch as ps

# Load an audio example from librosa (e.g., 'trumpet', 'brahms',...)
audio, sr = librosa.load(librosa.ex('trumpet'), sr=None)

# Assure that "audio" is a 2d array
if (audio.ndim == 1):
    audio = audio[np.newaxis, :]

# Create a Stretch object
stretch = ps.Signalsmith.Stretch()
# Configure using a preset
stretch.preset(audio.shape[0], sr) # numChannels, sampleRate
# Shift up by one octave
stretch.setTransposeSemitones(12)
# Stretch time
stretch.timeFactor = 0.75

# Process
audio_processed = stretch.process(audio)

# Save and listen
import soundfile as sf
sf.write("audio_original.wav", np.squeeze(audio), sr)
sf.write("audio_processed.wav", np.squeeze(audio_processed), sr)

Acknowledgements

  • Signalsmith Stretch: python-stretch is built on top of the Signalsmith Stretch C++ library, which provides the core algorithms for time stretching and pitch shifting.
  • nanobind: This project utilizes nanobind for easily binding the C++ code to Python.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc