The application I used to export my edited audio was normalizing the audio which I don’t want. I have the original audio that doesn’t have normalization, and the new audio that has some parts shifted around to match video timing but is normalized by the application.
Is it possible to reverse the normalization using the original audio file? Technically it should be trivial to detect the peaks of each file to calculate the scaling factor, right?
This code should do that:
def adjust_volume(original_path, normalized_path, output_path):
# Load the original and normalized audio
original_audio = AudioSegment.from_file(original_path)
normalized_audio = AudioSegment.from_file(normalized_path)
# Calculate the difference in dBFS
db_difference = original_audio.dBFS - normalized_audio.dBFS
# Adjust normalized audio
adjusted_audio = normalized_audio + db_difference
# Export the adjusted audio
adjusted_audio.export(output_path, format='wav')
As you can see the top parts are aligned but the bottom parts do not. Is it because I need to scale above the center line using a different factor vs below the center line?