OthmaneLKH commited on
Commit
7888e4e
1 Parent(s): 7519b8e
Files changed (1) hide show
  1. app.py +24 -8
app.py CHANGED
@@ -488,6 +488,13 @@ def transcribe_audio_app(audio_path):
488
 
489
  return transcription
490
 
 
 
 
 
 
 
 
491
 
492
  demo = gr.Blocks(css=".markdown-body { font-size: 18px; }")
493
 
@@ -576,19 +583,28 @@ with demo:
576
  outputs=[gen_key_btn],
577
  ) """
578
 
579
- msg = gr.Textbox()
580
-
581
- audio_box = gr.Audio(label="Audio", type="filepath", elem_id='audio')
 
 
582
 
583
  with gr.Row():
584
- audio_btn = gr.Button('Speak')
585
- clear = gr.Button("Clear")
 
586
 
587
- audio_btn.click(fn=action, inputs=audio_btn, outputs=audio_btn) \
588
  .then(fn=check_btn, inputs=audio_btn) \
589
- .success(fn=transcribe_audio_app, outputs=msg)
 
 
 
 
 
 
590
 
591
- clear.click(lambda: None, None, msg, queue=False)
592
 
593
  ########################## Transcription ##########################
594
  with gr.Row():
 
488
 
489
  return transcription
490
 
491
+ def enregistrer_audio(audio):
492
+ if audio is not None:
493
+ return audio
494
+ return None
495
+
496
+
497
+
498
 
499
  demo = gr.Blocks(css=".markdown-body { font-size: 18px; }")
500
 
 
583
  outputs=[gen_key_btn],
584
  ) """
585
 
586
+ msg = gr.Textbox(label="Message")
587
+ audio_output = gr.Audio(label="Audio enregistré", visible=False)
588
+ transcription_output = gr.Textbox(label="Transcription", lines=5)
589
+
590
+ audio_box = gr.Audio(label="Enregistrer Audio", source="microphone", type="filepath", elem_id='audio')
591
 
592
  with gr.Row():
593
+ audio_btn = gr.Button('Enregistrer')
594
+ transcribe_btn = gr.Button('Transcrire')
595
+ clear = gr.Button("Effacer")
596
 
597
+ audio_btn.click(fn=enregistrer_audio, inputs=[audio_box], outputs=[audio_output, msg]) \
598
  .then(fn=check_btn, inputs=audio_btn) \
599
+ .success(fn=lambda: "Audio enregistré avec succès!", outputs=msg)
600
+
601
+ transcribe_btn.click(
602
+ fn=transcribe_audio_app,
603
+ inputs=[audio_output],
604
+ outputs=[transcription_output]
605
+ )
606
 
607
+ clear.click(lambda: (None, None, None), None, [audio_output, msg, transcription_output], queue=False)
608
 
609
  ########################## Transcription ##########################
610
  with gr.Row():