Spaces:
Sleeping
Sleeping
File size: 915 Bytes
f3c0815 44aa222 f3c0815 44aa222 5622ebb e7983a7 5622ebb f3c0815 44aa222 44922b9 7a21455 a9a3010 f3c0815 44aa222 f9d0c83 f3c0815 f9d0c83 a9a3010 44aa222 f3c0815 f9d0c83 |
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
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()
|