Spaces:
Runtime error
Runtime error
File size: 1,426 Bytes
b2bd144 |
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 gradio as gr
import numpy as np
from TTS.utils.manage import ModelManager
from TTS.utils.synthesizer import Synthesizer
title = "Mandarin Text-to-Speech (TTS)"
description = "Generate mandarin speech from text using a Tachotron2 model with Coqui TTS 🐸, " \
"a deep learning toolkit for Text-to-Speech."
article = "<p style='text-align: center'><a href='https://github.com/eugenesiow/practical-ml'>Github</a></p>"
examples = [
["语音合成是通过机械的、电子的方法产生人造语音的技术。"],
["李显龙总理表示,我国要达到像意大利的开放程度,几乎回到冠病疫情前的生活,还需要一段时间。"]
]
manager = ModelManager()
model_path, config_path, model_item = manager.download_model("tts_models/zh-CN/baker/tacotron2-DDC-GST")
synthesizer = Synthesizer(
model_path, config_path, None, None, None,
)
def inference(text: str):
print(text)
wavs = synthesizer.tts(text)
output = (synthesizer.output_sample_rate, np.array(wavs))
return output
gr.Interface(
fn=inference,
inputs=[
gr.inputs.Textbox(
label="Input",
default="你好吗?我很好。",
),
],
outputs=gr.outputs.Audio(label="Output"),
title=title,
description=description,
article=article,
examples=examples,
enable_queue=True,
allow_flagging=False,
).launch(debug=False)
|