Spaces:
Sleeping
Sleeping
OthmaneLKH
commited on
Commit
•
2ad72ff
1
Parent(s):
d27b983
Update app.py
Browse files
app.py
CHANGED
@@ -454,13 +454,16 @@ def click_js():
|
|
454 |
|
455 |
def action(btn):
|
456 |
"""Changes button text on click"""
|
457 |
-
if btn == 'Speak':
|
458 |
-
|
|
|
|
|
459 |
|
460 |
|
461 |
def check_btn(btn):
|
462 |
"""Checks for correct button text before invoking transcribe()"""
|
463 |
-
if btn != 'Speak':
|
|
|
464 |
|
465 |
|
466 |
def transcribe():
|
@@ -561,16 +564,18 @@ with demo:
|
|
561 |
) """
|
562 |
|
563 |
msg = gr.Textbox()
|
564 |
-
|
|
|
|
|
565 |
|
566 |
with gr.Row():
|
567 |
audio_btn = gr.Button('Speak')
|
568 |
clear = gr.Button("Clear")
|
569 |
|
570 |
-
audio_btn.click(fn=action, inputs=audio_btn, outputs=audio_btn)
|
571 |
-
then(fn=lambda: None, _js=click_js())
|
572 |
-
then(fn=check_btn, inputs=audio_btn)
|
573 |
-
success(fn=transcribe, outputs=msg)
|
574 |
|
575 |
clear.click(lambda: None, None, msg, queue=False)
|
576 |
|
|
|
454 |
|
455 |
def action(btn):
|
456 |
"""Changes button text on click"""
|
457 |
+
if btn == 'Speak':
|
458 |
+
return 'Stop'
|
459 |
+
else:
|
460 |
+
return 'Speak'
|
461 |
|
462 |
|
463 |
def check_btn(btn):
|
464 |
"""Checks for correct button text before invoking transcribe()"""
|
465 |
+
if btn != 'Speak':
|
466 |
+
raise Exception('Recording...')
|
467 |
|
468 |
|
469 |
def transcribe():
|
|
|
564 |
) """
|
565 |
|
566 |
msg = gr.Textbox()
|
567 |
+
|
568 |
+
# Removed the `source` argument as it's no longer supported
|
569 |
+
audio_box = gr.Audio(label="Audio", type="filepath", elem_id='audio')
|
570 |
|
571 |
with gr.Row():
|
572 |
audio_btn = gr.Button('Speak')
|
573 |
clear = gr.Button("Clear")
|
574 |
|
575 |
+
audio_btn.click(fn=action, inputs=audio_btn, outputs=audio_btn) \
|
576 |
+
.then(fn=lambda: None, _js=click_js()) \
|
577 |
+
.then(fn=check_btn, inputs=audio_btn) \
|
578 |
+
.success(fn=transcribe, outputs=msg)
|
579 |
|
580 |
clear.click(lambda: None, None, msg, queue=False)
|
581 |
|