Spaces:
Runtime error
Runtime error
File size: 719 Bytes
22cc11f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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) |