fffiloni commited on
Commit
faf8c97
·
verified ·
1 Parent(s): 470d848

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -101,6 +101,9 @@ def infer_img2img(prompt, audio_path, progress=gr.Progress(track_tqdm=True)):
101
  # Ensure correct shape
102
  concat_audio = concat_audio.flatten() # Converts (1, N) → (N,)
103
 
 
 
 
104
  # Save as WAV
105
  sf.write("output.wav", concat_audio, 16000)
106
 
 
101
  # Ensure correct shape
102
  concat_audio = concat_audio.flatten() # Converts (1, N) → (N,)
103
 
104
+ # Normalize the audio to prevent clipping or excessive loudness
105
+ concat_audio = concat_audio / np.max(np.abs(concat_audio)) # Scale between -1 and 1
106
+
107
  # Save as WAV
108
  sf.write("output.wav", concat_audio, 16000)
109