Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from TTS.api import TTS #
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
config_path = "config.json" # Configuration file
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
def generate_speech(text):
|
| 12 |
-
#
|
| 13 |
-
# Adjust based on the correct method for generating speech
|
| 14 |
-
wav = tts.tts(text) # Ensure this is the correct method for your version
|
| 15 |
-
|
| 16 |
-
# Save the generated audio to a temporary file
|
| 17 |
audio_path = "output.wav"
|
| 18 |
with open(audio_path, "wb") as f:
|
| 19 |
f.write(wav)
|
| 20 |
-
|
| 21 |
return audio_path
|
| 22 |
|
| 23 |
-
# Define
|
| 24 |
iface = gr.Interface(
|
| 25 |
fn=generate_speech,
|
| 26 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
| 27 |
outputs=gr.Audio(type="filepath"),
|
| 28 |
-
title="Text-to-Speech with Coqui TTS"
|
| 29 |
-
description="Generate speech from text using a custom Coqui TTS model."
|
| 30 |
)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from TTS.api import TTS # Import TTS API
|
| 3 |
|
| 4 |
+
# Initialize TTS
|
| 5 |
+
tts = TTS(model_path="best_model.pth", config_path="config.json")
|
|
|
|
| 6 |
|
| 7 |
+
# Ensure the 'is_multi_lingual' attribute is set if it's not present
|
| 8 |
+
if not hasattr(tts, 'is_multi_lingual'):
|
| 9 |
+
tts.is_multi_lingual = False # Set to False since your model is not multilingual
|
| 10 |
|
| 11 |
def generate_speech(text):
|
| 12 |
+
wav = tts.tts(text) # Ensure this is the correct method for generating speech
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
audio_path = "output.wav"
|
| 14 |
with open(audio_path, "wb") as f:
|
| 15 |
f.write(wav)
|
|
|
|
| 16 |
return audio_path
|
| 17 |
|
| 18 |
+
# Define Gradio interface
|
| 19 |
iface = gr.Interface(
|
| 20 |
fn=generate_speech,
|
| 21 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
| 22 |
outputs=gr.Audio(type="filepath"),
|
| 23 |
+
title="Text-to-Speech with Coqui TTS"
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
if __name__ == "__main__":
|