Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to normalize the volume of an audio file in python?

I have a bunch of AAC (.m4a) audio files that need to be normalized, and was hoping to find a way to do it with a simple python script using some package.

I found this thread on superuser where someone has written an ffmpeg command-line utility in python, and it works well, but was wondering if there is some currently available python package with a pip install that would be up to the task.

like image 277
Luke Davis Avatar asked Feb 27 '17 17:02

Luke Davis


People also ask

Should I normalize a audio file?

Normalizing audio is an effective strategy for making samples, and vocal takes more consistent in volume before/during mixing and even as a method for mastering to bring a group of final music, podcast, or television mixes up to a consistent level.


1 Answers

from pydub import AudioSegment, effects  

rawsound = AudioSegment.from_file("./input.m4a", "m4a")  
normalizedsound = effects.normalize(rawsound)  
normalizedsound.export("./output.wav", format="wav")

Before:

Before image

After:

After image

like image 198
WeiJian Yen Avatar answered Oct 11 '22 11:10

WeiJian Yen