Spaces:
Sleeping
Sleeping
File size: 1,841 Bytes
9f76952 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #It checks whether pyannote can correctly read your dataset (audio + RTTM) using database.yml.
#get_protocol → asks pyannote:“Give me the dataset described in database.yml” FileFinder → helps pyannote find audio files
import os
from pyannote.database import get_protocol, FileFinder
# 1. Setup paths
current_dir = os.path.dirname(os.path.abspath(__file__))
config_path = os.path.join(current_dir, "database.yml")
os.environ["PYANNOTE_DATABASE_CONFIG"] = config_path
# 2. Initialize preprocessor
preprocessors = {'audio': FileFinder()}
# 3. Load the protocol
try:
protocol = get_protocol(
'HindiBhojpuri.SpeakerDiarization.Segmentation',
preprocessors=preprocessors
)
print("Protocol loaded successfully!")
except Exception as e:
print(f"Failed to load protocol: {e}")
exit()
# 4. Detailed Data Verification
# This replaces your previous testing loop
for file in protocol.test():
print("\n" + "="*30)
print(f"FILE URI: {file['uri']}")
print(f"AUDIO PATH: {file['audio']}")
# Load the annotation (the RTTM data)
annotation = file['annotation']
print(f"SEGMENTS FOUND: {len(annotation)}")
print("-" * 30)
print("START | END | SPEAKER")
print("-" * 30)
# Iterate through the first 5 segments to keep the output clean
for i, (segment, track, label) in enumerate(annotation.itertracks(yield_label=True)):
if i >= 5:
print("... (and more)")
break
print(f"{segment.start:9.2f}s | {segment.end:9.2f}s | {label}")
print("="*30)
# Only check the first file for now
break
# database.yml is correct, audio paths are correct
# RTTM files load correctly
# speaker segments exist
# segmentation training CAN start |