Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
from TTS.api import TTS
|
3 |
|
4 |
-
# Initialize Coqui TTS
|
5 |
tts = TTS(model_name="coqui/XTTS-v2", progress_bar=False)
|
6 |
|
7 |
def generate_speech(text):
|
8 |
-
# Generate a unique filename for the audio
|
9 |
output_file = "/tmp/output.wav"
|
10 |
-
tts.tts_to_file(
|
|
|
|
|
|
|
|
|
|
|
11 |
return output_file
|
12 |
|
13 |
# Create a Gradio interface
|
14 |
with gr.Blocks() as demo:
|
15 |
-
gr.Markdown("# Coqui
|
16 |
gr.Markdown("Type some text and hear it spoken!")
|
17 |
|
18 |
input_text = gr.Textbox(label="Enter Text", placeholder="Type something...")
|
@@ -21,5 +25,4 @@ with gr.Blocks() as demo:
|
|
21 |
submit_button = gr.Button("Generate Speech")
|
22 |
submit_button.click(generate_speech, inputs=input_text, outputs=output_audio)
|
23 |
|
24 |
-
|
25 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from TTS.api import TTS
|
3 |
|
4 |
+
# Initialize Coqui TTS with XTTS-v2
|
5 |
tts = TTS(model_name="coqui/XTTS-v2", progress_bar=False)
|
6 |
|
7 |
def generate_speech(text):
|
|
|
8 |
output_file = "/tmp/output.wav"
|
9 |
+
tts.tts_to_file(
|
10 |
+
text=text,
|
11 |
+
file_path=output_file,
|
12 |
+
speaker_wav="reference.wav", # Replace with the path to your reference audio
|
13 |
+
language="en" # Specify the language (e.g., "en" for English)
|
14 |
+
)
|
15 |
return output_file
|
16 |
|
17 |
# Create a Gradio interface
|
18 |
with gr.Blocks() as demo:
|
19 |
+
gr.Markdown("# Coqui XTTS-v2 Demo")
|
20 |
gr.Markdown("Type some text and hear it spoken!")
|
21 |
|
22 |
input_text = gr.Textbox(label="Enter Text", placeholder="Type something...")
|
|
|
25 |
submit_button = gr.Button("Generate Speech")
|
26 |
submit_button.click(generate_speech, inputs=input_text, outputs=output_audio)
|
27 |
|
28 |
+
demo.launch(share=True)
|
|