Spaces:
Runtime error
Runtime error
File size: 1,410 Bytes
22418d0 248e723 c7e9d11 22418d0 c7e9d11 22418d0 248e723 22418d0 248e723 22418d0 248e723 f5355fe 22418d0 c7e9d11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import random
import numpy as np
import torch
from chatterbox.src.orator.tts import OratorTTS
import gradio as gr
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
model = OratorTTS.from_pretrained(DEVICE)
def generate(text, audio_prompt_path, exaggeration, pace, temperature, seed_num):
with torch.inference_mode():
wav = model.generate(
text,
audio_prompt_path=audio_prompt_path,
emotion_adv=exaggeration,
)
return model.sr, wav.squeeze(0).numpy()
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
text = gr.Textbox(value="I know what you're thinking. \"Did he fire six shots, or only five?\" Well, to tell you the truth, in all this excitement, I kind of lost track myself.", label="Text to synthesize")
ref_wav = gr.Audio(sources="upload", type="filepath", label="Reference Audio File")
exaggeration = gr.Slider(0.25, 2, step=.05, label="Exaggeration (Neutral = 0.5, extreme values can be unstable)", value=.5)
run_btn = gr.Button("Generate", variant="primary")
with gr.Column():
audio_output = gr.Audio(label="Output Audio")
run_btn.click(
fn=generate,
inputs=[
text,
ref_wav,
exaggeration,
],
outputs=audio_output,
)
if __name__ == "__main__":
demo.launch()
|