Pendrokar commited on
Commit
fa0a8d8
·
1 Parent(s): f88842b

next round btn: new random blurred text

Browse files
Files changed (1) hide show
  1. app/ui_vote.py +24 -5
app/ui_vote.py CHANGED
@@ -4,13 +4,17 @@ from .synth import *
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():
12
  return [gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)]
13
-
 
 
 
14
 
15
  with gr.Blocks() as vote:
16
  # sample played
@@ -32,7 +36,9 @@ with gr.Blocks() as vote:
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')
37
  model1 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=False)
38
  #model1 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=True)
@@ -93,12 +99,25 @@ with gr.Blocks() as vote:
93
  gr.update(visible=False), #prevmodel1
94
  gr.update(visible=False), #prevmodel2
95
  gr.update(visible=False), #nxt round btn"""
96
- btn.click(disable, outputs=[btn, abetter, bbetter]).then(synthandreturn, inputs=[text], outputs=outputs).then(enable, outputs=[btn, abetter, bbetter])
97
- nxtroundbtn.click(clear_stuff, outputs=outputs)
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  # Allow interaction with the vote buttons only when both audio samples have finished playing
100
  #aud1.stop(unlock_vote, outputs=[abetter, bbetter, aplayed, bplayed], inputs=[gr.State(value=0), aplayed, bplayed])
101
  #aud2.stop(unlock_vote, outputs=[abetter, bbetter, aplayed, bplayed], inputs=[gr.State(value=1), aplayed, bplayed])
 
 
102
 
103
  # nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
104
  nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
 
4
  from .vote import *
5
  from .messages import *
6
 
7
+ blur_text_js = 'document.getElementById("arena-text-input").classList.add("blurred-text")'
8
+ unblur_text_js = 'document.getElementById("arena-text-input").classList.remove("blurred-text")'
9
 
10
  def disable():
11
  return [gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)]
12
  def enable():
13
  return [gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)]
14
+ def blur_text():
15
+ return gr.update(elem_classes=['blurred-text'])
16
+ def unblur_text():
17
+ return gr.update(elem_classes=[])
18
 
19
  with gr.Blocks() as vote:
20
  # sample played
 
36
  elem_id="arena-text-input",
37
  )
38
  randomt = gr.Button('🎲', scale=0, min_width=0, variant='tool')
39
+ randomt\
40
+ .click(randomsent, outputs=[text, randomt])\
41
+ .then(None, js="() => "+ unblur_text_js)
42
  btn = gr.Button("Synthesize", variant='primary')
43
  model1 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=False)
44
  #model1 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=True)
 
99
  gr.update(visible=False), #prevmodel1
100
  gr.update(visible=False), #prevmodel2
101
  gr.update(visible=False), #nxt round btn"""
102
+ btn\
103
+ .click(disable, outputs=[btn, abetter, bbetter])\
104
+ .then(synthandreturn, inputs=[text], outputs=outputs)\
105
+ .then(enable, outputs=[btn, abetter, bbetter])\
106
+ .then(None, js="() => "+ unblur_text_js)
107
+ # Next Round ; blur text
108
+ nxtroundbtn\
109
+ .click(clear_stuff, outputs=outputs)\
110
+ .then(randomsent, outputs=[text, randomt])\
111
+ .then(synthandreturn, inputs=[text], outputs=outputs)\
112
+ .then(enable, outputs=[btn, abetter, bbetter])
113
+ # blur text
114
+ nxtroundbtn.click(None, js="() => "+ blur_text_js)
115
 
116
  # Allow interaction with the vote buttons only when both audio samples have finished playing
117
  #aud1.stop(unlock_vote, outputs=[abetter, bbetter, aplayed, bplayed], inputs=[gr.State(value=0), aplayed, bplayed])
118
  #aud2.stop(unlock_vote, outputs=[abetter, bbetter, aplayed, bplayed], inputs=[gr.State(value=1), aplayed, bplayed])
119
+ # faster than sending output with elem_classes
120
+ aud2.stop(None, js="() => "+ unblur_text_js)
121
 
122
  # nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
123
  nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]