{"id":15442551,"url":"https://github.com/gregogiudici/python-stretch","last_synced_at":"2025-04-19T19:04:20.158Z","repository":{"id":257789617,"uuid":"859785510","full_name":"gregogiudici/python-stretch","owner":"gregogiudici","description":"Simple python library for pitch shifting and time stretching. Wrapper of Signalsmith Stretch C++ Library","archived":false,"fork":false,"pushed_at":"2025-03-19T11:49:20.000Z","size":18044,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T12:03:00.350Z","etag":null,"topics":["audio","augmentation","nanobind","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/python-stretch/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregogiudici.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-19T09:20:39.000Z","updated_at":"2025-03-19T12:40:16.000Z","dependencies_parsed_at":"2024-12-21T12:27:30.180Z","dependency_job_id":"6a895522-fbab-40e5-8f93-edfc2f537e3b","html_url":"https://github.com/gregogiudici/python-stretch","commit_stats":{"total_commits":56,"total_committers":2,"mean_commits":28.0,"dds":0.1071428571428571,"last_synced_commit":"33ed6ec33b59bdc4ddec424988f1d7e77982f2bb"},"previous_names":["gregogiudici/python-stretch"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregogiudici%2Fpython-stretch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregogiudici%2Fpython-stretch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregogiudici%2Fpython-stretch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregogiudici%2Fpython-stretch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregogiudici","download_url":"https://codeload.github.com/gregogiudici/python-stretch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249239311,"owners_count":21235838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","augmentation","nanobind","python"],"created_at":"2024-10-01T19:28:30.686Z","updated_at":"2025-04-16T12:31:06.183Z","avatar_url":"https://github.com/gregogiudici.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ***python-stretch***: pitch shifting and time stretching\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gregogiudici/python-stretch/blob/main/LICENSE)\n[![Supported Platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Windows%20%7C%20Linux-green)](https://pypi.org/project/python-stretch)\n[![Pip Action Status][actions-pip-badge]][actions-pip-link]\n[![Pip Action Status][actions-wheels-badge]][actions-wheels-link]\n[![PyPI Downloads](https://static.pepy.tech/badge/python-stretch)](https://pepy.tech/projects/python-stretch)\n\n\u003c!-- [![PyPI - Wheel](https://img.shields.io/pypi/wheel/python-stretch)](https://pypi.org/project/python-stretch) --\u003e\n\u003c!-- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/python-stretch)](https://pypi.org/project/python-stretch) --\u003e\n\u003c!-- [![PyPI Downloads](https://static.pepy.tech/badge/python-stretch)](https://pepy.tech/projects/python-stretch) --\u003e\n\n\n\n[actions-pip-link]:        https://github.com/gregogiudici/python-stretch/actions?query=workflow%3APip\n[actions-pip-badge]:       https://github.com/gregogiudici/python-stretch/workflows/Pip/badge.svg\n[actions-wheels-link]:     https://github.com/gregogiudici/python-stretch/actions?query=workflow%3AWheels\n[actions-wheels-badge]:    https://github.com/gregogiudici/python-stretch/workflows/Wheels/badge.svg\n\nA simple Python Wrapper of the Signalsmith Stretch C++ library for pitch and time stretching.\n\n## Features\n\n- **Multichannel support**: Works with mono and multichannel audio files.\n- **Seamless integration**: Works natively with NumPy arrays for compatibility with libraries such as [`librosa`](https://librosa.org/doc/latest/index.html) and many others used in audio processing pipelines.\n- **Backend of Audiomentations**: `python-stretch` is used as the core method for pitch shifting and time stretching in the popular [`audiomentations`](https://github.com/iver56/audiomentations) library since version [0.39.0](https://iver56.github.io/audiomentations/changelog/#:~:text=Semantic%20Versioning.-,0.39.0%20%2D%202025%2D02%2D12,-Changed).\n\n\n\n## Installation\n\n`python-stretch` is available in [PyPI](https://pypi.org/project/python-stretch/) (via [Platform Wheels](https://packaging.python.org/guides/distributing-packages-using-setuptools/#platform-wheels)):\n```\npip install python-stretch\n```\nAlternatevly, you can easly build it from source (You need a c++ compiler and cmake).\n```\n# Clone from github\ngit clone --recurse-submodules https://github.com/gregogiudici/python-stretch.git\n# Install\npip install ./python-stretch\n```\n\n# Examples\n## Quick Start\n```\nimport numpy as np\nimport librosa\nimport python_stretch as ps\n\n# Load an audio example from librosa (e.g., 'trumpet', 'brahms',...)\naudio, sr = librosa.load(librosa.ex('trumpet'), sr=None)\n\n# Assure that \"audio\" is a 2d array\nif (audio.ndim == 1):\n    audio = audio[np.newaxis, :]\n\n# Create a Stretch object\nstretch = ps.Signalsmith.Stretch()\n# Configure using a preset\nstretch.preset(audio.shape[0], sr) # numChannels, sampleRate\n# Shift up by one octave\nstretch.setTransposeSemitones(12)\n# Stretch time\nstretch.timeFactor = 0.75\n\n# Process\naudio_processed = stretch.process(audio)\n\n# Save and listen\nimport soundfile as sf\nsf.write(\"audio_original.wav\", np.squeeze(audio), sr)\nsf.write(\"audio_processed.wav\", np.squeeze(audio_processed), sr)\n```\n\n# Acknowledgements\n- [Signalsmith Stretch](https://github.com/Signalsmith-Audio/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.\n- [nanobind](https://github.com/wjakob/nanobind): This project utilizes `nanobind` for easily binding the C++ code to Python.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregogiudici%2Fpython-stretch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregogiudici%2Fpython-stretch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregogiudici%2Fpython-stretch/lists"}