testing45 / app.py
tommy24's picture
Update app.py
10b9a86
raw
history blame
892 Bytes
import gradio as gr
import requests
import urllib.request
from pydub import AudioSegment
def function1(prompt):
response = requests.post("https://tommy24-testing3.hf.space/run/predict", json={
"data": [
prompt,
]}).json()
data = response["data"][0]
response = requests.post("https://matthijs-speecht5-tts-demo.hf.space/run/predict", json={
"data": [
data,
"KSP (male)",
]
}).json()
data = response["data"][0]["name"]
data = "https://matthijs-speecht5-tts-demo.hf.space/file="+data
file_name, headers = urllib.request.urlretrieve(data, "speech.wav")
sound = AudioSegment.from_wav(file_name)
mp3_file = "https://tommy24-testing45.hf.space/file=speech.mp3"
sound.export(mp3_file, format="mp3")
return mp3_file
iface = gr.Interface(fn=function1, inputs="text", outputs="text")
iface.launch()