简体   繁体   中英

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.

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM