marquesafonso commited on
Commit
fc138bd
·
1 Parent(s): 33d3f17

return to gr.interface fix

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