{"id":13618784,"url":"https://github.com/marl/pysox","last_synced_at":"2026-03-14T00:06:27.300Z","repository":{"id":9040849,"uuid":"57714220","full_name":"marl/pysox","owner":"marl","description":"Python wrapper around sox.","archived":false,"fork":false,"pushed_at":"2024-06-16T22:31:15.000Z","size":4300,"stargazers_count":517,"open_issues_count":35,"forks_count":80,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-29T21:10:38.203Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marl.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":"2016-05-01T18:06:38.000Z","updated_at":"2024-10-25T03:49:12.000Z","dependencies_parsed_at":"2024-03-08T16:24:48.905Z","dependency_job_id":"3d2fd447-e7ac-4e90-a655-0be19d425725","html_url":"https://github.com/marl/pysox","commit_stats":{"total_commits":212,"total_committers":17,"mean_commits":"12.470588235294118","dds":0.2264150943396226,"last_synced_commit":"0a428b88f76c41e93eecbf49bb27b97c7b3f9de7"},"previous_names":["rabitt/pysox"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marl%2Fpysox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marl%2Fpysox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marl%2Fpysox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marl%2Fpysox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marl","download_url":"https://codeload.github.com/marl/pysox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247141587,"owners_count":20890650,"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":[],"created_at":"2024-08-01T21:00:30.493Z","updated_at":"2025-12-15T18:39:59.013Z","avatar_url":"https://github.com/marl.png","language":"Python","readme":"# pysox\nPython wrapper around sox. [Read the Docs here](http://pysox.readthedocs.org).\n\n[![PyPI version](https://badge.fury.io/py/sox.svg)](https://badge.fury.io/py/sox)\n[![Documentation Status](https://readthedocs.org/projects/pysox/badge/?version=latest)](https://pysox.readthedocs.io/en/latest/?badge=latest)\n[![GitHub license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://raw.githubusercontent.com/rabitt/pysox/master/LICENSE.md)\n[![PyPI](https://img.shields.io/pypi/pyversions/Django.svg?maxAge=2592000)]()\n\n[![Build Status](https://travis-ci.org/rabitt/pysox.svg?branch=master)](https://travis-ci.org/rabitt/pysox)\n[![Coverage Status](https://coveralls.io/repos/github/rabitt/pysox/badge.svg?branch=master)](https://coveralls.io/github/rabitt/pysox?branch=master)\n\n![PySocks](https://s-media-cache-ak0.pinimg.com/736x/62/6f/bc/626fbcae9618eccee1c4c7c947bf9d94.jpg)\n\nThis library was presented in the following paper:\n\n[R. M. Bittner](https://github.com/rabitt), [E. J. Humphrey](https://github.com/ejhumphrey) and J. P. Bello, \"[pysox: Leveraging the Audio Signal Processing Power of SoX in Python](https://wp.nyu.edu/ismir2016/wp-content/uploads/sites/2294/2016/08/bittner-pysox.pdf)\", in Proceedings of the 17th International Society for Music Information Retrieval Conference Late Breaking and Demo Papers, New York City, USA, Aug. 2016.\n\n\n# Install\n\nThis requires that [SoX](http://sox.sourceforge.net/) version 14.4.2 or higher is installed.\n\nTo install SoX on Mac with Homebrew:\n\n```brew install sox```\n\nIf you want support for `mp3`, `flac`, or `ogg` files, add the following flags:\n\n```brew install sox --with-lame --with-flac --with-libvorbis```\n\non Linux:\n\n```apt-get install sox```\n\nor install [from source](https://sourceforge.net/projects/sox/files/sox/).\n\n\n\nTo install the most up-to-date release of this module via PyPi:\n\n```pip install sox```\n\nTo install the master branch:\n\n```pip install git+https://github.com/rabitt/pysox.git```\n\nor\n\n```\ngit clone https://github.com/rabitt/pysox.git\ncd pysox\npython setup.py install\n```\n\n\n# Tests\n\nIf you have a different version of SoX installed, it's recommended that you run\nthe tests locally to make sure everything behaves as expected, by simply running:\n\n```\npytest\n```\n\n# Examples\n\n```python\nimport sox\n# create transformer\ntfm = sox.Transformer()\n# trim the audio between 5 and 10.5 seconds.\ntfm.trim(5, 10.5)\n# apply compression\ntfm.compand()\n# apply a fade in and fade out\ntfm.fade(fade_in_len=1.0, fade_out_len=0.5)\n# create an output file.\ntfm.build_file('path/to/input_audio.wav', 'path/to/output/audio.aiff')\n# or equivalently using the legacy API\ntfm.build('path/to/input_audio.wav', 'path/to/output/audio.aiff')\n# get the output in-memory as a numpy array\n# by default the sample rate will be the same as the input file\narray_out = tfm.build_array(input_filepath='path/to/input_audio.wav')\n# see the applied effects\ntfm.effects_log\n\u003e ['trim', 'compand', 'fade']\n\n```\n\nTransform in-memory arrays:\n```python\nimport numpy as np\nimport sox\n# sample rate in Hz\nsample_rate = 44100\n# generate a 1-second sine tone at 440 Hz\ny = np.sin(2 * np.pi * 440.0 * np.arange(sample_rate * 1.0) / sample_rate)\n# create a transformer\ntfm = sox.Transformer()\n# shift the pitch up by 2 semitones\ntfm.pitch(2)\n# transform an in-memory array and return an array\ny_out = tfm.build_array(input_array=y, sample_rate_in=sample_rate)\n# instead, save output to a file\ntfm.build_file(\n    input_array=y, sample_rate_in=sample_rate,\n    output_filepath='path/to/output.wav'\n)\n# create an output file with a different sample rate\ntfm.set_output_format(rate=8000)\ntfm.build_file(\n    input_array=y, sample_rate_in=sample_rate,\n    output_filepath='path/to/output_8k.wav'\n)\n```\n\nConcatenate 3 audio files:\n```python\nimport sox\n# create combiner\ncbn = sox.Combiner()\n# pitch shift combined audio up 3 semitones\ncbn.pitch(3.0)\n# convert output to 8000 Hz stereo\ncbn.convert(samplerate=8000, n_channels=2)\n# create the output file\ncbn.build(\n    ['input1.wav', 'input2.wav', 'input3.wav'], 'output.wav', 'concatenate'\n)\n# the combiner does not currently support array input/output\n```\n\nGet file information:\n```python\nimport sox\n# get the sample rate\nsample_rate = sox.file_info.sample_rate('path/to/file.mp3')\n# get the number of samples\nn_samples = sox.file_info.num_samples('path/to/file.wav')\n# determine if a file is silent\nis_silent = sox.file_info.silent('path/to/file.aiff')\n# file info doesn't currently support array input\n```\n","funding_links":[],"categories":["Audio Manipulation"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarl%2Fpysox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarl%2Fpysox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarl%2Fpysox/lists"}