Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import click
- import torchaudio as ta
- from chatterbox.tts import ChatterboxTTS
- import sys
- @click.command()
- @click.option('--text', default=None, help='Text to synthesize (omit for stdin)')
- @click.option('--exaggeration', default=0.5, help='Model exaggeration param')
- @click.option('--cfg_weight', default=0.5, help='Model cfg weight param')
- @click.option('--out', required=True, help='Path to the output file')
- @click.option('--audio-prompt-path', default=None, help='Path to the audio prompt file')
- def synthesize(text, exaggeration, cfg_weight, out, audio_prompt_path):
- model = ChatterboxTTS.from_pretrained(device="cuda")
- if text is None:
- text = sys.stdin.read()
- wav = model.generate(text, exaggeration=exaggeration, cfg_weight=cfg_weight, audio_prompt_path=audio_prompt_path)
- ta.save(out, wav, model.sr)
- print(f"Wrote {out}")
- if __name__ == '__main__':
- synthesize()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement