Update app.py
Browse files
app.py
CHANGED
@@ -2,4 +2,29 @@ from TTS.api import TTS
|
|
2 |
import gradio as gr
|
3 |
|
4 |
# Initialize the TTS model
|
5 |
-
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
# Initialize the TTS model
|
5 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=True)
|
6 |
+
|
7 |
+
@spaces.GPU
|
8 |
+
def generate_speech(text, speaker_wav, language):
|
9 |
+
# Generate speech using the provided text, speaker voice, and language
|
10 |
+
file_path = "output.wav"
|
11 |
+
tts.tts_to_file(text=text,
|
12 |
+
file_path=file_path,
|
13 |
+
speaker_wav=speaker_wav,
|
14 |
+
language=language)
|
15 |
+
return file_path
|
16 |
+
|
17 |
+
# Create the Gradio interface
|
18 |
+
interface = gr.Interface(
|
19 |
+
fn=generate_speech,
|
20 |
+
inputs=[
|
21 |
+
gr.Textbox(label="Enter your text"),
|
22 |
+
gr.Textbox(label="Path to target speaker WAV file", value="/content/speaker.wav"),
|
23 |
+
gr.Dropdown(label="Language", choices=["en"], value="en")
|
24 |
+
],
|
25 |
+
outputs="audio",
|
26 |
+
title="Voice Synthesis and Cloning with Coqui-XTTS",
|
27 |
+
description="Synthesize speech using a target voice and language."
|
28 |
+
)
|
29 |
+
# Launch the interface
|
30 |
+
interface.launch()
|