Parse command-line arguments.
()
| 26 | |
| 27 | |
| 28 | def parse_args(): |
| 29 | """Parse command-line arguments.""" |
| 30 | parser = argparse.ArgumentParser(description="Run TTS inference.") |
| 31 | |
| 32 | parser.add_argument( |
| 33 | "--model_dir", |
| 34 | type=str, |
| 35 | default="pretrained_models/Spark-TTS-0.5B", |
| 36 | help="Path to the model directory", |
| 37 | ) |
| 38 | parser.add_argument( |
| 39 | "--save_dir", |
| 40 | type=str, |
| 41 | default="example/results", |
| 42 | help="Directory to save generated audio files", |
| 43 | ) |
| 44 | parser.add_argument("--device", type=int, default=0, help="CUDA device number") |
| 45 | parser.add_argument( |
| 46 | "--text", type=str, required=True, help="Text for TTS generation" |
| 47 | ) |
| 48 | parser.add_argument("--prompt_text", type=str, help="Transcript of prompt audio") |
| 49 | parser.add_argument( |
| 50 | "--prompt_speech_path", |
| 51 | type=str, |
| 52 | help="Path to the prompt audio file", |
| 53 | ) |
| 54 | parser.add_argument("--gender", choices=["male", "female"]) |
| 55 | parser.add_argument( |
| 56 | "--pitch", choices=["very_low", "low", "moderate", "high", "very_high"] |
| 57 | ) |
| 58 | parser.add_argument( |
| 59 | "--speed", choices=["very_low", "low", "moderate", "high", "very_high"] |
| 60 | ) |
| 61 | return parser.parse_args() |
| 62 | |
| 63 | |
| 64 | def run_tts(args): |