Spaces:
Running
on
Zero
Running
on
Zero
| import gradio as gr | |
| import torch.cuda | |
| from InferenceInterfaces.ControllableInterface import ControllableInterface | |
| from Utility.utils import float2pcm | |
| class TTSWebUI: | |
| def __init__(self, gpu_id="cpu", title="Simplistic Stochastic Speech Synthesis with ToucanTTS", article="For a multilingual version, have a look at https://huggingface.co/spaces/Flux9665/MassivelyMultilingualTTS"): | |
| self.controllable_ui = ControllableInterface(gpu_id=gpu_id) | |
| self.iface = gr.Interface(fn=self.read, | |
| inputs=[gr.Textbox(lines=2, | |
| placeholder="write what you want the synthesis to read here...", | |
| value="What I cannot create, I do not understand.", | |
| label="Text input"), | |
| max_length=300], | |
| outputs=[gr.Audio(type="numpy", label="Speech")], | |
| title=title, | |
| theme="default", | |
| allow_flagging="never", | |
| article=article) | |
| self.iface.launch() | |
| def read(self, prompt): | |
| sr, wav = self.controllable_ui.read(prompt, -24.) | |
| return sr, float2pcm(wav) | |
| if __name__ == '__main__': | |
| TTSWebUI(gpu_id="cuda" if torch.cuda.is_available() else "cpu") | |