Update app.py
Browse files
app.py
CHANGED
@@ -51,6 +51,8 @@ model_name = 'hackathon-pln-es/poem-gen-spanish-t5-small'
|
|
51 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
52 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
53 |
|
|
|
|
|
54 |
def make_poem(author, sentiment, words, text):
|
55 |
num_lines=5
|
56 |
poem = text
|
@@ -83,7 +85,8 @@ def make_poem(author, sentiment, words, text):
|
|
83 |
|
84 |
pre_output = pre_output.replace('.', ' ')
|
85 |
poem += '\n' + pre_output
|
86 |
-
|
|
|
87 |
|
88 |
iface = gr.Interface(
|
89 |
fn=make_poem,
|
@@ -94,7 +97,7 @@ iface = gr.Interface(
|
|
94 |
gr.inputs.Textbox(lines=1, placeholder='palabra_1, palabra_2, ..., palabra_n', label='Palabras que desea incluir'),
|
95 |
gr.inputs.Textbox(lines=4, placeholder='texto inicial', label='Texto inicial'),
|
96 |
],
|
97 |
-
outputs="text",
|
98 |
examples=
|
99 |
[
|
100 |
['Pablo Neruda', 'positivo', 'cielo, luna, mar', 'Todos fueron a verle pasar']
|
|
|
51 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
52 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
53 |
|
54 |
+
tts_es = gr.Interface.load("huggingface/facebook/tts_transformer-es-css10")
|
55 |
+
|
56 |
def make_poem(author, sentiment, words, text):
|
57 |
num_lines=5
|
58 |
poem = text
|
|
|
85 |
|
86 |
pre_output = pre_output.replace('.', ' ')
|
87 |
poem += '\n' + pre_output
|
88 |
+
audio = tts_es(poem)
|
89 |
+
return poem, audio
|
90 |
|
91 |
iface = gr.Interface(
|
92 |
fn=make_poem,
|
|
|
97 |
gr.inputs.Textbox(lines=1, placeholder='palabra_1, palabra_2, ..., palabra_n', label='Palabras que desea incluir'),
|
98 |
gr.inputs.Textbox(lines=4, placeholder='texto inicial', label='Texto inicial'),
|
99 |
],
|
100 |
+
outputs=["text", "audio"],
|
101 |
examples=
|
102 |
[
|
103 |
['Pablo Neruda', 'positivo', 'cielo, luna, mar', 'Todos fueron a verle pasar']
|