Bruno KM
Bruno KM

Reputation: 768

How to change speed of a wav file while retaining the sampling frequency in Python

I wish to change the speed of an audio file (in the .wav format) by small amounts(±25%). The catch is that I need to retain the previous sample rate of the file. Both solutions involving a change of speed and pitch, and change of speed only (tempo change) are welcome, as ideally I would like to do both separately.

Upvotes: 3

Views: 4204

Answers (1)

filaton
filaton

Reputation: 2326

You can use ffmpeg for that purpose:

ffmpeg -i in.wav -filter:a "atempo=0.5" out.wav

If you want to call it from Python, you can use ffmpy.

import ffmpy
ff = ffmpy.FFmpeg(inputs={"in.wav": None}, outputs={"out.wav": ["-filter:a", "atempo=0.5"]})
ff.run()

Upvotes: 8

Related Questions