Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
mrfakename
commited on
Commit
•
ca8a2ca
1
Parent(s):
84a5bec
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,19 @@ import time
|
|
10 |
import uuid
|
11 |
from pathlib import Path
|
12 |
from huggingface_hub import CommitScheduler, delete_file, hf_hub_download
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
SPACE_ID = os.getenv('HF_ID')
|
15 |
|
@@ -20,7 +33,6 @@ DB_NAME = "database.db"
|
|
20 |
DB_PATH = f"/data/{DB_NAME}" if os.path.isdir("/data") else DB_NAME
|
21 |
|
22 |
AUDIO_DATASET_ID = "ttseval/tts-arena-new"
|
23 |
-
CITATION_TEXT = None
|
24 |
CITATION_TEXT = """@misc{tts-arena,
|
25 |
title = {Text to Speech Arena},
|
26 |
author = {mrfakename and Srivastav, Vaibhav and Pouget, Lucain and Fourrier, Clémentine},
|
@@ -114,6 +126,10 @@ scheduler = CommitScheduler(
|
|
114 |
# Load audio dataset
|
115 |
audio_dataset = load_dataset(AUDIO_DATASET_ID)
|
116 |
|
|
|
|
|
|
|
|
|
117 |
####################################
|
118 |
# Gradio app
|
119 |
####################################
|
@@ -182,7 +198,7 @@ def del_db(txt):
|
|
182 |
|
183 |
# Delete local + remote
|
184 |
os.remove(DB_PATH)
|
185 |
-
delete_file(path_in_repo=DB_NAME, repo_id=
|
186 |
|
187 |
# Recreate
|
188 |
create_db_if_missing()
|
@@ -396,18 +412,26 @@ with gr.Blocks() as leaderboard:
|
|
396 |
# bothgood.click(both_good, outputs=outputs, inputs=[model1, model2, useridstate])
|
397 |
|
398 |
# vote.load(reload, outputs=[aud1, aud2, model1, model2])
|
399 |
-
def
|
400 |
-
|
|
|
401 |
return (
|
402 |
text,
|
|
|
403 |
gr.update(visible=True), # r1
|
404 |
gr.update(visible=True), # r2
|
405 |
-
|
406 |
-
|
407 |
-
'
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
)
|
412 |
with gr.Blocks() as vote:
|
413 |
useridstate = gr.State()
|
@@ -433,11 +457,12 @@ with gr.Blocks() as vote:
|
|
433 |
with gr.Row():
|
434 |
abetter = gr.Button("A is Better", variant='primary')
|
435 |
bbetter = gr.Button("B is Better", variant='primary')
|
436 |
-
|
|
|
437 |
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
# skipbtn.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])
|
442 |
|
443 |
# bothbad.click(both_bad, outputs=outputs, inputs=[model1, model2, useridstate])
|
|
|
10 |
import uuid
|
11 |
from pathlib import Path
|
12 |
from huggingface_hub import CommitScheduler, delete_file, hf_hub_download
|
13 |
+
from gradio_client import Client
|
14 |
+
|
15 |
+
####################################
|
16 |
+
# Constants
|
17 |
+
####################################
|
18 |
+
|
19 |
+
AVAILABLE_MODELS = {
|
20 |
+
'XTTS': 'xttsv2',
|
21 |
+
'WhisperSpeech': 'whisperspeech',
|
22 |
+
'ElevenLabs': 'eleven',
|
23 |
+
'OpenVoice': 'openvoice',
|
24 |
+
'Pheme': 'pheme',
|
25 |
+
}
|
26 |
|
27 |
SPACE_ID = os.getenv('HF_ID')
|
28 |
|
|
|
33 |
DB_PATH = f"/data/{DB_NAME}" if os.path.isdir("/data") else DB_NAME
|
34 |
|
35 |
AUDIO_DATASET_ID = "ttseval/tts-arena-new"
|
|
|
36 |
CITATION_TEXT = """@misc{tts-arena,
|
37 |
title = {Text to Speech Arena},
|
38 |
author = {mrfakename and Srivastav, Vaibhav and Pouget, Lucain and Fourrier, Clémentine},
|
|
|
126 |
# Load audio dataset
|
127 |
audio_dataset = load_dataset(AUDIO_DATASET_ID)
|
128 |
|
129 |
+
####################################
|
130 |
+
# Router API
|
131 |
+
####################################
|
132 |
+
router = Client("ttseval/tts-router", hf_token=os.getenv('HF_TOKEN'))
|
133 |
####################################
|
134 |
# Gradio app
|
135 |
####################################
|
|
|
198 |
|
199 |
# Delete local + remote
|
200 |
os.remove(DB_PATH)
|
201 |
+
delete_file(path_in_repo=DB_NAME, repo_id=DB_DATASET_ID, repo_type='dataset')
|
202 |
|
203 |
# Recreate
|
204 |
create_db_if_missing()
|
|
|
412 |
# bothgood.click(both_good, outputs=outputs, inputs=[model1, model2, useridstate])
|
413 |
|
414 |
# vote.load(reload, outputs=[aud1, aud2, model1, model2])
|
415 |
+
def synthandreturn(text):
|
416 |
+
# Get two random models
|
417 |
+
mdl1, mdl2 = random.sample(AVAILABLE_MODELS.keys(), 2)
|
418 |
return (
|
419 |
text,
|
420 |
+
"Synthesize",
|
421 |
gr.update(visible=True), # r1
|
422 |
gr.update(visible=True), # r2
|
423 |
+
mdl1, # model1
|
424 |
+
mdl2, # model2
|
425 |
+
'Vote to reveal model A', # prevmodel1
|
426 |
+
router.predict(
|
427 |
+
text,
|
428 |
+
AVAILABLE_MODELS[mdl1]
|
429 |
+
), # aud1
|
430 |
+
'Vote to reveal model B', # prevmodel2
|
431 |
+
router.predict(
|
432 |
+
text,
|
433 |
+
AVAILABLE_MODELS[mdl2]
|
434 |
+
), # aud2
|
435 |
)
|
436 |
with gr.Blocks() as vote:
|
437 |
useridstate = gr.State()
|
|
|
457 |
with gr.Row():
|
458 |
abetter = gr.Button("A is Better", variant='primary')
|
459 |
bbetter = gr.Button("B is Better", variant='primary')
|
460 |
+
outputs = [text, btn, r1, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2]
|
461 |
+
btn.click(synthandreturn, inputs=[text], outputs=outputs)
|
462 |
|
463 |
+
nxt_outputs = [aud1, aud2, model1, model2, useridstate, prevmodel1, prevmodel2]
|
464 |
+
abetter.click(a_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
|
465 |
+
bbetter.click(b_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
|
466 |
# skipbtn.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])
|
467 |
|
468 |
# bothbad.click(both_bad, outputs=outputs, inputs=[model1, model2, useridstate])
|