0
$\begingroup$

I have many audio files @ 22kHz. I want to convert it to 44.1kHz. Since I have many files to convert, I am looking for an easy solution. I came across ffmpegwrapper for python. I installed the package for python. But I couldnt find out the command to resample. Can anyone please help me ? This is the link for the wrapper. https://pypi.python.org/pypi/ffmpegwrapper

$\endgroup$

2 Answers 2

1
$\begingroup$

Use SoX to easily convert your files in one go.

Here are some examples:

Alternatively, if you want to do this from Python, use librosa. An example:

By default, librosa will resample the signal to 22050Hz.

You can change this behavior by saying:

librosa.load(audio_path, sr=44100)
to resample at 44.1KHz, or

librosa.load(audio_path, sr=None)
to disable resampling.
$\endgroup$
0
1
$\begingroup$

For complete guide visit this answer (https://stackoverflow.com/a/73891617/14627589)

You can use ffmpeg tool to resample audios. For this, you must have ffmpeg in your environment path variable. You can download ffmpeg for your OS from the given link:

https://ffmpeg.org/download.html

After that extract it and add it to environment variable. Then, use the following Python code to resample:

import os

source_file = "path/to/input/file/with/extension"
output_file = "path/to/output/file/with/extension"
cmd_str = f"ffmpeg -i {source_file} -ac 1 -ar 44000 {output_file}"
print(cmd_str)
os.system(cmd_str)

I have used this code for my projects and it is working perfect. Replace 44000 with your desired sample rate.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.