Created
October 24, 2019 00:51
-
-
Save coltenkrauter/50d088c516d78527696682d60379fdf2 to your computer and use it in GitHub Desktop.
Python code for normalizing audio files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credit: https://stackoverflow.com/questions/42492246/how-to-normalize-the-volume-of-an-audio-file-in-python-any-packages-currently-a#answer-42496373 | |
# pip install pydub | |
from pydub import AudioSegment | |
def match_target_amplitude(sound, target_dBFS): | |
change_in_dBFS = target_dBFS - sound.dBFS | |
return sound.apply_gain(change_in_dBFS) | |
sound = AudioSegment.from_file("yourAudio.m4a", "m4a") | |
normalized_sound = match_target_amplitude(sound, -20.0) | |
normalized_sound.export("nomrmalizedAudio.m4a", format="mp4") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment