Commit ·
42c394e
1
Parent(s): def1f31
handler change0
Browse files- handler.py +8 -7
handler.py
CHANGED
|
@@ -27,12 +27,13 @@ class EndpointHandler:
|
|
| 27 |
|
| 28 |
self.model.set_generation_params(duration=duration)
|
| 29 |
outputs = self.model.generate(inputs)
|
| 30 |
-
prediction = outputs[0].cpu().numpy()
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
return {"generated_audio_file": output_file_path}
|
|
|
|
| 27 |
|
| 28 |
self.model.set_generation_params(duration=duration)
|
| 29 |
outputs = self.model.generate(inputs)
|
|
|
|
| 30 |
|
| 31 |
+
# Save each generated audio file with loudness normalization
|
| 32 |
+
output_files = []
|
| 33 |
+
for idx, one_wav in enumerate(outputs):
|
| 34 |
+
output_file_path = f"generated_audio_{idx}.wav"
|
| 35 |
+
audio_write(output_file_path, one_wav.cpu(), self.model.sample_rate, strategy="loudness", loudness_compressor=True)
|
| 36 |
+
output_files.append(output_file_path)
|
| 37 |
|
| 38 |
+
return {"generated_audio_files": output_files}
|
| 39 |
+
|
|
|
|
|
|