File size: 632 Bytes
9617188 |
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 |
import gradio as gr
import nltk
import os
os.system('python -m unidic download')
from melo.api import TTS
nltk.download('averaged_perceptron_tagger_eng')
# Get device
device = 'auto'
model = TTS(language='EN', device=device)
speaker_ids = model.hps.data.spk2id
def inference(text: str):
output_path = 'en-us.wav'
model.tts_to_file(text, speaker_ids['EN-US'], output_path, speed=1.0)
return output_path
if __name__ == "__main__":
demo = gr.Interface(
fn=inference,
inputs=[
gr.Textbox(),
],
outputs=[
gr.Audio()
],
)
demo.queue().launch()
|