Spaces:
Runtime error
Runtime error
Aryan Gosaliya commited on
Commit ·
7603254
1
Parent(s): 7d4595c
debugging pyannote
Browse files- app/services/asr.py +9 -3
app/services/asr.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
# app/services/asr.py
|
| 2 |
-
|
| 3 |
from typing import List, Dict
|
| 4 |
from faster_whisper import WhisperModel
|
| 5 |
import os
|
|
@@ -59,6 +57,15 @@ def transcribe(audio_path: str) -> List[Dict]:
|
|
| 59 |
# 2. Perform Diarization
|
| 60 |
try:
|
| 61 |
diarization = diarization_pipeline(audio_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
except Exception as e:
|
| 63 |
print(f"Error during diarization: {e}")
|
| 64 |
for seg in whisper_segments:
|
|
@@ -71,7 +78,6 @@ def transcribe(audio_path: str) -> List[Dict]:
|
|
| 71 |
# Find the speaker for the segment's midpoint
|
| 72 |
midpoint = seg["start"] + (seg["end"] - seg["start"]) / 2
|
| 73 |
speaker = "UNKNOWN"
|
| 74 |
-
# CORRECTED LINE: The 'diarization' object is now directly iterable
|
| 75 |
for turn, _, speaker_label in diarization.itertracks(yield_label=True):
|
| 76 |
if turn.start <= midpoint <= turn.end:
|
| 77 |
speaker = speaker_label
|
|
|
|
|
|
|
|
|
|
| 1 |
from typing import List, Dict
|
| 2 |
from faster_whisper import WhisperModel
|
| 3 |
import os
|
|
|
|
| 57 |
# 2. Perform Diarization
|
| 58 |
try:
|
| 59 |
diarization = diarization_pipeline(audio_path)
|
| 60 |
+
|
| 61 |
+
# --- DEBUGGING LINES ADDED HERE ---
|
| 62 |
+
print("\n--- Diarization Output ---")
|
| 63 |
+
print(f"Type of diarization object: {type(diarization)}")
|
| 64 |
+
print("Diarization object content:")
|
| 65 |
+
print(diarization)
|
| 66 |
+
print("--- End Diarization Output ---\n")
|
| 67 |
+
# ------------------------------------
|
| 68 |
+
|
| 69 |
except Exception as e:
|
| 70 |
print(f"Error during diarization: {e}")
|
| 71 |
for seg in whisper_segments:
|
|
|
|
| 78 |
# Find the speaker for the segment's midpoint
|
| 79 |
midpoint = seg["start"] + (seg["end"] - seg["start"]) / 2
|
| 80 |
speaker = "UNKNOWN"
|
|
|
|
| 81 |
for turn, _, speaker_label in diarization.itertracks(yield_label=True):
|
| 82 |
if turn.start <= midpoint <= turn.end:
|
| 83 |
speaker = speaker_label
|