mrfakename commited on
Commit
73c86b6
1 Parent(s): c823dc3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -488,10 +488,12 @@ def synthandreturn(text):
488
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
489
  log_text(text)
490
  print("[debug] Using", mdl1, mdl2)
491
- def predict_and_update_result(text, model, gr_update):
492
  result = router.predict(text, AVAILABLE_MODELS[model], api_name="/synthesize")
493
- thread1 = threading.Thread(target=predict_and_update_result, args=(text, mdl1, gr.update))
494
- thread2 = threading.Thread(target=predict_and_update_result, args=(text, mdl2, gr.update))
 
 
495
  thread1.start()
496
  thread2.start()
497
  thread1.join()
@@ -502,8 +504,8 @@ def synthandreturn(text):
502
  gr.update(visible=True), # r2
503
  mdl1, # model1
504
  mdl2, # model2
505
- gr.update(visible=True, value=thread1.result), # aud1
506
- gr.update(visible=True, value=thread2.result), # aud2
507
  gr.update(visible=True, interactive=True),
508
  gr.update(visible=True, interactive=True),
509
  gr.update(visible=False),
 
488
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
489
  log_text(text)
490
  print("[debug] Using", mdl1, mdl2)
491
+ def predict_and_update_result(text, model, result_storage):
492
  result = router.predict(text, AVAILABLE_MODELS[model], api_name="/synthesize")
493
+ result_storage[model] = result
494
+ results = {}
495
+ thread1 = threading.Thread(target=predict_and_update_result, args=(text, mdl1, results))
496
+ thread2 = threading.Thread(target=predict_and_update_result, args=(text, mdl2, results))
497
  thread1.start()
498
  thread2.start()
499
  thread1.join()
 
504
  gr.update(visible=True), # r2
505
  mdl1, # model1
506
  mdl2, # model2
507
+ gr.update(visible=True, value=results[mdl1]), # aud1
508
+ gr.update(visible=True, value=results[mdl2]), # aud2
509
  gr.update(visible=True, interactive=True),
510
  gr.update(visible=True, interactive=True),
511
  gr.update(visible=False),