Code Monkey home page Code Monkey logo

time_stretch's Introduction

Time Stretch

This python script implements stretching or shrinking audio data without changing the pitch. Given an input wav file, it stretches(or shrinks) it and saves to a new output file. The audio is first converted to frequency domain resulting in a short-term fourier transform (STFT). The STFT is then transformed according to The Phase Vocoder algorithm, and ultitmately converted back to time domain. The stretch is controlled by the stretch factor, the new duration being old duration times the stretch factor. The file can also be imported as a library to call the stretch function. The functionality is inside stretch() function. I wrote a loop-less version of this function as stretch_wo_loop() in order boost speed, but it just led to less a readable function without much change is speed. The command line usage for running the script is:

usage: speed up or speed down the audio without changing the pitch
       [-h] -i IN_FILE [-o OUT_FILE] -f FACTOR [-n NFFT]

optional arguments:
  -h, --help            show this help message and exit
  -i IN_FILE, --in-file IN_FILE
                        path to the input wav file
  -o OUT_FILE, --out-file OUT_FILE
                        path of the output file
  -f FACTOR, --factor FACTOR
                        factor by which to shrink or dilate time. if FACTOR <
                        1.0, audio will be sped up, otherwise sped down
  -n NFFT, --nfft NFFT  num of FFT bins to use

time_stretch's People

Contributors

gaganbahga avatar williamwedgwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.