marquesafonso commited on
Commit
0ca0046
·
1 Parent(s): 780225d

refactor ui

Browse files
Files changed (1) hide show
  1. app.py +34 -25
app.py CHANGED
@@ -7,40 +7,49 @@ def main():
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
  with gr.Tabs(selected="video") as tabs:
9
  with gr.Tab("Video", id="video"):
10
- file = gr.File(file_types=["video"],type="filepath", label="Upload a video")
11
- file_type = gr.Radio(choices=["video"], value="video", label="File Type", visible=False)
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",
15
- "turbo",
16
- "large-v3"], value="deepdml/faster-whisper-large-v3-turbo-ct2", label="Select Model")
17
- text_output = gr.Textbox(label="SRT Text transcription")
18
- srt_file = gr.File(file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
19
- text_clean_output = gr.Textbox(label="Text transcription")
20
- transcribe_btn = gr.Button(value="Transcribe")
 
 
 
 
21
  transcribe_btn.click(
22
  fn=transcriber,
23
  inputs=[file, file_type, max_words_per_line, task, model_version],
24
  outputs=[text_output, srt_file, text_clean_output]
25
- )
26
-
27
  with gr.Tab("Audio", id = "audio"):
28
- file = gr.File(file_types=["audio"],type="filepath", label="Upload an audio file")
29
- file_type = gr.Radio(choices=["audio"], value="audio", label="File Type", visible=False)
30
- max_words_per_line = gr.Number(value=6, label="Max words per line")
31
- task = gr.Radio(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
32
- model_version = gr.Radio(choices=["deepdml/faster-whisper-large-v3-turbo-ct2",
33
- "turbo",
34
- "large-v3"], value="deepdml/faster-whisper-large-v3-turbo-ct2", label="Select Model")
35
- text_output = gr.Textbox(label="SRT Text transcription")
36
- srt_file = gr.File(file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
37
- text_clean_output = gr.Textbox(label="Text transcription")
38
- transcribe_btn = gr.Button(value="Transcribe")
 
 
 
 
39
  transcribe_btn.click(
40
  fn=transcriber,
41
  inputs=[file, file_type, max_words_per_line, task, model_version],
42
  outputs=[text_output, srt_file, text_clean_output]
43
- )
 
44
  demo.launch()
45
 
46
  if __name__ == '__main__':
 
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
  with gr.Tabs(selected="video") as tabs:
9
  with gr.Tab("Video", id="video"):
10
+ with gr.Row():
11
+ with gr.Column():
12
+ video = True
13
+ file = gr.File(file_types=["video"],type="filepath", label="Upload a video")
14
+ file_type = gr.Radio(choices=["video"], value="video", label="File Type", visible=False)
15
+ max_words_per_line = gr.Number(value=6, label="Max words per line")
16
+ task = gr.Radio(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
17
+ model_version = gr.Radio(choices=["deepdml/faster-whisper-large-v3-turbo-ct2",
18
+ "turbo",
19
+ "large-v3"], value="deepdml/faster-whisper-large-v3-turbo-ct2", label="Select Model")
20
+ transcribe_btn = gr.Button(value="Transcribe", variant="primary")
21
+ with gr.Column():
22
+ text_output = gr.Textbox(label="SRT Text transcription")
23
+ srt_file = gr.File(value=None, file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
24
+ text_clean_output = gr.Textbox(label="Text transcription")
25
  transcribe_btn.click(
26
  fn=transcriber,
27
  inputs=[file, file_type, max_words_per_line, task, model_version],
28
  outputs=[text_output, srt_file, text_clean_output]
29
+ )
30
+
31
  with gr.Tab("Audio", id = "audio"):
32
+ with gr.Row():
33
+ with gr.Column():
34
+ video = False
35
+ file = gr.File(file_types=["audio"],type="filepath", label="Upload an audio file")
36
+ file_type = gr.Radio(choices=["audio"], value="audio", label="File Type", visible=False)
37
+ max_words_per_line = gr.Number(value=6, label="Max words per line")
38
+ task = gr.Radio(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
39
+ model_version = gr.Radio(choices=["deepdml/faster-whisper-large-v3-turbo-ct2",
40
+ "turbo",
41
+ "large-v3"], value="deepdml/faster-whisper-large-v3-turbo-ct2", label="Select Model")
42
+ transcribe_btn = gr.Button(value="Transcribe", variant="primary")
43
+ with gr.Column():
44
+ text_output = gr.Textbox(label="SRT Text transcription")
45
+ srt_file = gr.File(value=None, file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
46
+ text_clean_output = gr.Textbox(label="Text transcription")
47
  transcribe_btn.click(
48
  fn=transcriber,
49
  inputs=[file, file_type, max_words_per_line, task, model_version],
50
  outputs=[text_output, srt_file, text_clean_output]
51
+ )
52
+
53
  demo.launch()
54
 
55
  if __name__ == '__main__':