Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -67,6 +67,17 @@ def tts(txt, emotion, roma=False, length_scale=1):
|
|
67 |
else:
|
68 |
print("emotion参数不正确")
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
audio = net_g.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=0.667, noise_scale_w=0.8, length_scale=1.2, emo=emo)[0][0,0].data.float().numpy()
|
71 |
return audio
|
72 |
|
|
|
67 |
else:
|
68 |
print("emotion参数不正确")
|
69 |
|
70 |
+
# Save the numpy array as a temporary file
|
71 |
+
temp_file = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
|
72 |
+
temp_file_path = temp_file.name
|
73 |
+
write(temp_file_path, hps.data.sampling_rate, audio)
|
74 |
+
|
75 |
+
# Display the audio
|
76 |
+
ipd.display(ipd.Audio(temp_file_path, rate=hps.data.sampling_rate, normalize=False))
|
77 |
+
|
78 |
+
# Delete the temporary file
|
79 |
+
os.remove(temp_file_path)
|
80 |
+
|
81 |
audio = net_g.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=0.667, noise_scale_w=0.8, length_scale=1.2, emo=emo)[0][0,0].data.float().numpy()
|
82 |
return audio
|
83 |
|