Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import requests
|
|
| 3 |
import urllib.request
|
| 4 |
from pydub import AudioSegment
|
| 5 |
import numpy as np
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
def function1(prompt):
|
| 9 |
response = requests.post("https://tommy24-testing3.hf.space/run/predict", json={
|
|
@@ -18,20 +17,9 @@ def function1(prompt):
|
|
| 18 |
]
|
| 19 |
}).json()
|
| 20 |
data = response["data"][0]["name"]
|
| 21 |
-
data = "https://matthijs-speecht5-tts-demo.hf.space/file="
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
sound = AudioSegment.from_wav("speech.wav")
|
| 28 |
-
|
| 29 |
-
# Set the path and file name for the converted MP3 file
|
| 30 |
-
mp3_file = "speech.mp3"
|
| 31 |
-
|
| 32 |
-
# Export the audio in MP3 format
|
| 33 |
-
sound.export(mp3_file, format="mp3")
|
| 34 |
-
|
| 35 |
-
# Return the path to the MP3 file
|
| 36 |
-
return mp3_file
|
| 37 |
-
|
|
|
|
| 3 |
import urllib.request
|
| 4 |
from pydub import AudioSegment
|
| 5 |
import numpy as np
|
|
|
|
| 6 |
|
| 7 |
def function1(prompt):
|
| 8 |
response = requests.post("https://tommy24-testing3.hf.space/run/predict", json={
|
|
|
|
| 17 |
]
|
| 18 |
}).json()
|
| 19 |
data = response["data"][0]["name"]
|
| 20 |
+
data = "https://matthijs-speecht5-tts-demo.hf.space/file="+data
|
| 21 |
+
file_name, headers = urllib.request.urlretrieve(data, "speech.mp3")
|
| 22 |
+
return data
|
| 23 |
+
|
| 24 |
+
iface = gr.Interface(fn=function1, inputs="text", outputs="text")
|
| 25 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|