ysharma's picture
ysharma HF staff
update
30c1c6f
raw
history blame
2.08 kB
import gradio as gr
fastspeech = gr.Interface.load("huggingface/facebook/fastspeech2-en-ljspeech")
def text2speech(text):
return fastspeech(text)
def engine(text_input):
ner = gr.Interface.load("huggingface/flair/ner-english-ontonotes-large")
entities = ner(text_input)
entities = [tupl for tupl in entities if None not in tupl]
entities_num = len(entities)
img_intfc = gr.Interface.load("spaces/multimodalart/latentdiffusion", inputs=[gr.inputs.Textbox(default='George'), gr.inputs.Textbox(default='50'), gr.inputs.Textbox(default='256'), gr.inputs.Textbox(default='256'), gr.inputs.Textbox(default='1'), gr.inputs.Textbox(default='10'),],
outputs=[gr.outputs.Image(type="pil", label="output image"),],
title="Convert text to image")
img = img_intfc('George')
#inputs=['George',50,256,256,1,10]
#run(prompt, steps, width, height, images, scale)
speech = text2speech(text_input)
return entities, speech, img
app = gr.Interface(fn=engine,
inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
#live=True,
description="Takes a text as input and reads it out to you.",
outputs=[gr.outputs.Textbox(type="auto", label="Text"), gr.outputs.Audio(type="file", label="Speech Answer"),
gr.outputs.Image(type="pil", label="output image")],
examples=["On April 17th Sunday George celebrated Easter. He is staying at Empire State building with his parents. He is a citizen of Canada and speaks English and French fluently. His role model is former president Obama. He got 1000 dollar from his mother to visit Disney World and to buy new iPhone mobile. George likes watching Game of Thrones."]
).launch(debug=True)
#get_audio = gr.Button("generate audio")
#get_audio.click(text2speech, inputs=text, outputs=speech)
#def greet(name):
# return "Hello " + name + "!!"
#iface = gr.Interface(fn=greet, inputs="text", outputs="text")
#iface.launch()