trained_tts / app.py
Neomindapp's picture
Update app.py
e7983a7 verified
raw
history blame contribute delete
915 Bytes
import gradio as gr
from TTS.api import TTS # Import TTS API
# Initialize TTS
tts = TTS(model_path="best_model.pth", config_path="config.json")
# Override the _check_arguments method to bypass the multilingual check
def _check_arguments_override(language):
# We bypass the check since this model is not multilingual
pass
# Override the method in the TTS instance
tts._check_arguments = _check_arguments_override
def generate_speech(text):
wav = tts.tts(text) # Ensure this is the correct method for generating speech
audio_path = "output.wav"
with open(audio_path, "wb") as f:
f.write(wav)
return audio_path
# Define Gradio interface
iface = gr.Interface(
fn=generate_speech,
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
outputs=gr.Audio(type="filepath"),
title="Text-to-Speech with Coqui TTS"
)
if __name__ == "__main__":
iface.launch()