|
|
|
|
@ -19,6 +19,8 @@ for filepath in paths:
|
|
|
|
|
|
|
|
|
|
if (str(filepath) == str(target_filepath)):
|
|
|
|
|
raise ValueError("Source and target path are identical: " + str(target_filepath))
|
|
|
|
|
if (os.path.exists(target_filepath)):
|
|
|
|
|
print(f"Output already exists, skipping {target_filepath}")
|
|
|
|
|
|
|
|
|
|
print("From: " + str(filepath))
|
|
|
|
|
print("To: " + str(target_filepath))
|
|
|
|
|
@ -39,10 +41,13 @@ for filepath in paths:
|
|
|
|
|
|
|
|
|
|
# measure the loudness first
|
|
|
|
|
meter = pyln.Meter(rate) # create BS.1770 meter
|
|
|
|
|
loudness = meter.integrated_loudness(data)
|
|
|
|
|
try:
|
|
|
|
|
loudness = meter.integrated_loudness(data)
|
|
|
|
|
|
|
|
|
|
# loudness normalize audio to -25 dB LUFS
|
|
|
|
|
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -25.0)
|
|
|
|
|
# loudness normalize audio to -25 dB LUFS
|
|
|
|
|
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -25.0)
|
|
|
|
|
except ValueError as e:
|
|
|
|
|
print(f"ValueError: ${str(e)}")
|
|
|
|
|
|
|
|
|
|
sf.write(target_filepath, data=loudness_normalized_audio, samplerate=22050)
|
|
|
|
|
|
|
|
|
|
|