ayaanzaveri commited on
Commit
778f982
1 Parent(s): 56811cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -37,7 +37,7 @@ def segment_to_dict(segment):
37
  return segment
38
 
39
  def download_video(video_url: str):
40
- download_convert_video_to_audio(yt_dlp, video_url, f"/content/{uuid.uuid4().hex}")
41
 
42
  def transcribe_video(video_url: str, word_timestamps: bool = True, model_size: str = "tiny"):
43
  print(word_timestamps)
@@ -47,8 +47,8 @@ def transcribe_video(video_url: str, word_timestamps: bool = True, model_size: s
47
  print("getting hex")
48
  rand_id = uuid.uuid4().hex
49
  print("doing download")
50
- download_convert_video_to_audio(yt_dlp, video_url, f"/content/{rand_id}")
51
- segments, info = model.transcribe(f"/content/{rand_id}.mp3", beam_size=5, word_timestamps=word_timestamps)
52
  segments = [segment_to_dict(segment) for segment in segments]
53
  total_duration = round(info.duration, 2) # Same precision as the Whisper timestamps.
54
  with tqdm(total=total_duration, unit=" seconds") as pbar:
@@ -58,7 +58,7 @@ def transcribe_video(video_url: str, word_timestamps: bool = True, model_size: s
58
 
59
  print(pbar)
60
  print(info)
61
- os.remove(f"/content/{rand_id}.mp3")
62
  print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
63
  print(segments)
64
  return segments
 
37
  return segment
38
 
39
  def download_video(video_url: str):
40
+ download_convert_video_to_audio(yt_dlp, video_url, f"{uuid.uuid4().hex}")
41
 
42
  def transcribe_video(video_url: str, word_timestamps: bool = True, model_size: str = "tiny"):
43
  print(word_timestamps)
 
47
  print("getting hex")
48
  rand_id = uuid.uuid4().hex
49
  print("doing download")
50
+ download_convert_video_to_audio(yt_dlp, video_url, f"{rand_id}")
51
+ segments, info = model.transcribe(f"{rand_id}.mp3", beam_size=5, word_timestamps=word_timestamps)
52
  segments = [segment_to_dict(segment) for segment in segments]
53
  total_duration = round(info.duration, 2) # Same precision as the Whisper timestamps.
54
  with tqdm(total=total_duration, unit=" seconds") as pbar:
 
58
 
59
  print(pbar)
60
  print(info)
61
+ os.remove(f"{rand_id}.mp3")
62
  print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
63
  print(segments)
64
  return segments