TextToSpeech / app.py
HappyElephant's picture
Update app.py
22cc11f
raw
history blame
719 Bytes
import gradio as gr
from TTS.api import TTS
model_name = TTS.list_models()[0]
# Init TTS
tts = TTS(model_name)
def text_to_speech(text: str, speaker_wav, language: str):
# Use the 'speaker_wav' parameter to get the path of the uploaded audio file
tts.tts_to_file(text, speaker_wav=speaker_wav, language=language, file_path="output.wav")
return 'output.wav'
inputs = [gr.Textbox(label="Input", value="Hello!", max_lines=3),
gr.File(label="Speaker Wav", accept=".wav,.mp3"),
gr.Radio(label="Language", choices=tts.languages, value="en")]
outputs = gr.Audio(label="Output", type="filepath")
demo = gr.Interface(fn=text_to_speech, inputs=inputs, outputs=outputs)
demo.launch(debug=True)