Spaces:
Sleeping
Sleeping
Ubuntu
commited on
Commit
•
753aaf7
1
Parent(s):
992acbf
remove unused tab
Browse files
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 |
-
|
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.
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
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")))
|