Spaces:
Runtime error
Runtime error
ayaanzaveri
commited on
Commit
•
a6dcf15
1
Parent(s):
85d7ecb
Update main.py
Browse files
main.py
CHANGED
@@ -21,19 +21,19 @@ def segment_to_dict(segment):
|
|
21 |
|
22 |
@app.post("/video")
|
23 |
async def download_video(video_url: str):
|
24 |
-
download_convert_video_to_audio(yt_dlp, video_url, f"/
|
25 |
|
26 |
@app.post("/transcribe")
|
27 |
async def transcribe_video(video_url: str, beam_size: int = 5):
|
28 |
print("doing hex")
|
29 |
rand_id = uuid.uuid4().hex
|
30 |
print("doing download")
|
31 |
-
download_convert_video_to_audio(yt_dlp, video_url, f"/
|
32 |
-
segments, info = model.transcribe(f"/
|
33 |
segments = [segment_to_dict(segment) for segment in segments]
|
34 |
total_duration = round(info.duration, 2) # Same precision as the Whisper timestamps.
|
35 |
print(info)
|
36 |
-
os.remove(f"/
|
37 |
print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
38 |
|
39 |
return segments
|
|
|
21 |
|
22 |
@app.post("/video")
|
23 |
async def download_video(video_url: str):
|
24 |
+
download_convert_video_to_audio(yt_dlp, video_url, f"/home/user/{uuid.uuid4().hex}")
|
25 |
|
26 |
@app.post("/transcribe")
|
27 |
async def transcribe_video(video_url: str, beam_size: int = 5):
|
28 |
print("doing hex")
|
29 |
rand_id = uuid.uuid4().hex
|
30 |
print("doing download")
|
31 |
+
download_convert_video_to_audio(yt_dlp, video_url, f"/home/user/{rand_id}")
|
32 |
+
segments, info = model.transcribe(f"/home/user/{rand_id}.mp3", beam_size=beam_size, word_timestamps=True)
|
33 |
segments = [segment_to_dict(segment) for segment in segments]
|
34 |
total_duration = round(info.duration, 2) # Same precision as the Whisper timestamps.
|
35 |
print(info)
|
36 |
+
os.remove(f"/home/user/{rand_id}.mp3")
|
37 |
print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
38 |
|
39 |
return segments
|