|
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') |
|
|
|
|
|
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() |
|
|