JoelJebaraj93 commited on
Commit
66b1fe1
·
verified ·
1 Parent(s): 0f988fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -62,9 +62,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
62
  btn_speech = gr.Button("Speech-to-Text")
63
  btn_qgen = gr.Button("Question Generation")
64
 
65
- output_container = gr.Column(visible=False)
66
-
67
- # Tabs
68
  with gr.Column(visible=False) as summarize_tab:
69
  text = gr.Textbox(label="Enter paragraph", lines=10)
70
  out = gr.Textbox(label="Summary", lines=4)
@@ -101,10 +99,23 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
101
  gr.update(visible=(tab_name == "question")),
102
  ]
103
 
104
- btn_summ.click(show_tab, inputs=[gr.Textbox(value="summarize", visible=False)], outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab])
105
- btn_sent.click(show_tab, inputs=[gr.Textbox(value="sentiment", visible=False)], outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab])
106
- btn_trans.click(show_tab, inputs=[gr.Textbox(value="translate", visible=False)], outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab])
107
- btn_speech.click(show_tab, inputs=[gr.Textbox(value="speech", visible=False)], outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab])
108
- btn_qgen.click(show_tab, inputs=[gr.Textbox(value="question", visible=False)], outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab])
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  demo.launch()
 
62
  btn_speech = gr.Button("Speech-to-Text")
63
  btn_qgen = gr.Button("Question Generation")
64
 
65
+ # Tab sections
 
 
66
  with gr.Column(visible=False) as summarize_tab:
67
  text = gr.Textbox(label="Enter paragraph", lines=10)
68
  out = gr.Textbox(label="Summary", lines=4)
 
99
  gr.update(visible=(tab_name == "question")),
100
  ]
101
 
102
+ # Shared hidden input to control tab switching
103
+ hidden_tab_name = gr.Textbox(value="", visible=False)
104
+
105
+ btn_summ.click(lambda: "summarize", outputs=hidden_tab_name).then(
106
+ show_tab, inputs=hidden_tab_name, outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab]
107
+ )
108
+ btn_sent.click(lambda: "sentiment", outputs=hidden_tab_name).then(
109
+ show_tab, inputs=hidden_tab_name, outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab]
110
+ )
111
+ btn_trans.click(lambda: "translate", outputs=hidden_tab_name).then(
112
+ show_tab, inputs=hidden_tab_name, outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab]
113
+ )
114
+ btn_speech.click(lambda: "speech", outputs=hidden_tab_name).then(
115
+ show_tab, inputs=hidden_tab_name, outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab]
116
+ )
117
+ btn_qgen.click(lambda: "question", outputs=hidden_tab_name).then(
118
+ show_tab, inputs=hidden_tab_name, outputs=[summarize_tab, sentiment_tab, translate_tab, speech_tab, question_tab]
119
+ )
120
 
121
  demo.launch()