Save generation number
Browse files
app.py
CHANGED
@@ -13,6 +13,10 @@ import gradio as gr
|
|
13 |
from TTS.api import TTS
|
14 |
from TTS.utils.manage import ModelManager
|
15 |
|
|
|
|
|
|
|
|
|
16 |
max_64_bit_int = 2**63 - 1
|
17 |
model_names = TTS().list_models()
|
18 |
print(model_names.__dict__)
|
@@ -39,12 +43,18 @@ def save_preferences(preferences, value):
|
|
39 |
preferences["language-id"] = value
|
40 |
return preferences
|
41 |
|
|
|
|
|
|
|
|
|
42 |
def load_preferences(saved_prefs):
|
|
|
|
|
|
|
|
|
43 |
if saved_prefs is None:
|
44 |
-
saved_prefs =
|
45 |
-
|
46 |
-
}
|
47 |
-
return saved_prefs["language-id"]
|
48 |
|
49 |
def update_output(output_number):
|
50 |
return [
|
@@ -200,8 +210,7 @@ def predict_on_gpu(
|
|
200 |
)
|
201 |
|
202 |
with gr.Blocks() as interface:
|
203 |
-
local_storage = gr.BrowserState(
|
204 |
-
"language-id": "en",})
|
205 |
gr.HTML(
|
206 |
"""
|
207 |
<h1><center>XTTS</center></h1>
|
@@ -251,6 +260,7 @@ Leave a star on the Github <a href="https://github.com/coqui-ai/TTS">TTS</a>, wh
|
|
251 |
],
|
252 |
max_choices=1,
|
253 |
elem_id = "language-id",
|
|
|
254 |
)
|
255 |
gr.HTML("More languages <a href='https://huggingface.co/spaces/Brasd99/TTS-Voice-Cloner'>here</a>")
|
256 |
gender = gr.Radio(
|
@@ -396,6 +406,13 @@ You can also install XTTS on your computer using docker but it's more complicate
|
|
396 |
], outputs = [
|
397 |
local_storage
|
398 |
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
|
400 |
submit.click(fn = update_output, inputs = [
|
401 |
generation_number
|
@@ -542,7 +559,8 @@ You can also install XTTS on your computer using docker but it's more complicate
|
|
542 |
fn=load_preferences, inputs = [
|
543 |
local_storage
|
544 |
], outputs = [
|
545 |
-
language
|
|
|
546 |
]
|
547 |
)
|
548 |
|
|
|
13 |
from TTS.api import TTS
|
14 |
from TTS.utils.manage import ModelManager
|
15 |
|
16 |
+
default_local_storage = {
|
17 |
+
"language-id": "en",
|
18 |
+
"generation-number-id": 1,
|
19 |
+
}
|
20 |
max_64_bit_int = 2**63 - 1
|
21 |
model_names = TTS().list_models()
|
22 |
print(model_names.__dict__)
|
|
|
43 |
preferences["language-id"] = value
|
44 |
return preferences
|
45 |
|
46 |
+
def save_preferences_generation_number(preferences, value):
|
47 |
+
preferences["generation-number-id"] = value
|
48 |
+
return preferences
|
49 |
+
|
50 |
def load_preferences(saved_prefs):
|
51 |
+
saved_prefs = init_preferences(saved_prefs)
|
52 |
+
return [saved_prefs["language-id"], saved_prefs["generation-number-id"]]
|
53 |
+
|
54 |
+
def init_preferences(saved_prefs):
|
55 |
if saved_prefs is None:
|
56 |
+
saved_prefs = default_local_storage
|
57 |
+
return saved_prefs
|
|
|
|
|
58 |
|
59 |
def update_output(output_number):
|
60 |
return [
|
|
|
210 |
)
|
211 |
|
212 |
with gr.Blocks() as interface:
|
213 |
+
local_storage = gr.BrowserState(default_local_storage)
|
|
|
214 |
gr.HTML(
|
215 |
"""
|
216 |
<h1><center>XTTS</center></h1>
|
|
|
260 |
],
|
261 |
max_choices=1,
|
262 |
elem_id = "language-id",
|
263 |
+
value = "en",
|
264 |
)
|
265 |
gr.HTML("More languages <a href='https://huggingface.co/spaces/Brasd99/TTS-Voice-Cloner'>here</a>")
|
266 |
gender = gr.Radio(
|
|
|
406 |
], outputs = [
|
407 |
local_storage
|
408 |
])
|
409 |
+
|
410 |
+
generation_number.change(fn = save_preferences_generation_number, inputs = [
|
411 |
+
local_storage,
|
412 |
+
generation_number,
|
413 |
+
], outputs = [
|
414 |
+
local_storage
|
415 |
+
])
|
416 |
|
417 |
submit.click(fn = update_output, inputs = [
|
418 |
generation_number
|
|
|
559 |
fn=load_preferences, inputs = [
|
560 |
local_storage
|
561 |
], outputs = [
|
562 |
+
language,
|
563 |
+
generation_number
|
564 |
]
|
565 |
)
|
566 |
|