marquesafonso commited on
Commit
9b8ed12
·
verified ·
1 Parent(s): 45c890c

create tabbed interface for video and audio

Browse files
Files changed (1) hide show
  1. app.py +27 -11
app.py CHANGED
@@ -5,17 +5,33 @@ def main():
5
  with gr.Blocks(title='multilang-asr-transcriber', delete_cache=(86400, 86400), theme=gr.themes.Base()) as demo:
6
  gr.Markdown('## Multilang ASR Transcriber')
7
  gr.Markdown('An automatic speech recognition tool using [faster-whisper](https://github.com/SYSTRAN/faster-whisper). Supports multilingual video transcription and translation to english. Users may set the max words per line.')
8
- file = gr.File(file_types=["video", "audio"],type="filepath", label="Upload video or audio")
9
- max_words_per_line = gr.Number(value=6, label="Max words per line")
10
- task = gr.Radio(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
11
- model_version = gr.Radio(choices=["deepdml/faster-whisper-large-v3-turbo-ct2", "large-v3"], value="deepdml/faster-whisper-large-v3-turbo-ct2", label="Select Model")
12
- text_output = gr.Textbox(label="SRT Text transcription", show_copy_button=True)
13
- srt_file = gr.File(file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
14
- text_clean_output = gr.Textbox(label="Text transcription", show_copy_button=True)
15
- gr.Interface(transcriber,
16
- inputs=[file, max_words_per_line, task, model_version],
17
- outputs=[text_output, srt_file, text_clean_output],
18
- allow_flagging="never")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  demo.launch()
20
 
21
  if __name__ == '__main__':
 
5
  with gr.Blocks(title='multilang-asr-transcriber', delete_cache=(86400, 86400), theme=gr.themes.Base()) as demo:
6
  gr.Markdown('## Multilang ASR Transcriber')
7
  gr.Markdown('An automatic speech recognition tool using [faster-whisper](https://github.com/SYSTRAN/faster-whisper). Supports multilingual video transcription and translation to english. Users may set the max words per line.')
8
+
9
+ with gr.Tab("Video"):
10
+ file = gr.File(file_types=["video"],type="filepath", label="Upload a video")
11
+ video = True
12
+ max_words_per_line = gr.Number(value=6, label="Max words per line")
13
+ task = gr.Radio(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
14
+ model_version = gr.Radio(choices=["deepdml/faster-whisper-large-v3-turbo-ct2", "large-v3"], value="deepdml/faster-whisper-large-v3-turbo-ct2", label="Select Model")
15
+ text_output = gr.Textbox(label="SRT Text transcription", show_copy_button=True)
16
+ srt_file = gr.File(file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
17
+ text_clean_output = gr.Textbox(label="Text transcription", show_copy_button=True)
18
+ gr.Interface(transcriber,
19
+ inputs=[file, video, max_words_per_line, task, model_version],
20
+ outputs=[text_output, srt_file, text_clean_output],
21
+ allow_flagging="never")
22
+
23
+ with gr.Tab("Audio"):
24
+ file = gr.File(file_types=["audio"],type="filepath", label="Upload an audio file")
25
+ max_words_per_line = gr.Number(value=6, label="Max words per line")
26
+ task = gr.Radio(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
27
+ model_version = gr.Radio(choices=["deepdml/faster-whisper-large-v3-turbo-ct2", "large-v3"], value="deepdml/faster-whisper-large-v3-turbo-ct2", label="Select Model")
28
+ text_output = gr.Textbox(label="SRT Text transcription", show_copy_button=True)
29
+ srt_file = gr.File(file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
30
+ text_clean_output = gr.Textbox(label="Text transcription", show_copy_button=True)
31
+ gr.Interface(transcriber,
32
+ inputs=[file, video, max_words_per_line, task, model_version],
33
+ outputs=[text_output, srt_file, text_clean_output],
34
+ allow_flagging="never")
35
  demo.launch()
36
 
37
  if __name__ == '__main__':