Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio_client import Client
|
| 3 |
+
def get_text_ai(json_input):
|
| 4 |
+
space_text = json_input.get("space_text", "")
|
| 5 |
+
text = json_input.get("text", "")
|
| 6 |
+
key = json_input.get("key", "")
|
| 7 |
+
client = Client(space_text)
|
| 8 |
+
result = client.predict(
|
| 9 |
+
text=text,
|
| 10 |
+
key=key,
|
| 11 |
+
api_name="/predict"
|
| 12 |
+
)
|
| 13 |
+
return result
|
| 14 |
+
def get_url_speech(json_input,text):
|
| 15 |
+
space_speech = json_input.get("space_speech", "")
|
| 16 |
+
model = json_input.get("model", "")
|
| 17 |
+
speaking_rate=json_input.get("speaking_rate", "")
|
| 18 |
+
client = Client(space_speech)
|
| 19 |
+
result = client.predict(
|
| 20 |
+
text=text,
|
| 21 |
+
name_model=model,
|
| 22 |
+
speaking_rate=speaking_rate,
|
| 23 |
+
api_name="/predict"
|
| 24 |
+
)
|
| 25 |
+
return result
|
| 26 |
+
def greet(json_input):
|
| 27 |
+
|
| 28 |
+
res=get_text_ai(json_input)
|
| 29 |
+
|
| 30 |
+
if res:
|
| 31 |
+
return get_url_speech(json_input,res)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
return '333'
|
| 42 |
+
|
| 43 |
+
demo = gr.Interface(fn=greet, inputs=gr.inputs.JSON(), outputs="text")
|
| 44 |
+
demo.launch()
|