Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,2 +1,89 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
import torch
|
4 |
+
import os
|
5 |
+
import zipfile
|
6 |
+
import requests
|
7 |
+
from TTS.api import TTS
|
8 |
+
|
9 |
+
|
10 |
+
os.environ["COQUI_TOS_AGREED"] = "1"
|
11 |
+
|
12 |
+
device = "cuda"
|
13 |
+
|
14 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
15 |
+
|
16 |
+
def clone(text, url, language):
|
17 |
+
response = requests.get(url)
|
18 |
+
|
19 |
+
with open("temp.zip", "wb") as f:
|
20 |
+
f.write(response.content)
|
21 |
+
|
22 |
+
with zipfile.ZipFile("temp.zip", "r") as zip_ref:
|
23 |
+
zip_ref.extractall()
|
24 |
+
|
25 |
+
audio_file = [f for f in os.listdir(".") if f.endswith(".wav")][0]
|
26 |
+
|
27 |
+
tts.tts_to_file(text=text, speaker_wav=audio_file, language=language, file_path="./output.wav")
|
28 |
+
|
29 |
+
os.remove(audio_file)
|
30 |
+
os.remove("temp.zip")
|
31 |
+
|
32 |
+
return "./output.wav"
|
33 |
+
|
34 |
+
iface = gr.Interface(fn=clone,
|
35 |
+
inputs=["text", gr.components.Text(label="URL"), gr.Dropdown(choices=["en", "es", "fr", "de", "it", "ja", "zh-CN", "zh-TW"], label="Language")],
|
36 |
+
outputs=gr.Audio(type='filepath'),
|
37 |
+
title='Voice Clone',
|
38 |
+
description="""
|
39 |
+
by [Angetyde](https://youtube.com/@Angetyde?si=7nusP31nTumIkPTF) and [Tony Assi](https://www.tonyassi.com/ )
|
40 |
+
|
41 |
+
use this colab with caution <3.
|
42 |
+
""",
|
43 |
+
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate"))
|
44 |
+
|
45 |
+
iface.launch(share=True)
|
46 |
+
import gradio as gr
|
47 |
+
import torch
|
48 |
+
import os
|
49 |
+
import zipfile
|
50 |
+
import requests
|
51 |
+
from TTS.api import TTS
|
52 |
+
|
53 |
+
|
54 |
+
os.environ["COQUI_TOS_AGREED"] = "1"
|
55 |
+
|
56 |
+
device = "cuda"
|
57 |
+
|
58 |
+
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
59 |
+
|
60 |
+
def clone(text, url, language):
|
61 |
+
response = requests.get(url)
|
62 |
+
|
63 |
+
with open("temp.zip", "wb") as f:
|
64 |
+
f.write(response.content)
|
65 |
+
|
66 |
+
with zipfile.ZipFile("temp.zip", "r") as zip_ref:
|
67 |
+
zip_ref.extractall()
|
68 |
+
|
69 |
+
audio_file = [f for f in os.listdir(".") if f.endswith(".wav")][0]
|
70 |
+
|
71 |
+
tts.tts_to_file(text=text, speaker_wav=audio_file, language=language, file_path="./output.wav")
|
72 |
+
|
73 |
+
os.remove(audio_file)
|
74 |
+
os.remove("temp.zip")
|
75 |
+
|
76 |
+
return "./output.wav"
|
77 |
+
|
78 |
+
iface = gr.Interface(fn=clone,
|
79 |
+
inputs=["text", gr.components.Text(label="URL"), gr.Dropdown(choices=["en", "es", "fr", "de", "it", "ja", "zh-CN", "zh-TW"], label="Language")],
|
80 |
+
outputs=gr.Audio(type='filepath'),
|
81 |
+
title='Voice Clone',
|
82 |
+
description="""
|
83 |
+
by [Angetyde](https://youtube.com/@Angetyde?si=7nusP31nTumIkPTF) and [Tony Assi](https://www.tonyassi.com/ )
|
84 |
+
|
85 |
+
use this colab with caution <3.
|
86 |
+
""",
|
87 |
+
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate"))
|
88 |
+
|
89 |
+
iface.launch(share=True)
|