Advertisement
Guest User

chatterbox cli

a guest
May 29th, 2025
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import click
  2. import torchaudio as ta
  3. from chatterbox.tts import ChatterboxTTS
  4. import sys
  5.  
  6. @click.command()
  7. @click.option('--text', default=None, help='Text to synthesize (omit for stdin)')
  8. @click.option('--exaggeration', default=0.5, help='Model exaggeration param')
  9. @click.option('--cfg_weight', default=0.5, help='Model cfg weight param')
  10. @click.option('--out', required=True, help='Path to the output file')
  11. @click.option('--audio-prompt-path', default=None, help='Path to the audio prompt file')
  12. def synthesize(text, exaggeration, cfg_weight, out, audio_prompt_path):
  13. model = ChatterboxTTS.from_pretrained(device="cuda")
  14. if text is None:
  15. text = sys.stdin.read()
  16. wav = model.generate(text, exaggeration=exaggeration, cfg_weight=cfg_weight, audio_prompt_path=audio_prompt_path)
  17. ta.save(out, wav, model.sr)
  18. print(f"Wrote {out}")
  19.  
  20. if __name__ == '__main__':
  21. synthesize()
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement