mrfakename commited on
Commit
860bd89
1 Parent(s): 21f92d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -26,6 +26,7 @@ AVAILABLE_MODELS = {
26
 
27
  SPACE_ID = os.getenv('HF_ID')
28
  MAX_SAMPLE_TXT_LENGTH = 150
 
29
  DB_DATASET_ID = os.getenv('DATASET_ID')
30
  DB_NAME = "database.db"
31
 
@@ -194,7 +195,7 @@ Please assume all generated audio clips are not licensed to be redistributed and
194
  LDESC = """
195
  ## Leaderboard
196
 
197
- A list of the models, based on how highly they are ranked!
198
  """.strip()
199
 
200
 
@@ -383,7 +384,7 @@ def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, cho
383
  else:
384
  out.append(gr.update(value=f'{chosenmodel1}', interactive=False, visible=True))
385
  out.append(gr.update(value=f'Your vote: {chosenmodel2}', interactive=False, visible=True))
386
- out.append(gr.update(visible=True))
387
  return out
388
 
389
  with gr.Blocks() as leaderboard:
@@ -444,13 +445,16 @@ def synthandreturn(text):
444
  text = text.strip()
445
  if len(text) > MAX_SAMPLE_TXT_LENGTH:
446
  raise gr.Error(f'You exceeded the limit of {MAX_SAMPLE_TXT_LENGTH} characters')
 
 
447
  if not text:
448
  raise gr.Error(f'You did not enter any text')
449
  # Get two random models
450
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
451
  return (
452
  text,
453
- "Synthesize",
 
454
  gr.update(visible=True), # r2
455
  mdl1, # model1
456
  mdl2, # model2
@@ -470,7 +474,7 @@ def synthandreturn(text):
470
  gr.update(visible=True, interactive=True),
471
  gr.update(visible=False),
472
  gr.update(visible=False),
473
- gr.update(visible=False), #nxt round btn
474
  )
475
  def clear_stuff():
476
  return "", "Synthesize", gr.update(visible=False), '', '', gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
@@ -493,14 +497,14 @@ with gr.Blocks() as vote:
493
  aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
494
  bbetter = gr.Button("B is better", variant='primary')
495
  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)
496
- nxtroundbtn = gr.Button('Next Round', visible=False)
497
  # outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
498
- outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
499
  btn.click(synthandreturn, inputs=[text], outputs=outputs)
500
- nxtroundbtn.click(clear_stuff, outputs=outputs)
501
 
502
  # nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
503
- nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
504
  abetter.click(a_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
505
  bbetter.click(b_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
506
  # skipbtn.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])
 
26
 
27
  SPACE_ID = os.getenv('HF_ID')
28
  MAX_SAMPLE_TXT_LENGTH = 150
29
+ MIN_SAMPLE_TXT_LENGTH = 10
30
  DB_DATASET_ID = os.getenv('DATASET_ID')
31
  DB_NAME = "database.db"
32
 
 
195
  LDESC = """
196
  ## Leaderboard
197
 
198
+ A list of the models, based on how highly they are ranked! **Please note that if the leaderboard is empty, it means we have not collected enough results yet.**
199
  """.strip()
200
 
201
 
 
384
  else:
385
  out.append(gr.update(value=f'{chosenmodel1}', interactive=False, visible=True))
386
  out.append(gr.update(value=f'Your vote: {chosenmodel2}', interactive=False, visible=True))
387
+ # out.append(gr.update(visible=True))
388
  return out
389
 
390
  with gr.Blocks() as leaderboard:
 
445
  text = text.strip()
446
  if len(text) > MAX_SAMPLE_TXT_LENGTH:
447
  raise gr.Error(f'You exceeded the limit of {MAX_SAMPLE_TXT_LENGTH} characters')
448
+ if len(text) < MAX_SAMPLE_TXT_LENGTH:
449
+ raise gr.Error(f'You did not enter enough text!')
450
  if not text:
451
  raise gr.Error(f'You did not enter any text')
452
  # Get two random models
453
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
454
  return (
455
  text,
456
+ # "Synthesize",
457
+ "Next Round",
458
  gr.update(visible=True), # r2
459
  mdl1, # model1
460
  mdl2, # model2
 
474
  gr.update(visible=True, interactive=True),
475
  gr.update(visible=False),
476
  gr.update(visible=False),
477
+ # gr.update(visible=False), #nxt round btn
478
  )
479
  def clear_stuff():
480
  return "", "Synthesize", gr.update(visible=False), '', '', gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
 
497
  aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
498
  bbetter = gr.Button("B is better", variant='primary')
499
  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)
500
+ # nxtroundbtn = gr.Button('Next Round', visible=False)
501
  # outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
502
+ outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2]
503
  btn.click(synthandreturn, inputs=[text], outputs=outputs)
504
+ # nxtroundbtn.click(clear_stuff, outputs=outputs)
505
 
506
  # nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
507
+ nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2]
508
  abetter.click(a_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
509
  bbetter.click(b_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
510
  # skipbtn.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])