()
| 449 | |
| 450 | |
| 451 | def main() -> None: |
| 452 | parser = argparse.ArgumentParser( |
| 453 | description="Generate audio fixtures for VocalDetector tests" |
| 454 | ) |
| 455 | parser.add_argument( |
| 456 | "--output", |
| 457 | type=Path, |
| 458 | default=Path("tests/data/audio"), |
| 459 | help="Output directory (default: tests/data/audio)", |
| 460 | ) |
| 461 | parser.add_argument( |
| 462 | "--synth-only", |
| 463 | action="store_true", |
| 464 | help="Use synthetic generation only (no downloads)", |
| 465 | ) |
| 466 | parser.add_argument( |
| 467 | "--cache-dir", |
| 468 | type=Path, |
| 469 | default=Path(tempfile.gettempdir()) / "fastled_audio_cache", |
| 470 | help="Cache directory for downloads", |
| 471 | ) |
| 472 | args = parser.parse_args() |
| 473 | |
| 474 | ffmpeg = find_ffmpeg() |
| 475 | print(f"Using ffmpeg: {ffmpeg}") |
| 476 | |
| 477 | # Create output directories |
| 478 | stems_dir = args.output / "stems" |
| 479 | mixes_dir = args.output / "mixes" |
| 480 | stems_dir.mkdir(parents=True, exist_ok=True) |
| 481 | mixes_dir.mkdir(parents=True, exist_ok=True) |
| 482 | args.cache_dir.mkdir(parents=True, exist_ok=True) |
| 483 | |
| 484 | # --- Generate stems --- |
| 485 | print("\n=== Generating stems ===") |
| 486 | all_stems = ["voice_male", "voice_female", "guitar_acoustic", "drums_jazz"] |
| 487 | |
| 488 | for stem_name in all_stems: |
| 489 | output_path = stems_dir / f"{stem_name}.ogg" |
| 490 | if output_path.exists(): |
| 491 | print( |
| 492 | f" {stem_name}: already exists ({output_path.stat().st_size // 1024}KB)" |
| 493 | ) |
| 494 | continue |
| 495 | |
| 496 | downloaded = False |
| 497 | if not args.synth_only and stem_name in SOURCES: |
| 498 | src = SOURCES[stem_name] |
| 499 | downloaded = download_and_trim( |
| 500 | ffmpeg, src["url"], src["start"], output_path, args.cache_dir |
| 501 | ) |
| 502 | |
| 503 | if not downloaded: |
| 504 | print(f" {stem_name}: using synthetic fallback") |
| 505 | generate_synthetic_stem(ffmpeg, stem_name, output_path) |
| 506 | |
| 507 | # --- Generate mixes --- |
| 508 | print("\n=== Generating mixes ===") |
no test coverage detected