Update app.py
Browse files
app.py
CHANGED
@@ -42,15 +42,21 @@ def generate_audio(text, model_id):
|
|
42 |
num_speakers = pipe_dict["pipe"].model.config.num_speakers
|
43 |
|
44 |
out = []
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
out.append(output)
|
52 |
-
|
53 |
-
out.extend([gr.Audio(visible=False)]*(max_speakers-num_speakers))
|
54 |
return out
|
55 |
|
56 |
|
|
|
42 |
num_speakers = pipe_dict["pipe"].model.config.num_speakers
|
43 |
|
44 |
out = []
|
45 |
+
if num_speakers>1:
|
46 |
+
for i in range(min(num_speakers, max_speakers)):
|
47 |
+
forward_params = {"speaker_id": i}
|
48 |
+
output = pipe_dict["pipe"](text, forward_params=forward_params)
|
49 |
+
|
50 |
+
output = gr.Audio(value = (output["sampling_rate"], output["audio"].squeeze()), type="numpy", autoplay=False, label=f"Generated Audio - speaker {i}", show_label=True,
|
51 |
+
visible=True)
|
52 |
+
out.append(output)
|
53 |
+
out.extend([gr.Audio(visible=False)]*(max_speakers-num_speakers))
|
54 |
+
else:
|
55 |
+
output = pipe_dict["pipe"](text)
|
56 |
+
output = gr.Audio(value = (output["sampling_rate"], output["audio"].squeeze()), type="numpy", autoplay=False, label="Generated Audio - Mono speaker", show_label=True,
|
57 |
+
visible=True)
|
58 |
out.append(output)
|
59 |
+
out.extend([gr.Audio(visible=False)]*(max_speakers-1))
|
|
|
60 |
return out
|
61 |
|
62 |
|