vitaliy-sharandin
commited on
Commit
•
79c8716
1
Parent(s):
0657ec1
Update app.py
Browse files
app.py
CHANGED
@@ -18,10 +18,10 @@ DEEPL_TOKEN = os.environ["DEEPL_TOKEN"]
|
|
18 |
|
19 |
# Download video from Youtube
|
20 |
def download_youtube_video(url):
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
|
27 |
# Extract audio from video
|
@@ -54,7 +54,7 @@ def speech_diarization(audio_path, hf_token):
|
|
54 |
import gc; gc.collect(); torch.cuda.empty_cache(); del model_a
|
55 |
|
56 |
# 3. Assign speaker labels
|
57 |
-
diarize_model = whisperx.DiarizationPipeline(
|
58 |
|
59 |
# add min/max number of speakers if known
|
60 |
diarize_segments = diarize_model(audio)
|
|
|
18 |
|
19 |
# Download video from Youtube
|
20 |
def download_youtube_video(url):
|
21 |
+
yt = YouTube(url)
|
22 |
+
stream = yt.streams.filter(file_extension='mp4').first()
|
23 |
+
output_path = stream.download()
|
24 |
+
return output_path
|
25 |
|
26 |
|
27 |
# Extract audio from video
|
|
|
54 |
import gc; gc.collect(); torch.cuda.empty_cache(); del model_a
|
55 |
|
56 |
# 3. Assign speaker labels
|
57 |
+
diarize_model = whisperx.DiarizationPipeline(use_auth_token=hf_token, device=device)
|
58 |
|
59 |
# add min/max number of speakers if known
|
60 |
diarize_segments = diarize_model(audio)
|