(args, parser, *, text: str, output: str, prompt_text: str | None)
| 242 | |
| 243 | |
| 244 | def _run_single(args, parser, *, text: str, output: str, prompt_text: str | None): |
| 245 | output_path = validate_output_path(output) |
| 246 | |
| 247 | if args.prompt_audio: |
| 248 | require_file_exists(args.prompt_audio, parser, "prompt audio file") |
| 249 | if args.reference_audio: |
| 250 | require_file_exists(args.reference_audio, parser, "reference audio file") |
| 251 | |
| 252 | model = load_model(args) |
| 253 | |
| 254 | audio_array = model.generate( |
| 255 | text=text, |
| 256 | prompt_wav_path=args.prompt_audio, |
| 257 | prompt_text=prompt_text, |
| 258 | reference_wav_path=args.reference_audio, |
| 259 | cfg_value=args.cfg_value, |
| 260 | inference_timesteps=args.inference_timesteps, |
| 261 | normalize=args.normalize, |
| 262 | denoise=args.denoise |
| 263 | and (args.prompt_audio is not None or args.reference_audio is not None), |
| 264 | ) |
| 265 | |
| 266 | import soundfile as sf |
| 267 | |
| 268 | sf.write(str(output_path), audio_array, model.tts_model.sample_rate) |
| 269 | |
| 270 | duration = len(audio_array) / model.tts_model.sample_rate |
| 271 | print(f"Saved audio to: {output_path} ({duration:.2f}s)", file=sys.stderr) |
| 272 | |
| 273 | |
| 274 | def cmd_design(args, parser): |
no test coverage detected
searching dependent graphs…