Download scripts/run_pilot.py from TTS-AGI/speech-performance-arena: direct link, hf CLI and curl.
- Browser
- Download file 3.03 kB
-
https://huggingface.co/spaces/TTS-AGI/speech-performance-arena/resolve/main/scripts/run_pilot.py
- Command line
-
hf download hf://spaces/TTS-AGI/speech-performance-arena/scripts/run_pilot.py
-
curl -L -o run_pilot.py https://huggingface.co/spaces/TTS-AGI/speech-performance-arena/resolve/main/scripts/run_pilot.py
3.03 kB
| #!/usr/bin/env python3 | |
| """Run generation and QC as one resumable Speech Performance Arena workflow.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def run(command: list[str], *, tolerate_failure: bool = False) -> int: | |
| print("+ " + " ".join(command), flush=True) | |
| result = subprocess.run(command, cwd=ROOT) | |
| if result.returncode and not tolerate_failure: | |
| raise SystemExit(result.returncode) | |
| return result.returncode | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("pool", type=Path) | |
| parser.add_argument("keys", type=Path) | |
| parser.add_argument("--output-dir", type=Path, required=True) | |
| parser.add_argument("--profile", action="append", dest="profiles", required=True) | |
| parser.add_argument("--task-id", action="append", dest="task_ids") | |
| parser.add_argument("--hypr-key-source", type=Path) | |
| parser.add_argument("--max-workers", type=int, default=3) | |
| parser.add_argument("--retries", type=int, default=2) | |
| parser.add_argument("--asr", action="store_true") | |
| parser.add_argument("--asr-timeout", type=int, default=90) | |
| parser.add_argument("--skip-generation", action="store_true") | |
| args = parser.parse_args() | |
| output = args.output_dir.resolve() | |
| manifest = output / "manifest.json" | |
| if not args.skip_generation: | |
| command = [ | |
| sys.executable, | |
| str(ROOT / "scripts/generate_batch.py"), | |
| str(args.pool.resolve()), | |
| str(args.keys.resolve()), | |
| "--output-dir", str(output), | |
| "--max-workers", str(args.max_workers), | |
| "--retries", str(args.retries), | |
| ] | |
| for profile in args.profiles: | |
| command.extend(("--profile", profile)) | |
| for task_id in args.task_ids or []: | |
| command.extend(("--task-id", task_id)) | |
| if args.hypr_key_source: | |
| command.extend(("--hypr-key-source", str(args.hypr_key_source.resolve()))) | |
| # Always continue into QC: its report needs to include failed/missing jobs too. | |
| run(command, tolerate_failure=True) | |
| if not manifest.exists(): | |
| raise SystemExit(f"generation produced no manifest: {manifest}") | |
| qc_command = [ | |
| sys.executable, | |
| str(ROOT / "scripts/qc_batch.py"), | |
| str(manifest), | |
| str(args.pool.resolve()), | |
| ] | |
| if args.asr: | |
| qc_command.extend(("--asr", "--asr-timeout", str(args.asr_timeout))) | |
| run(qc_command, tolerate_failure=True) | |
| report = json.loads((output / "qc.json").read_text(encoding="utf-8")) | |
| summary = { | |
| "output_dir": str(output), | |
| "manifest": str(manifest), | |
| "qc_report": str(output / "qc.md"), | |
| **report["summary"], | |
| } | |
| print("\nPilot workflow result") | |
| print(json.dumps(summary, indent=2)) | |
| raise SystemExit(1 if summary["fail"] or summary["missing"] else 0) | |
| if __name__ == "__main__": | |
| main() | |