Commit
·
0ca0046
1
Parent(s):
780225d
refactor ui
Browse files
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 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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__':
|