Use a structure
Browse files
app.py
CHANGED
@@ -35,6 +35,17 @@ else:
|
|
35 |
tts = TTS(model_name, gpu=torch.cuda.is_available())
|
36 |
tts.to(device_type)
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
def update_output(output_number):
|
39 |
return [
|
40 |
gr.update(visible = True),
|
@@ -189,7 +200,8 @@ def predict_on_gpu(
|
|
189 |
)
|
190 |
|
191 |
with gr.Blocks() as interface:
|
192 |
-
local_storage = gr.BrowserState("
|
|
|
193 |
gr.HTML(
|
194 |
"""
|
195 |
<h1><center>XTTS</center></h1>
|
@@ -378,8 +390,9 @@ You can install _Pinokio_ locally and then install _XTTS_ into it. It should be
|
|
378 |
You can also install XTTS on your computer using docker but it's more complicate.
|
379 |
""")
|
380 |
|
381 |
-
language.change(
|
382 |
-
|
|
|
383 |
], outputs = [
|
384 |
local_storage
|
385 |
])
|
@@ -526,7 +539,7 @@ You can also install XTTS on your computer using docker but it's more complicate
|
|
526 |
|
527 |
# Load saved preferences when the page loads
|
528 |
interface.load(
|
529 |
-
fn=
|
530 |
local_storage
|
531 |
], outputs = [
|
532 |
language
|
|
|
35 |
tts = TTS(model_name, gpu=torch.cuda.is_available())
|
36 |
tts.to(device_type)
|
37 |
|
38 |
+
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 |
+
"language-id": "en",
|
46 |
+
}
|
47 |
+
return saved_prefs["language-id"]
|
48 |
+
|
49 |
def update_output(output_number):
|
50 |
return [
|
51 |
gr.update(visible = True),
|
|
|
200 |
)
|
201 |
|
202 |
with gr.Blocks() as interface:
|
203 |
+
local_storage = gr.BrowserState({ #"user_preferences":
|
204 |
+
"language-id": "en",})
|
205 |
gr.HTML(
|
206 |
"""
|
207 |
<h1><center>XTTS</center></h1>
|
|
|
390 |
You can also install XTTS on your computer using docker but it's more complicate.
|
391 |
""")
|
392 |
|
393 |
+
language.change(fn = save_preferences, inputs = [
|
394 |
+
local_storage,
|
395 |
+
language,
|
396 |
], outputs = [
|
397 |
local_storage
|
398 |
])
|
|
|
539 |
|
540 |
# Load saved preferences when the page loads
|
541 |
interface.load(
|
542 |
+
fn=load_preferences, inputs = [
|
543 |
local_storage
|
544 |
], outputs = [
|
545 |
language
|