wgcv commited on
Commit
3da0176
Β·
verified Β·
1 Parent(s): bd10047

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -17
app.py CHANGED
@@ -12,16 +12,6 @@ def texto_a_sentimiento(texto):
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
- global shared_text
24
- return shared_text
25
 
26
  with demo:
27
  gr.Markdown("## Transcribe audio2text and sentimental classification - Spanish")
@@ -29,22 +19,19 @@ with demo:
29
  with gr.TabItem("Transcribe"):
30
  with gr.Row():
31
  audio_input = gr.Audio(sources=["microphone"], type="filepath")
32
- texto_output = gr.Textbox(label="Audio to text", value=shared_text)
33
- texto_output.change(fn=update_text, inputs=texto_output, outputs=texto_output)
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="Text to sentimental", 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
- b1.click(audio_a_texto, inputs=audio_input, outputs=texto_output)
48
  b2.click(texto_a_sentimiento, inputs=texto_input, outputs=sentimiento_output)
49
 
50
  demo.launch()
 
12
  return sentimiento
13
  demo = gr.Blocks()
14
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  with demo:
17
  gr.Markdown("## Transcribe audio2text and sentimental classification - Spanish")
 
19
  with gr.TabItem("Transcribe"):
20
  with gr.Row():
21
  audio_input = gr.Audio(sources=["microphone"], type="filepath")
22
+ texto_output = gr.Textbox(label="Audio to text")
 
23
  with gr.Row():
24
  b1 = gr.Button("Transcribe πŸŽ™οΈβœπŸ»")
25
  with gr.TabItem("Sentimental Classification"):
26
  with gr.Row():
27
+ texto_input = gr.Textbox(label="Text to sentimental")
 
28
  sentimiento_output = gr.Label()
29
  with gr.Row():
30
  b2 = gr.Button("Sentimental Classification πŸ€–")
31
 
32
  # Keep the 2 text box with the same text.
33
+
34
+ b1.click(audio_a_texto, inputs=audio_input, outputs=[texto_output,texto_input])
 
35
  b2.click(texto_a_sentimiento, inputs=texto_input, outputs=sentimiento_output)
36
 
37
  demo.launch()