From 66dbdb16caf968c3cc8e0abd8152a04d9322985d Mon Sep 17 00:00:00 2001 From: Jasper <37783831+jagilley@users.noreply.github.com> Date: Fri, 16 Dec 2022 22:12:39 -0600 Subject: [PATCH] Scale by max value Scale by max value to allow for processing 24- and 32-bit wavs --- riffusion/audio.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/riffusion/audio.py b/riffusion/audio.py index 3710533..323e851 100644 --- a/riffusion/audio.py +++ b/riffusion/audio.py @@ -93,9 +93,12 @@ def image_from_spectrogram( """ # Apply the power curve data = np.power(spectrogram, power_for_image) + + # Rescale to 0-1 + data = data / np.max(data) # Rescale to 0-255 - data = data * 255 / max_volume + data = data * 255 # Invert data = 255 - data