Spaces:
Runtime error
Runtime error
Update diarization.py
Browse files- diarization.py +4 -1
diarization.py
CHANGED
@@ -118,6 +118,7 @@ def create_combined_srt(transcription_chunks, diarization, output_path):
|
|
118 |
|
119 |
@spaces.GPU(duration=600)
|
120 |
def process_video(video_path, diarization_access_token, language):
|
|
|
121 |
base_name = os.path.splitext(video_path)[0]
|
122 |
audio_path = f"{base_name}.wav"
|
123 |
extract_audio(video_path, audio_path)
|
@@ -125,7 +126,7 @@ def process_video(video_path, diarization_access_token, language):
|
|
125 |
# Diarization
|
126 |
print("Performing diarization...")
|
127 |
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", use_auth_token=diarization_access_token)
|
128 |
-
pipeline = pipeline.to(
|
129 |
diarization = pipeline(audio_path)
|
130 |
print("Diarization complete.")
|
131 |
|
@@ -142,6 +143,8 @@ def process_video(video_path, diarization_access_token, language):
|
|
142 |
# Clean up
|
143 |
os.remove(audio_path)
|
144 |
|
|
|
|
|
145 |
if __name__ == "__main__":
|
146 |
video_path = r"C:\Users\reab5\Downloads\MediaHuman\Music\test1.mp4"
|
147 |
# Get Hugging Face token from Space secret
|
|
|
118 |
|
119 |
@spaces.GPU(duration=600)
|
120 |
def process_video(video_path, diarization_access_token, language):
|
121 |
+
import torch
|
122 |
base_name = os.path.splitext(video_path)[0]
|
123 |
audio_path = f"{base_name}.wav"
|
124 |
extract_audio(video_path, audio_path)
|
|
|
126 |
# Diarization
|
127 |
print("Performing diarization...")
|
128 |
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", use_auth_token=diarization_access_token)
|
129 |
+
pipeline = pipeline.to("cuda")
|
130 |
diarization = pipeline(audio_path)
|
131 |
print("Diarization complete.")
|
132 |
|
|
|
143 |
# Clean up
|
144 |
os.remove(audio_path)
|
145 |
|
146 |
+
return combined_srt_path
|
147 |
+
|
148 |
if __name__ == "__main__":
|
149 |
video_path = r"C:\Users\reab5\Downloads\MediaHuman\Music\test1.mp4"
|
150 |
# Get Hugging Face token from Space secret
|