Update app.py
Browse files
app.py
CHANGED
@@ -7,14 +7,14 @@ import spaces
|
|
7 |
|
8 |
|
9 |
# Agree to Terms of service
|
10 |
-
os.environ["COQUI_TOS_AGREED"] = "1"
|
11 |
-
|
12 |
-
# Get device
|
13 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
-
|
15 |
-
# Initialize the TTS model
|
16 |
-
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
@spaces.GPU
|
@@ -29,19 +29,33 @@ def generate_speech(text):
|
|
29 |
language=language)
|
30 |
return file_path
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
)
|
44 |
-
#
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
|
|
|
7 |
|
8 |
|
9 |
# Agree to Terms of service
|
10 |
+
# os.environ["COQUI_TOS_AGREED"] = "1"
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
def init_TTS():
|
13 |
+
# Get device
|
14 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
15 |
+
# Initialize the TTS model
|
16 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
17 |
+
return tts
|
18 |
|
19 |
|
20 |
@spaces.GPU
|
|
|
29 |
language=language)
|
30 |
return file_path
|
31 |
|
32 |
+
|
33 |
+
|
34 |
+
def main():
|
35 |
+
|
36 |
+
# call init
|
37 |
+
tts = init_TTS()
|
38 |
+
|
39 |
+
# Create the Gradio interface
|
40 |
+
interface = gr.Interface(
|
41 |
+
fn=generate_speech,
|
42 |
+
inputs=[
|
43 |
+
gr.Textbox(label="Enter your text")
|
44 |
+
#gr.Textbox(label="Path to target speaker WAV file", value="/content/speaker.wav")
|
45 |
+
#gr.Dropdown(label="Language", choices=["en"], value="en")
|
46 |
+
],
|
47 |
+
outputs="audio",
|
48 |
+
title="Voice Synthesis with Coqui-XTTS",
|
49 |
+
description="Synthesize speech using predefined target voice and language."
|
50 |
+
)
|
51 |
+
|
52 |
+
# Launch the interface
|
53 |
+
interface.launch()
|
54 |
+
return 0
|
55 |
+
|
56 |
+
if __name__ == "__main__":
|
57 |
+
main()
|
58 |
+
|
59 |
+
|
60 |
|
61 |
|