File size: 732 Bytes
a841504 4e2a62e a841504 4e2a62e a841504 4e2a62e a841504 4e2a62e a841504 4e2a62e |
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 |
import tempfile
import gradio as gr
from piper import PiperVoice
from pathlib import Path
import wave
_FILE = Path(__file__)
_DIR = _FILE.parent
voice = PiperVoice.load(
model_path=_DIR / 'models/rmedium.onnx',
config_path=_DIR / 'models/rmedium.onnx.json'
)
synthesize_args = {}
def tts(text: str):
print(text)
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
with wave.Wave_write(fp) as wav:
voice.synthesize(text, wav, **synthesize_args)
return fp.name
inputs = [gr.Textbox(label="Input", value="Salut, numele meu este Bogdan.", max_lines=10)]
outputs = gr.Audio(label="Output")
demo = gr.Interface(fn=tts, inputs=inputs, outputs=outputs)
demo.launch()
|