File size: 1,085 Bytes
2da20b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
from gradio_client import Client
def  get_text_ai(json_input):
     space_text = json_input.get("space_text", "")
     text = json_input.get("text", "")
     key = json_input.get("key", "")
     client = Client(space_text)
     result = client.predict(
            text=text,
            key=key,
            api_name="/predict"
    )
    return result
def  get_url_speech(json_input,text):
      space_speech = json_input.get("space_speech", "")
      model = json_input.get("model", "")
      speaking_rate=json_input.get("speaking_rate", "")
      client = Client(space_speech)
      result = client.predict(
                text=text,
                name_model=model,
                speaking_rate=speaking_rate,
                api_name="/predict"
        )
      return result
def greet(json_input):
    
    res=get_text_ai(json_input)

    if res:
        return  get_url_speech(json_input,res)
        
      
        
    
       

        
    
    
    return '333'

demo = gr.Interface(fn=greet, inputs=gr.inputs.JSON(), outputs="text")
demo.launch()