Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 549 Bytes
d40e945 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import uuid
import soundfile as sf
import pydub
import pyloudnorm as pyln
def match_target_amplitude(sound, target_dBFS):
change_in_dBFS = target_dBFS - sound.dBFS
return sound.apply_gain(change_in_dBFS)
def mkuuid(uid):
if not uid:
uid = uuid.uuid4()
return uid
def doloudnorm(path):
data, rate = sf.read(path)
meter = pyln.Meter(rate)
loudness = meter.integrated_loudness(data)
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
sf.write(path, loudness_normalized_audio, rate) |