Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import uuid
|
|
7 |
from io import StringIO
|
8 |
from io import BytesIO
|
9 |
import base64
|
|
|
10 |
|
11 |
import gradio as gr
|
12 |
import spaces
|
@@ -179,10 +180,12 @@ def predict(
|
|
179 |
# torchaudio.save("output.wav", torch.tensor(out["wav"]).unsqueeze(0), 24000)
|
180 |
torchaudio.save(buffer, torch.tensor(out["wav"]).unsqueeze(0), 24000, format='wav')
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
186 |
|
187 |
except RuntimeError as e:
|
188 |
if "device-side assert" in str(e):
|
@@ -248,7 +251,7 @@ def predict(
|
|
248 |
"Something unexpected happened please retry again."
|
249 |
)
|
250 |
return (None, metrics_text)
|
251 |
-
return ("output.wav", metrics_text,
|
252 |
|
253 |
|
254 |
with gr.Blocks(analytics_enabled=False) as demo:
|
@@ -317,7 +320,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
317 |
with gr.Column():
|
318 |
audio_gr = gr.Audio(label="Synthesised Audio", autoplay=True)
|
319 |
out_text_gr = gr.Text(label="Metrics")
|
320 |
-
|
321 |
|
322 |
tts_button.click(
|
323 |
predict,
|
@@ -327,7 +330,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
327 |
ref_gr,
|
328 |
normalize_text,
|
329 |
],
|
330 |
-
outputs=[audio_gr, out_text_gr,
|
331 |
api_name="predict",
|
332 |
)
|
333 |
|
|
|
7 |
from io import StringIO
|
8 |
from io import BytesIO
|
9 |
import base64
|
10 |
+
import requests
|
11 |
|
12 |
import gradio as gr
|
13 |
import spaces
|
|
|
180 |
# torchaudio.save("output.wav", torch.tensor(out["wav"]).unsqueeze(0), 24000)
|
181 |
torchaudio.save(buffer, torch.tensor(out["wav"]).unsqueeze(0), 24000, format='wav')
|
182 |
|
183 |
+
output_path = "output.wav"
|
184 |
+
with open(output_path, "wb") as f:
|
185 |
+
f.write(buffer.getbuffer())
|
186 |
+
|
187 |
+
upload_url = "https://temp.sh/upload"
|
188 |
+
response = requests.post(upload_url, files={"file": open(output_path, "rb")})
|
189 |
|
190 |
except RuntimeError as e:
|
191 |
if "device-side assert" in str(e):
|
|
|
251 |
"Something unexpected happened please retry again."
|
252 |
)
|
253 |
return (None, metrics_text)
|
254 |
+
return ("output.wav", metrics_text, response)
|
255 |
|
256 |
|
257 |
with gr.Blocks(analytics_enabled=False) as demo:
|
|
|
320 |
with gr.Column():
|
321 |
audio_gr = gr.Audio(label="Synthesised Audio", autoplay=True)
|
322 |
out_text_gr = gr.Text(label="Metrics")
|
323 |
+
response = gr.Text(label="temp")
|
324 |
|
325 |
tts_button.click(
|
326 |
predict,
|
|
|
330 |
ref_gr,
|
331 |
normalize_text,
|
332 |
],
|
333 |
+
outputs=[audio_gr, out_text_gr, response],
|
334 |
api_name="predict",
|
335 |
)
|
336 |
|