Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -2,32 +2,37 @@ import os
|
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
from TTS.api import TTS
|
|
|
5 |
|
6 |
# Agree to Coqui TOS
|
7 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
8 |
|
9 |
-
#
|
10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
11 |
-
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", device=device)
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
def clone(text, audio):
|
14 |
output_path = "./output.wav"
|
15 |
tts.tts_to_file(text=text, speaker_wav=audio, language="en", file_path=output_path)
|
16 |
return output_path
|
17 |
|
18 |
-
# Define the UI using Blocks
|
19 |
with gr.Blocks(title="Advanced Voice Clone", theme=gr.themes.Soft(primary_hue="teal")) as demo:
|
20 |
gr.Markdown(
|
21 |
"""
|
22 |
# 🎤 Voice Clone
|
23 |
|
24 |
-
**by
|
25 |
|
26 |
This application uses the **xtts_v2** model for voice cloning.
|
27 |
*Non-commercial use only.*
|
28 |
|
29 |
[Coqui Public Model License](https://coqui.ai/cpml) |
|
30 |
-
|
31 |
|
32 |
---
|
33 |
"""
|
@@ -53,25 +58,6 @@ with gr.Blocks(title="Advanced Voice Clone", theme=gr.themes.Soft(primary_hue="t
|
|
53 |
label="Cloned Voice Output",
|
54 |
interactive=False
|
55 |
)
|
56 |
-
with gr.Accordion("Example Voices", open=False):
|
57 |
-
gr.Markdown(
|
58 |
-
"""
|
59 |
-
### Preloaded Examples
|
60 |
-
|
61 |
-
- **Dorothy from Wizard of Oz**
|
62 |
-
- *Sample Audio:* [Download](./audio/Wizard-of-Oz-Dorthy.wav)
|
63 |
-
- **Vito Corleone from The Godfather**
|
64 |
-
- *Sample Audio:* [Download](./audio/Godfather.wav)
|
65 |
-
- **Paris Hilton**
|
66 |
-
- *Sample Audio:* [Download](./audio/Paris-Hilton.mp3)
|
67 |
-
- **Megan Fox from Transformers**
|
68 |
-
- *Sample Audio:* [Download](./audio/Megan-Fox.mp3)
|
69 |
-
- **Jeff Goldblum**
|
70 |
-
- *Sample Audio:* [Download](./audio/Jeff-Goldblum.mp3)
|
71 |
-
- **Heath Ledger as the Joker**
|
72 |
-
- *Sample Audio:* [Download](./audio/Heath-Ledger.mp3)
|
73 |
-
"""
|
74 |
-
)
|
75 |
|
76 |
gr.Markdown(
|
77 |
"""
|
|
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
from TTS.api import TTS
|
5 |
+
import spaces # Ensure this import is available in your environment
|
6 |
|
7 |
# Agree to Coqui TOS
|
8 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
9 |
|
10 |
+
# Determine the device
|
11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
12 |
|
13 |
+
# Initialize TTS model without the 'device' parameter
|
14 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
|
15 |
+
tts.to(device)
|
16 |
+
|
17 |
+
@spaces.GPU(enable_queue=True)
|
18 |
def clone(text, audio):
|
19 |
output_path = "./output.wav"
|
20 |
tts.tts_to_file(text=text, speaker_wav=audio, language="en", file_path=output_path)
|
21 |
return output_path
|
22 |
|
23 |
+
# Define the UI using Gradio Blocks with enhanced styling
|
24 |
with gr.Blocks(title="Advanced Voice Clone", theme=gr.themes.Soft(primary_hue="teal")) as demo:
|
25 |
gr.Markdown(
|
26 |
"""
|
27 |
# 🎤 Voice Clone
|
28 |
|
29 |
+
**by Vortex**
|
30 |
|
31 |
This application uses the **xtts_v2** model for voice cloning.
|
32 |
*Non-commercial use only.*
|
33 |
|
34 |
[Coqui Public Model License](https://coqui.ai/cpml) |
|
35 |
+
|
36 |
|
37 |
---
|
38 |
"""
|
|
|
58 |
label="Cloned Voice Output",
|
59 |
interactive=False
|
60 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
gr.Markdown(
|
63 |
"""
|