Ubuntu commited on
Commit
753aaf7
1 Parent(s): 992acbf

remove unused tab

Browse files
Files changed (1) hide show
  1. app.py +36 -81
app.py CHANGED
@@ -161,87 +161,42 @@ def user_interface(audio, source_lang, target_lang, youtube_url):
161
  with gr.Blocks() as demo:
162
  gr.Markdown("# Speech Translation")
163
 
164
- with gr.Tab("User Mode"):
165
- gr.Markdown("Speak into the microphone, upload an audio file, or provide a YouTube URL. The app will translate and speak it back to you.")
166
-
167
- with gr.Row():
168
- user_audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath")
169
- user_youtube_url = gr.Textbox(label="YouTube URL (optional)")
170
- user_source_lang = gr.Dropdown(choices=["en", "ma", "ta", "zh"], label="Source Language", value="en")
171
- user_target_lang = gr.Dropdown(choices=["en", "ma", "ta", "zh"], label="Target Language", value="zh")
172
-
173
- with gr.Row():
174
- user_button = gr.Button("Translate and Speak", interactive=False)
175
-
176
- with gr.Row():
177
- user_transcription_output = gr.Textbox(label="Transcription")
178
- user_translation_output = gr.Textbox(label="Translation")
179
- user_audio_output = gr.Audio(label="Translated Speech")
180
-
181
- def update_button_state(audio, youtube_url):
182
- print(audio, youtube_url)
183
- return gr.Button(interactive=bool(audio) or bool(youtube_url))
184
-
185
- user_audio_input.change(
186
- fn=update_button_state,
187
- inputs=[user_audio_input, user_youtube_url],
188
- outputs=user_button
189
- )
190
- user_youtube_url.change(
191
- fn=update_button_state,
192
- inputs=[user_audio_input, user_youtube_url],
193
- outputs=user_button
194
- )
195
-
196
- user_button.click(
197
- fn=user_interface,
198
- inputs=[user_audio_input, user_source_lang, user_target_lang, user_youtube_url],
199
- outputs=[user_transcription_output, user_translation_output, user_audio_output]
200
- )
201
 
202
- with gr.Tab("Developer Mode"):
203
- password_input = gr.Textbox(type="password", label="Enter Developer Password")
204
- login_button = gr.Button("Login")
205
- login_error = gr.Markdown(visible=False)
206
-
207
- dev_interface = gr.Column(visible=False)
208
-
209
- with dev_interface:
210
- gr.Markdown("Developer Mode: Transcription, Translation, and TTS")
211
-
212
- with gr.Row():
213
- dev_audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath")
214
- dev_source_lang = gr.Dropdown(choices=["en", "ma", "ta", "zh"], label="Source Language", value="en")
215
- dev_target_lang = gr.Dropdown(choices=["en", "ma", "ta", "zh"], label="Target Language", value="zh")
216
-
217
- with gr.Row():
218
- dev_button = gr.Button("Transcribe, Translate, and Speak")
219
-
220
- with gr.Row():
221
- dev_text_output = gr.Textbox(label="Transcription")
222
-
223
- with gr.Row():
224
- dev_translation_output = gr.Textbox(label="Translation")
225
-
226
- with gr.Row():
227
- dev_audio_output = gr.Audio(label="Translated Speech")
228
-
229
- dev_button.click(
230
- fn=transcribe_and_speak,
231
- inputs=[dev_audio_input, dev_source_lang, dev_target_lang],
232
- outputs=[dev_text_output, dev_translation_output, dev_audio_output]
233
- )
234
-
235
- def login(password):
236
- if check_password(password):
237
- return gr.Column(visible=True), gr.Markdown(visible=False)
238
- else:
239
- return gr.Column(visible=False), gr.Markdown("Incorrect password. Please try again.", visible=True)
240
-
241
- login_button.click(
242
- fn=login,
243
- inputs=[password_input],
244
- outputs=[dev_interface, login_error]
245
- )
246
 
247
  demo.launch(auth=(os.getenv("DEV_USER"), os.getenv("DEV_PWD")))
 
161
  with gr.Blocks() as demo:
162
  gr.Markdown("# Speech Translation")
163
 
164
+ # with gr.Tab("User Mode"):
165
+ gr.Markdown("Speak into the microphone, upload an audio file, or provide a YouTube URL. The app will translate and speak it back to you.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
+ with gr.Row():
168
+ user_audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath")
169
+ user_youtube_url = gr.Textbox(label="YouTube URL (optional)")
170
+ user_source_lang = gr.Dropdown(choices=["en", "ma", "ta", "zh"], label="Source Language", value="en")
171
+ user_target_lang = gr.Dropdown(choices=["en", "ma", "ta", "zh"], label="Target Language", value="zh")
172
+
173
+ with gr.Row():
174
+ user_button = gr.Button("Translate and Speak", interactive=False)
175
+
176
+ with gr.Row():
177
+ user_transcription_output = gr.Textbox(label="Transcription")
178
+ user_translation_output = gr.Textbox(label="Translation")
179
+ user_audio_output = gr.Audio(label="Translated Speech")
180
+
181
+ def update_button_state(audio, youtube_url):
182
+ print(audio, youtube_url)
183
+ return gr.Button(interactive=bool(audio) or bool(youtube_url))
184
+
185
+ user_audio_input.change(
186
+ fn=update_button_state,
187
+ inputs=[user_audio_input, user_youtube_url],
188
+ outputs=user_button
189
+ )
190
+ user_youtube_url.change(
191
+ fn=update_button_state,
192
+ inputs=[user_audio_input, user_youtube_url],
193
+ outputs=user_button
194
+ )
195
+
196
+ user_button.click(
197
+ fn=user_interface,
198
+ inputs=[user_audio_input, user_source_lang, user_target_lang, user_youtube_url],
199
+ outputs=[user_transcription_output, user_translation_output, user_audio_output]
200
+ )
 
 
 
 
 
 
 
 
 
 
201
 
202
  demo.launch(auth=(os.getenv("DEV_USER"), os.getenv("DEV_PWD")))