Update app.py
Browse files
app.py
CHANGED
@@ -106,7 +106,7 @@ codec_model.eval()
|
|
106 |
# vocal_decoder.eval()
|
107 |
# inst_decoder.eval()
|
108 |
|
109 |
-
|
110 |
def generate_music(
|
111 |
max_new_tokens=5,
|
112 |
run_n_segments=2,
|
@@ -296,13 +296,22 @@ def generate_music(
|
|
296 |
vocal_sr = 16000
|
297 |
instrumental_sr = 16000
|
298 |
mixed_sr = 16000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
print("All process Done")
|
301 |
|
302 |
return (mixed_sr, mixed_waveform.numpy()), (vocal_sr, decoded_vocals_waveform.numpy()), (instrumental_sr, decoded_instrumentals_waveform.numpy())
|
303 |
|
304 |
-
|
305 |
-
@spaces.GPU(duration=120)
|
306 |
def infer(genre_txt_content, lyrics_txt_content, num_segments=2, max_new_tokens=15):
|
307 |
# Execute the command
|
308 |
try:
|
|
|
106 |
# vocal_decoder.eval()
|
107 |
# inst_decoder.eval()
|
108 |
|
109 |
+
@spaces.GPU(duration=120)
|
110 |
def generate_music(
|
111 |
max_new_tokens=5,
|
112 |
run_n_segments=2,
|
|
|
296 |
vocal_sr = 16000
|
297 |
instrumental_sr = 16000
|
298 |
mixed_sr = 16000
|
299 |
+
|
300 |
+
# added scaling to the audio
|
301 |
+
limit = 0.99
|
302 |
+
max_val = np.max(np.abs(mixed_waveform))
|
303 |
+
mixed_waveform = mixed_waveform * min(limit / max_val, 1)
|
304 |
+
|
305 |
+
max_val = np.max(np.abs(decoded_vocals_waveform))
|
306 |
+
decoded_vocals_waveform = decoded_vocals_waveform * min(limit/ max_val, 1)
|
307 |
+
|
308 |
+
max_val = np.max(np.abs(decoded_instrumentals_waveform))
|
309 |
+
decoded_instrumentals_waveform = decoded_instrumentals_waveform * min(limit/max_val,1)
|
310 |
|
311 |
print("All process Done")
|
312 |
|
313 |
return (mixed_sr, mixed_waveform.numpy()), (vocal_sr, decoded_vocals_waveform.numpy()), (instrumental_sr, decoded_instrumentals_waveform.numpy())
|
314 |
|
|
|
|
|
315 |
def infer(genre_txt_content, lyrics_txt_content, num_segments=2, max_new_tokens=15):
|
316 |
# Execute the command
|
317 |
try:
|