raphaelbiojout
commited on
Commit
·
38217d8
1
Parent(s):
d9a0ef6
cpu for dia
Browse files- handler.py +7 -7
handler.py
CHANGED
@@ -179,7 +179,7 @@ class EndpointHandler():
|
|
179 |
|
180 |
self.diarize_model = whisperx.DiarizationPipeline(
|
181 |
"pyannote/speaker-diarization-3.0",
|
182 |
-
use_auth_token="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", device=
|
183 |
|
184 |
logger.info(f"Model for diarization initialized")
|
185 |
|
@@ -233,8 +233,8 @@ class EndpointHandler():
|
|
233 |
logger.info(f"device: {device}, batch_size: {batch_size}, compute_type:{compute_type}, whisper_model: {whisper_model}")
|
234 |
transcription = self.model.transcribe(audio_nparray, batch_size=batch_size,language=language)
|
235 |
if info:
|
236 |
-
print(transcription["segments"]) # before alignment
|
237 |
-
logger.info(transcription["segments"])
|
238 |
|
239 |
# 3. align
|
240 |
if alignment:
|
@@ -244,8 +244,8 @@ class EndpointHandler():
|
|
244 |
transcription = whisperx.align(
|
245 |
transcription["segments"], model_a, metadata, audio_nparray, device, return_char_alignments=False)
|
246 |
if info:
|
247 |
-
print(transcription["segments"])
|
248 |
-
logger.info(transcription["segments"])
|
249 |
|
250 |
# 4. Assign speaker labels
|
251 |
logger.info("--------------- STARTING DIARIZATION ------------------------")
|
@@ -258,8 +258,8 @@ class EndpointHandler():
|
|
258 |
|
259 |
transcription = whisperx.assign_word_speakers(diarize_segments, transcription)
|
260 |
if info:
|
261 |
-
print(transcription["segments"])
|
262 |
-
logger.info(transcription["segments"]) # segments are now assigned speaker IDs
|
263 |
|
264 |
if torch.cuda.is_available():
|
265 |
logger.info("--------------- GPU ------------------------")
|
|
|
179 |
|
180 |
self.diarize_model = whisperx.DiarizationPipeline(
|
181 |
"pyannote/speaker-diarization-3.0",
|
182 |
+
use_auth_token="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", device="cpu")
|
183 |
|
184 |
logger.info(f"Model for diarization initialized")
|
185 |
|
|
|
233 |
logger.info(f"device: {device}, batch_size: {batch_size}, compute_type:{compute_type}, whisper_model: {whisper_model}")
|
234 |
transcription = self.model.transcribe(audio_nparray, batch_size=batch_size,language=language)
|
235 |
if info:
|
236 |
+
print(transcription["segments"][0:10000]) # before alignment
|
237 |
+
logger.info(transcription["segments"][0:10000])
|
238 |
|
239 |
# 3. align
|
240 |
if alignment:
|
|
|
244 |
transcription = whisperx.align(
|
245 |
transcription["segments"], model_a, metadata, audio_nparray, device, return_char_alignments=False)
|
246 |
if info:
|
247 |
+
print(transcription["segments"][0:10000])
|
248 |
+
logger.info(transcription["segments"][0:10000])
|
249 |
|
250 |
# 4. Assign speaker labels
|
251 |
logger.info("--------------- STARTING DIARIZATION ------------------------")
|
|
|
258 |
|
259 |
transcription = whisperx.assign_word_speakers(diarize_segments, transcription)
|
260 |
if info:
|
261 |
+
print(transcription["segments"][0:10000])
|
262 |
+
logger.info(transcription["segments"][0:10000]) # segments are now assigned speaker IDs
|
263 |
|
264 |
if torch.cuda.is_available():
|
265 |
logger.info("--------------- GPU ------------------------")
|