| |
| import os |
| import sys |
| import shutil |
| from pathlib import Path |
|
|
| |
| REPO_ROOT = Path(__file__).resolve().parent.parent |
| os.chdir(REPO_ROOT) |
| sys.path.insert(0, str(REPO_ROOT)) |
|
|
| |
| import voice_pipeline |
| from voice_pipeline.pipeline import SpeechDataPipeline |
| from voice_pipeline.utils.logger import setup_logging |
|
|
| def main(): |
| setup_logging(log_level="INFO") |
| |
| |
| audio_file = Path("/root/audiodown/6Ak15wj9ePw.wav") |
| if not audio_file.exists(): |
| print(f"Error: {audio_file} does not exist!") |
| sys.exit(1) |
| |
| print(f"Starting test pipeline on: {audio_file}") |
| |
| |
| config_path = REPO_ROOT / "voice_pipeline" / "configs" / "pipeline_config.yaml" |
| |
| |
| from voice_pipeline.utils.checkpoint import CheckpointManager |
| for stage in ["download", "ingest", "audio_normalize", "vad", "diarization", "emotion", "asr", "validation"]: |
| ckpt = CheckpointManager(REPO_ROOT / "data" / ".checkpoints", stage) |
| |
| ckpt_path = Path(REPO_ROOT / "data" / ".checkpoints" / f"{stage}_done.jsonl") |
| if ckpt_path.exists(): |
| |
| from voice_pipeline.utils.file_utils import get_file_hash |
| file_hash = get_file_hash(audio_file, algo="md5") |
| file_id = file_hash[:16] |
| lines = [] |
| with open(ckpt_path, "r") as f: |
| for line in f: |
| if file_id not in line: |
| lines.append(line) |
| with open(ckpt_path, "w") as f: |
| f.writelines(lines) |
| print(f"Cleared checkpoint for stage {stage} for file {file_id}") |
|
|
| pipeline = SpeechDataPipeline(config_path=config_path) |
| |
| print("Running pipeline...") |
| export_dir = pipeline.run_on_file( |
| file_path=audio_file, |
| language="hi", |
| content_type="debate_podcast" |
| ) |
| |
| print("\nPipeline run finished successfully!") |
| print(f"Export directory: {export_dir}") |
| |
| |
| segments_file = export_dir / "segments.jsonl" |
| if segments_file.exists(): |
| print("\nFirst few lines of segments.jsonl:") |
| with open(segments_file, "r") as f: |
| for _ in range(5): |
| line = f.readline() |
| if not line: |
| break |
| print(line.strip()) |
| else: |
| print("\nWarning: segments.jsonl was not generated.") |
|
|
| if __name__ == "__main__": |
| main() |
|
|