()
| 253 | |
| 254 | |
| 255 | def main(): |
| 256 | parser = argparse.ArgumentParser(description="TTS inference with Asteroid model") |
| 257 | parser.add_argument( |
| 258 | "--jsonl", |
| 259 | default="examples/examples.jsonl", |
| 260 | help="Path to JSONL file (default: examples/examples.jsonl)", |
| 261 | ) |
| 262 | parser.add_argument( |
| 263 | "--seed", |
| 264 | type=int, |
| 265 | default=None, |
| 266 | help="Random seed for reproducibility (default: None)", |
| 267 | ) |
| 268 | parser.add_argument( |
| 269 | "--output_dir", |
| 270 | default="outputs/streamer", |
| 271 | help="Output directory for generated audio files (default: outputs)", |
| 272 | ) |
| 273 | parser.add_argument( |
| 274 | "--use_normalize", |
| 275 | action="store_true", |
| 276 | default=True, |
| 277 | help="Whether to use text normalization (default: True)", |
| 278 | ) |
| 279 | parser.add_argument( |
| 280 | "--dtype", |
| 281 | choices=["bf16", "fp16", "fp32"], |
| 282 | default="bf16", |
| 283 | help="Model data type (default: bf16)", |
| 284 | ) |
| 285 | parser.add_argument( |
| 286 | "--attn_implementation", |
| 287 | choices=["flash_attention_2", "sdpa", "eager"], |
| 288 | default="flash_attention_2", |
| 289 | help="Attention implementation (default: flash_attention_2)", |
| 290 | ) |
| 291 | parser.add_argument( |
| 292 | "--use_tqdm", |
| 293 | action="store_true", |
| 294 | default=False, |
| 295 | help="Whether to show progress bar using tqdm (default: False)", |
| 296 | ) |
| 297 | |
| 298 | args = parser.parse_args() |
| 299 | |
| 300 | # Convert dtype string to torch dtype |
| 301 | dtype_mapping = { |
| 302 | "bf16": torch.bfloat16, |
| 303 | "fp16": torch.float16, |
| 304 | "fp32": torch.float32, |
| 305 | } |
| 306 | torch_dtype = dtype_mapping[args.dtype] |
| 307 | |
| 308 | # Create output directory if it doesn't exist |
| 309 | os.makedirs(args.output_dir, exist_ok=True) |
| 310 | |
| 311 | device = "cuda" if torch.cuda.is_available() else "cpu" |
| 312 | print(f"Using device: {device}") |
no test coverage detected