marquesafonso commited on
Commit
861c879
1 Parent(s): 5f974dc

set allow paths to include temp dir

Browse files
Files changed (2) hide show
  1. app.py +4 -5
  2. src/transcriber.py +0 -1
app.py CHANGED
@@ -2,20 +2,19 @@ import gradio as gr
2
  from src.transcriber import transcriber
3
 
4
  def main():
5
- with gr.Blocks(analytics_enabled=False, title='multilang-asr-transcriber') as demo:
6
  gr.Markdown('# multilang-asr-transcriber')
7
  gr.Markdown('### A multilingual automatic speech transcription tool using [faster-whisper](https://github.com/SYSTRAN/faster-whisper). Supports translation to english and user setting of max words per line.')
8
  video_file = gr.File(file_types=["video"],type="filepath", label="Upload a video")
9
  max_words_per_line = gr.Number(value=6, label="Max words per line")
10
  task = gr.Dropdown(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
11
  text_output = gr.Textbox(label="Text transcription")
12
- srt_file = gr.File(file_count="single", file_types=[".srt"], label="SRT file")
13
  gr.Interface(transcriber,
14
  inputs=[video_file, max_words_per_line, task],
15
  outputs=[text_output,srt_file],
16
- allow_flagging="never",
17
- analytics_enabled=False)
18
- demo.launch()
19
 
20
  if __name__ == '__main__':
21
  main()
 
2
  from src.transcriber import transcriber
3
 
4
  def main():
5
+ with gr.Blocks(title='multilang-asr-transcriber') as demo:
6
  gr.Markdown('# multilang-asr-transcriber')
7
  gr.Markdown('### A multilingual automatic speech transcription tool using [faster-whisper](https://github.com/SYSTRAN/faster-whisper). Supports translation to english and user setting of max words per line.')
8
  video_file = gr.File(file_types=["video"],type="filepath", label="Upload a video")
9
  max_words_per_line = gr.Number(value=6, label="Max words per line")
10
  task = gr.Dropdown(choices=["transcribe", "translate"], value="transcribe", label="Select Task")
11
  text_output = gr.Textbox(label="Text transcription")
12
+ srt_file = gr.File(file_count="single", type="filepath", file_types=[".srt"], label="SRT file")
13
  gr.Interface(transcriber,
14
  inputs=[video_file, max_words_per_line, task],
15
  outputs=[text_output,srt_file],
16
+ allow_flagging="never")
17
+ demo.launch(allowed_paths=["https://marquesafonso-multilang-asr-transcriber.hf.space/file=/tmp/gradio/", "file=/tmp/gradio/", "/tmp/gradio/"])
 
18
 
19
  if __name__ == '__main__':
20
  main()
src/transcriber.py CHANGED
@@ -45,7 +45,6 @@ def transcriber(video_input:gr.File,
45
  max_words_per_line:int,
46
  task:str):
47
  srt_filepath = os.path.normpath(f"{video_input.split('.')[0]}.srt")
48
- gr.set_static_paths(paths=[srt_filepath])
49
  audio_input = convert_video_to_audio(video_input)
50
  model_size = "large-v3"
51
  model = WhisperModel(model_size, device="cpu", compute_type="int8")
 
45
  max_words_per_line:int,
46
  task:str):
47
  srt_filepath = os.path.normpath(f"{video_input.split('.')[0]}.srt")
 
48
  audio_input = convert_video_to_audio(video_input)
49
  model_size = "large-v3"
50
  model = WhisperModel(model_size, device="cpu", compute_type="int8")