AndrewRWilliams commited on
Commit
39f97dc
1 Parent(s): 062f9b2

use `load_audio()`

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -30,7 +30,15 @@ def slugify(value, allow_unicode=False):
30
  return re.sub(r'[-\s]+', '-', value).strip('-_')
31
 
32
  def transcribe(file):
33
- result = model.transcribe(file)
 
 
 
 
 
 
 
 
34
 
35
  file_path = pathlib.Path(file)
36
  sourceName = file_path.stem[:MAX_FILE_PREFIX_LENGTH] + file_path.suffix
 
30
  return re.sub(r'[-\s]+', '-', value).strip('-_')
31
 
32
  def transcribe(file):
33
+
34
+ try:
35
+ audio = whisper.load_audio(video_file_path)
36
+ except Exception as e:
37
+ raise RuntimeError("Error converting video to audio")
38
+
39
+ transcribe_options = dict(beam_size=5, best_of=5, without_timestamps=False
40
+
41
+ result = model.transcribe(audio, **transcribe_options)
42
 
43
  file_path = pathlib.Path(file)
44
  sourceName = file_path.stem[:MAX_FILE_PREFIX_LENGTH] + file_path.suffix