Spaces:
Sleeping
Sleeping
import pymatcha | |
import gradio as gr | |
import io | |
from scipy.io import wavfile | |
with open("vocoder.onnx", "rb") as f: | |
vocoder = f.read() | |
with open("model.onnx", "rb") as f: | |
model = f.read() | |
matcha = pymatcha.Matcha(model, vocoder) | |
def generate(text): | |
clean_text = matcha.preprocess(text) | |
mel, mel_lengths = matcha.synthesise(clean_text) | |
wav_data = matcha.decode(mel, mel_lengths) | |
byte_io = io.BytesIO(wav_data) | |
sr, data = wavfile.read(byte_io) | |
return sr, data | |
gradio_app = gr.Interface( | |
fn=generate, | |
inputs=["text"], | |
outputs=[gr.Audio()], | |
) | |
if __name__ == "__main__": | |
gradio_app.launch(server_name="0.0.0.0") |