Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
-
import urllib.request
|
3 |
import requests
|
4 |
-
|
|
|
5 |
|
6 |
def function1(prompt):
|
7 |
response = requests.post("https://matthijs-speecht5-tts-demo.hf.space/run/predict", json={
|
@@ -12,8 +12,11 @@ def function1(prompt):
|
|
12 |
}).json()
|
13 |
data = response["data"][0]["name"]
|
14 |
data = "https://matthijs-speecht5-tts-demo.hf.space/file="+data
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
|
18 |
iface = gr.Interface(fn=function1, inputs="text", outputs="text")
|
19 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import requests
|
3 |
+
import urllib.request
|
4 |
+
from pydub import AudioSegment
|
5 |
|
6 |
def function1(prompt):
|
7 |
response = requests.post("https://matthijs-speecht5-tts-demo.hf.space/run/predict", json={
|
|
|
12 |
}).json()
|
13 |
data = response["data"][0]["name"]
|
14 |
data = "https://matthijs-speecht5-tts-demo.hf.space/file="+data
|
15 |
+
file_name, headers = urllib.request.urlretrieve(data, "speech.wav")
|
16 |
+
sound = AudioSegment.from_wav(file_name)
|
17 |
+
mp3_file = "speech.mp3"
|
18 |
+
sound.export(mp3_file, format="mp3")
|
19 |
+
return mp3_file
|
20 |
|
21 |
iface = gr.Interface(fn=function1, inputs="text", outputs="text")
|
22 |
+
iface.launch()
|