mrfakename commited on
Commit
2ca5c30
1 Parent(s): a64707b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -67,6 +67,12 @@ def create_db_if_missing():
67
  vote INTEGER
68
  );
69
  ''')
 
 
 
 
 
 
70
  def get_db():
71
  return sqlite3.connect(DB_PATH)
72
 
@@ -319,7 +325,13 @@ def upvote_model(model, uname):
319
  with scheduler.lock:
320
  conn.commit()
321
  cursor.close()
322
-
 
 
 
 
 
 
323
  def downvote_model(model, uname):
324
  conn = get_db()
325
  cursor = conn.cursor()
@@ -456,6 +468,8 @@ def synthandreturn(text):
456
  raise gr.Error(f'You did not enter any text')
457
  # Get two random models
458
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
 
 
459
  return (
460
  text,
461
  "Synthesize",
@@ -506,7 +520,7 @@ with gr.Blocks() as vote:
506
  aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
507
  bbetter = gr.Button("B is better", variant='primary')
508
  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)
509
- nxtroundbtn = gr.Button('Next Round', visible=False)
510
  # outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
511
  outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
512
  btn.click(synthandreturn, inputs=[text], outputs=outputs)
 
67
  vote INTEGER
68
  );
69
  ''')
70
+ cursor.execute('''
71
+ CREATE TABLE IF NOT EXISTS spokentext (
72
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
73
+ spokentext TEXT
74
+ );
75
+ ''')
76
  def get_db():
77
  return sqlite3.connect(DB_PATH)
78
 
 
325
  with scheduler.lock:
326
  conn.commit()
327
  cursor.close()
328
+ def log_text(text):
329
+ conn = get_db()
330
+ cursor = conn.cursor()
331
+ cursor.execute('INSERT INTO spokentext (spokentext) VALUES (?)', (text,))
332
+ with scheduler.lock:
333
+ conn.commit()
334
+ cursor.close()
335
  def downvote_model(model, uname):
336
  conn = get_db()
337
  cursor = conn.cursor()
 
468
  raise gr.Error(f'You did not enter any text')
469
  # Get two random models
470
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
471
+ log_text(text)
472
+ print("[debug] Using", mdl1, mdl2)
473
  return (
474
  text,
475
  "Synthesize",
 
520
  aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
521
  bbetter = gr.Button("B is better", variant='primary')
522
  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)
523
+ nxtroundbtn = gr.Button('Next round', visible=False)
524
  # outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
525
  outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
526
  btn.click(synthandreturn, inputs=[text], outputs=outputs)