Spaces:
Build error
Build error
ayaanzaveri
commited on
Commit
·
79a90b8
1
Parent(s):
a639eca
Update app.py
Browse files
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"
|
41 |
|
42 |
def transcribe_video(video_url: str, beam_size: int = 5, model_size: str = "tiny", word_timestamps: bool = True):
|
43 |
print("loading model")
|
@@ -45,12 +45,12 @@ def transcribe_video(video_url: str, beam_size: int = 5, model_size: str = "tiny
|
|
45 |
print("getting hex")
|
46 |
rand_id = uuid.uuid4().hex
|
47 |
print("doing download")
|
48 |
-
download_convert_video_to_audio(yt_dlp, video_url, f"
|
49 |
-
segments, info = model.transcribe(f"
|
50 |
segments = [segment_to_dict(segment) for segment in segments]
|
51 |
total_duration = round(info.duration, 2) # Same precision as the Whisper timestamps.
|
52 |
print(info)
|
53 |
-
os.remove(f"
|
54 |
print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
55 |
print(segments)
|
56 |
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, beam_size: int = 5, model_size: str = "tiny", word_timestamps: bool = True):
|
43 |
print("loading model")
|
|
|
45 |
print("getting hex")
|
46 |
rand_id = uuid.uuid4().hex
|
47 |
print("doing download")
|
48 |
+
download_convert_video_to_audio(yt_dlp, video_url, f"{rand_id}")
|
49 |
+
segments, info = model.transcribe(f"{rand_id}.mp3", beam_size=beam_size, word_timestamps=word_timestamps)
|
50 |
segments = [segment_to_dict(segment) for segment in segments]
|
51 |
total_duration = round(info.duration, 2) # Same precision as the Whisper timestamps.
|
52 |
print(info)
|
53 |
+
os.remove(f"{rand_id}.mp3")
|
54 |
print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
55 |
print(segments)
|
56 |
return segments
|