Pendrokar commited on
Commit
147419f
1 Parent(s): 80f449e

no multithreading

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -1033,10 +1033,10 @@ def synthandreturn(text, request: gr.Request):
1033
  break
1034
  except Exception as e:
1035
  attempt_count += 1
1036
- print(repr(e))
1037
- print(f"{model}: Unable to call API (attempt: {attempt_count})")
1038
  # sleep for three seconds to avoid spamming the server with requests
1039
- time.sleep(3)
1040
 
1041
  # Fetch and store client again
1042
  # hf_clients[model] = Client(model, hf_token=hf_token, headers=hf_headers)
@@ -1061,6 +1061,7 @@ def synthandreturn(text, request: gr.Request):
1061
  audio.export(f.name, format="wav")
1062
  os.unlink(result)
1063
  result = f.name
 
1064
  except:
1065
  print(f"{model}: [WARN] Unable to resample audio")
1066
  pass
@@ -1107,13 +1108,15 @@ def synthandreturn(text, request: gr.Request):
1107
  if mdl2 in AVAILABLE_MODELS.keys(): mdl2k=AVAILABLE_MODELS[mdl2]
1108
  results = {}
1109
  print(f"Sending models {mdl1k} and {mdl2k} to API")
1110
- thread1 = threading.Thread(target=predict_and_update_result, args=(text, mdl1k, results, request))
1111
- thread2 = threading.Thread(target=predict_and_update_result, args=(text, mdl2k, results, request))
1112
-
1113
- thread1.start()
1114
- thread2.start()
1115
- thread1.join(180)
1116
- thread2.join(180)
 
 
1117
  #debug
1118
  # print(results)
1119
  # print(list(results.keys())[0])
 
1033
  break
1034
  except Exception as e:
1035
  attempt_count += 1
1036
+ raise gr.Error(f"{model}:"+ repr(e))
1037
+ # print(f"{model}: Unable to call API (attempt: {attempt_count})")
1038
  # sleep for three seconds to avoid spamming the server with requests
1039
+ # time.sleep(3)
1040
 
1041
  # Fetch and store client again
1042
  # hf_clients[model] = Client(model, hf_token=hf_token, headers=hf_headers)
 
1061
  audio.export(f.name, format="wav")
1062
  os.unlink(result)
1063
  result = f.name
1064
+ gr.Info('Audio from a TTS model received')
1065
  except:
1066
  print(f"{model}: [WARN] Unable to resample audio")
1067
  pass
 
1108
  if mdl2 in AVAILABLE_MODELS.keys(): mdl2k=AVAILABLE_MODELS[mdl2]
1109
  results = {}
1110
  print(f"Sending models {mdl1k} and {mdl2k} to API")
1111
+ # thread1 = threading.Thread(target=predict_and_update_result, args=(text, mdl1k, results, request))
1112
+ # thread2 = threading.Thread(target=predict_and_update_result, args=(text, mdl2k, results, request))
1113
+
1114
+ # thread1.start()
1115
+ # thread2.start()
1116
+ # thread1.join(180)
1117
+ # thread2.join(180)
1118
+ predict_and_update_result(text, mdl1k, results, request)
1119
+ predict_and_update_result(text, mdl2k, results, request)
1120
  #debug
1121
  # print(results)
1122
  # print(list(results.keys())[0])