Spaces:
Running
Running
keyboard shortcuts
Browse files- app/ui.py +34 -1
- app/ui_vote.py +30 -4
app/ui.py
CHANGED
@@ -5,11 +5,44 @@ from .ui_vote import *
|
|
5 |
from .ui_leaderboard import *
|
6 |
from .ui_contenders import *
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
with gr.Blocks() as about:
|
10 |
gr.Markdown(ABOUT)
|
11 |
|
12 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
13 |
gr.Markdown(DESCR)
|
14 |
gr.TabbedInterface([vote, leaderboard, about, tts_info], ['π³οΈ Vote', 'π Leaderboard', 'π About', 'π£ Contenders'])
|
15 |
if CITATION_TEXT:
|
|
|
5 |
from .ui_leaderboard import *
|
6 |
from .ui_contenders import *
|
7 |
|
8 |
+
# JavaScript within HTML head
|
9 |
+
head_js = ""
|
10 |
+
shortcut_js = """
|
11 |
+
<script>
|
12 |
+
function shortcuts(e) {
|
13 |
+
var event = document.all ? window.event : e;
|
14 |
+
switch (e.target.tagName.toLowerCase()) {
|
15 |
+
case "input":
|
16 |
+
case "textarea":
|
17 |
+
break;
|
18 |
+
default:
|
19 |
+
switch (e.key.toLowerCase()) {
|
20 |
+
case "a":
|
21 |
+
document.getElementById("arena-a-better").click();
|
22 |
+
break;
|
23 |
+
case "b":
|
24 |
+
document.getElementById("arena-b-better").click();
|
25 |
+
break;
|
26 |
+
case "n":
|
27 |
+
document.getElementById("arena-next-round").click();
|
28 |
+
break;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
document.addEventListener('keypress', shortcuts, false);
|
33 |
+
|
34 |
+
"""
|
35 |
+
head_js += shortcut_js
|
36 |
+
head_js += '</script>'
|
37 |
|
38 |
with gr.Blocks() as about:
|
39 |
gr.Markdown(ABOUT)
|
40 |
|
41 |
+
with gr.Blocks(
|
42 |
+
css="footer {visibility: hidden}textbox{resize:none} .blurred-text {filter: blur(0.15em);}",
|
43 |
+
head=head_js,
|
44 |
+
title="TTS Arena"
|
45 |
+
) as app:
|
46 |
gr.Markdown(DESCR)
|
47 |
gr.TabbedInterface([vote, leaderboard, about, tts_info], ['π³οΈ Vote', 'π Leaderboard', 'π About', 'π£ Contenders'])
|
48 |
if CITATION_TEXT:
|
app/ui_vote.py
CHANGED
@@ -4,6 +4,8 @@ from .synth import *
|
|
4 |
from .vote import *
|
5 |
from .messages import *
|
6 |
|
|
|
|
|
7 |
def disable():
|
8 |
return [gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)]
|
9 |
def enable():
|
@@ -19,7 +21,16 @@ with gr.Blocks() as vote:
|
|
19 |
gr.Markdown(INSTR)
|
20 |
with gr.Group():
|
21 |
with gr.Row():
|
22 |
-
text = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
randomt = gr.Button('π²', scale=0, min_width=0, variant='tool')
|
24 |
randomt.click(randomsent, outputs=[text, randomt])
|
25 |
btn = gr.Button("Synthesize", variant='primary')
|
@@ -31,14 +42,29 @@ with gr.Blocks() as vote:
|
|
31 |
with gr.Column():
|
32 |
with gr.Group():
|
33 |
aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False)
|
34 |
-
abetter = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
35 |
prevmodel1 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model A", text_align="center", lines=1, max_lines=1, visible=False)
|
36 |
with gr.Column():
|
37 |
with gr.Group():
|
38 |
aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False)
|
39 |
-
bbetter = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
40 |
prevmodel2 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model B", text_align="center", lines=1, max_lines=1, visible=False)
|
41 |
-
nxtroundbtn = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
42 |
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
43 |
outputs = [
|
44 |
text,
|
|
|
4 |
from .vote import *
|
5 |
from .messages import *
|
6 |
|
7 |
+
unblur_js = 'document.getElementById("arena-text-input").classList.remove("blurred-text")'
|
8 |
+
|
9 |
def disable():
|
10 |
return [gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)]
|
11 |
def enable():
|
|
|
21 |
gr.Markdown(INSTR)
|
22 |
with gr.Group():
|
23 |
with gr.Row():
|
24 |
+
text = gr.Textbox(
|
25 |
+
container=False,
|
26 |
+
show_label=False,
|
27 |
+
placeholder="Enter text to synthesize",
|
28 |
+
lines=1,
|
29 |
+
max_lines=1,
|
30 |
+
scale=9999999,
|
31 |
+
min_width=0,
|
32 |
+
elem_id="arena-text-input",
|
33 |
+
)
|
34 |
randomt = gr.Button('π²', scale=0, min_width=0, variant='tool')
|
35 |
randomt.click(randomsent, outputs=[text, randomt])
|
36 |
btn = gr.Button("Synthesize", variant='primary')
|
|
|
42 |
with gr.Column():
|
43 |
with gr.Group():
|
44 |
aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False)
|
45 |
+
abetter = gr.Button(
|
46 |
+
"[A] is better",
|
47 |
+
elem_id='arena-a-better',
|
48 |
+
variant='primary',
|
49 |
+
interactive=False,
|
50 |
+
)
|
51 |
prevmodel1 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model A", text_align="center", lines=1, max_lines=1, visible=False)
|
52 |
with gr.Column():
|
53 |
with gr.Group():
|
54 |
aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False)
|
55 |
+
bbetter = gr.Button(
|
56 |
+
"[B] is better",
|
57 |
+
elem_id='arena-b-better',
|
58 |
+
variant='primary',
|
59 |
+
interactive=False,
|
60 |
+
)
|
61 |
prevmodel2 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model B", text_align="center", lines=1, max_lines=1, visible=False)
|
62 |
+
nxtroundbtn = gr.Button(
|
63 |
+
'β‘ [N]ext round',
|
64 |
+
elem_id='arena-next-round',
|
65 |
+
visible=False,
|
66 |
+
variant='primary',
|
67 |
+
)
|
68 |
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
69 |
outputs = [
|
70 |
text,
|