Update app.py
Browse files
app.py
CHANGED
|
@@ -12,23 +12,40 @@ def texto_a_sentimiento(texto):
|
|
| 12 |
return sentimiento
|
| 13 |
demo = gr.Blocks()
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
with demo:
|
| 16 |
gr.Markdown("## Transcribe audio2text and sentimental classification - Spanish")
|
| 17 |
with gr.Tabs():
|
| 18 |
with gr.TabItem("Transcribe"):
|
| 19 |
with gr.Row():
|
| 20 |
audio_input = gr.Audio(sources=["microphone"], type="filepath")
|
| 21 |
-
texto_output = gr.Textbox()
|
|
|
|
|
|
|
| 22 |
with gr.Row():
|
| 23 |
b1 = gr.Button("Transcribe 🎙️✍🏻")
|
| 24 |
with gr.TabItem("Sentimental Classification"):
|
| 25 |
with gr.Row():
|
| 26 |
-
texto_input = gr.Textbox()
|
|
|
|
| 27 |
sentimiento_output = gr.Label()
|
| 28 |
with gr.Row():
|
| 29 |
b2 = gr.Button("Sentimental Classification 🤖")
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
b1.click(audio_a_texto, inputs=audio_input, outputs=texto_output)
|
| 32 |
-
b2.click(texto_a_sentimiento, inputs=
|
| 33 |
|
| 34 |
demo.launch()
|
|
|
|
| 12 |
return sentimiento
|
| 13 |
demo = gr.Blocks()
|
| 14 |
|
| 15 |
+
shared_text = ""
|
| 16 |
+
|
| 17 |
+
def update_text(text):
|
| 18 |
+
global shared_text
|
| 19 |
+
shared_text = text
|
| 20 |
+
return text
|
| 21 |
+
|
| 22 |
+
def get_shared_text():
|
| 23 |
+
return shared_text
|
| 24 |
+
|
| 25 |
with demo:
|
| 26 |
gr.Markdown("## Transcribe audio2text and sentimental classification - Spanish")
|
| 27 |
with gr.Tabs():
|
| 28 |
with gr.TabItem("Transcribe"):
|
| 29 |
with gr.Row():
|
| 30 |
audio_input = gr.Audio(sources=["microphone"], type="filepath")
|
| 31 |
+
texto_output = gr.Textbox(label="Audio to text", value=shared_text)
|
| 32 |
+
texto_output.change(fn=update_text, inputs=texto_output, outputs=texto_output)
|
| 33 |
+
|
| 34 |
with gr.Row():
|
| 35 |
b1 = gr.Button("Transcribe 🎙️✍🏻")
|
| 36 |
with gr.TabItem("Sentimental Classification"):
|
| 37 |
with gr.Row():
|
| 38 |
+
texto_input = gr.Textbox(label="Audio to text", value=shared_text)
|
| 39 |
+
texto_input.change(fn=update_text, inputs=texto_input, outputs=texto_input)
|
| 40 |
sentimiento_output = gr.Label()
|
| 41 |
with gr.Row():
|
| 42 |
b2 = gr.Button("Sentimental Classification 🤖")
|
| 43 |
|
| 44 |
+
# Keep the 2 text box with the same text.
|
| 45 |
+
texto_input.change(fn=get_shared_text, inputs=None, outputs=texto_input)
|
| 46 |
+
texto_output.change(fn=get_shared_text, inputs=None, outputs=texto_output)
|
| 47 |
+
|
| 48 |
b1.click(audio_a_texto, inputs=audio_input, outputs=texto_output)
|
| 49 |
+
b2.click(texto_a_sentimiento, inputs=texto_input, outputs=sentimiento_output)
|
| 50 |
|
| 51 |
demo.launch()
|