testtts / app.py
siya02's picture
Update app.py
441e6b7
# # import gradio as gr
# def my_function(name):
# return "Hello " + name + "!!"
# # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
# # iface.launch()
# import gradio as gr
# import requests
# # Create a Gradio app.
# app = gr.Interface(fn=my_function, inputs=['text'], outputs=['text'])
# # Get the URL of the Gradio app.
# url = app.launch()
# # Make a POST request to the URL of the Gradio app.
# data = {'text': 'This is a test.'}
# response = requests.post(url, data=data)
# # The response to the POST request will be the output of the Gradio app.
# output = response.json()['text']
# import gradio as gr
# import requests
# def my_function(name):
# return "Hello " + name + "!!"
# # Create a Gradio app.
# app = gr.Interface(fn=my_function, inputs=['text'], outputs=['text'], allow_external_requests=True)
# # Launch the Gradio app.
# app.launch()
# # Make a GET request to the URL of the Gradio app.
# data = {'text': 'This is a test.'}
# response = requests.get(app.url, data=data)
# # The response to the GET request will be a JSON object.
# output = response.json()['output']
# # The input that you entered will be in the `input` key of the JSON object.
# input = response.json()['input']
# # Print the output and input.
# print(output)
# print(input)
import gradio
# Create a Gradio app.
interface = gradio.Interface(
fn=predict,
inputs=[gradio.inputs.Textbox()],
outputs=[gradio.outputs.Text()],
)
# Add a `predict()` method to the Gradio app.
def predict(name):
return "Hello " + name + "!!"
# Use the model to predict the output.
output = model(text)
# Return the output.
return output
# Save the Gradio app.
interface.save("my_app")
# Deploy the Gradio app.
interface.deploy()
# Create a post API endpoint.
interface.create_post_api()