Giter Site home page Giter Site logo

speedup.py's Introduction

speedup.py

A simple Python module to speed up (or slow down) audio. It also comes with a commandline interface and a Flask server.

Installation

To install speedup.py run:

pip install speedup.py

The speedup.py module has optional dependencies required for the CLI and API modules. Run one of the three lines below to:

pip install speedup.py[cli]			# Only install CLI dependencies
pip install speecup.py[server]		# Only install server dependencies
pip install speedup.py[cli,server]	# Install dependencies for both

Usage

Assuming you have soundfile for reading in audio files, speeding up audio from a file called audio.mp3 by a factor of 1.5 takes four lines of Python code:

from speedup import speedup
import soundfile as sf
audio, samplerate = sf.read("audio.mp3")
spedup_audio = speedup(audio, 1.5)

The speedup function returns the sped up audio as a NumPy array, which you can then save to a file like so:

sf.write("spedup-audio.mp3", spedup_audio, samplerate)

CLI usage

The CLI abstracts everything in the previous section away.

To speed up audio.mp3 by a factor of 1.5, run:

speedup audio.mp3 1.5

Despite the project's name, multipliers below 1 work as well. The audio will be slowed down in this case:

speedup audio.mp3 0.75

In this case, the sped up audio is saved to audio-1.5x.mp3 by default. You can specify the output file using --output-file:

speedup audio.mp3 1.5 --output-file spedup.mp3

Since the resample operation takes some time, the --play option lets you hear your spedup audio without resampling:

speedup audio.mp3 1.5 --play

Using --play prevents saving the audio to a file, since the exact same file would be created, except the sample rate would be multiplied. This is because compressed audio formats (especially MPEG-3) don't support custom sample rates.

The --output-file and --play options are mutually exclusive.

Running the Flask server

You can run the Flask development server with:

python -m speedup.api

For production environments however, you should use a WSGI server like gunicorn:

pip install gunicorn
gunicorn -w 4 speedup.api:app

Building

To build the Python package, run the below commands in your terminal:

git clone https://github.com/trustytrojan/speedup.py
cd speedup.py
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m build

speedup.py's People

Contributors

trustytrojan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.