Parse command-line arguments such as model directory and device ID.
()
| 222 | |
| 223 | |
| 224 | def parse_arguments(): |
| 225 | """ |
| 226 | Parse command-line arguments such as model directory and device ID. |
| 227 | """ |
| 228 | parser = argparse.ArgumentParser(description="Spark TTS Gradio server.") |
| 229 | parser.add_argument( |
| 230 | "--model_dir", |
| 231 | type=str, |
| 232 | default="pretrained_models/Spark-TTS-0.5B", |
| 233 | help="Path to the model directory." |
| 234 | ) |
| 235 | parser.add_argument( |
| 236 | "--device", |
| 237 | type=int, |
| 238 | default=0, |
| 239 | help="ID of the GPU device to use (e.g., 0 for cuda:0)." |
| 240 | ) |
| 241 | parser.add_argument( |
| 242 | "--server_name", |
| 243 | type=str, |
| 244 | default="0.0.0.0", |
| 245 | help="Server host/IP for Gradio app." |
| 246 | ) |
| 247 | parser.add_argument( |
| 248 | "--server_port", |
| 249 | type=int, |
| 250 | default=7860, |
| 251 | help="Server port for Gradio app." |
| 252 | ) |
| 253 | return parser.parse_args() |
| 254 | |
| 255 | if __name__ == "__main__": |
| 256 | # Parse command-line arguments |