File size: 661 Bytes
955a06d
 
d9e2e96
bed5cd1
955a06d
 
 
 
 
576a862
955a06d
 
 
de2f3c2
955a06d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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")