Pendrokar commited on
Commit
bde9568
1 Parent(s): 2c05179

Client: skip retries and storing the Client

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -547,7 +547,7 @@ We may store text you enter and generated audio. We store a unique ID for each s
547
 
548
  Generated audio clips cannot be redistributed and may be used for personal, non-commercial use only.
549
 
550
- Random sentences are sourced from a filtered subset of the [Harvard Sentences](https://www.cs.columbia.edu/~hgs/audio/harvard.html).
551
  """.strip()
552
 
553
  LDESC = f"""
@@ -565,7 +565,7 @@ TTS_INFO = f"""
565
 
566
  ### Open Source TTS capabilities table
567
 
568
- See [the below dataset itself](https://huggingface.co/datasets/Pendrokar/open_tts_tracker) for the legend and more in depth information for each model.
569
  """.strip()
570
 
571
  model_series = []
@@ -961,16 +961,17 @@ def synthandreturn(text, request: gr.Request):
961
  except:
962
  pass
963
 
964
- # 2 attempts
965
  attempt_count = 0
966
- while attempt_count < 2:
 
967
  try:
968
  if model in AVAILABLE_MODELS:
969
  if '/' in model:
970
  # Use public HF Space
971
- if (model not in hf_clients):
972
- hf_clients[model] = Client(model, hf_token=hf_token, headers=hf_headers)
973
- mdl_space = hf_clients[model]
974
 
975
  # print(f"{model}: Fetching endpoints of HF Space")
976
  # assume the index is one of the first 9 return params
@@ -1028,7 +1029,7 @@ def synthandreturn(text, request: gr.Request):
1028
  time.sleep(3)
1029
 
1030
  # Fetch and store client again
1031
- hf_clients[model] = Client(model, hf_token=hf_token, headers=hf_headers)
1032
 
1033
  if attempt_count > 2:
1034
  raise gr.Error(f"{model}: Failed to call model")
 
547
 
548
  Generated audio clips cannot be redistributed and may be used for personal, non-commercial use only.
549
 
550
+ Random sentences are sourced from a filtered subset of the [Harvard Sentences](https://www.cs.columbia.edu/~hgs/audio/harvard.html) and also from KingNish's generated LLM sentences.
551
  """.strip()
552
 
553
  LDESC = f"""
 
565
 
566
  ### Open Source TTS capabilities table
567
 
568
+ See [the below dataset itself](https://huggingface.co/datasets/Pendrokar/open_tts_tracker) for the legend and more in depth information of each model.
569
  """.strip()
570
 
571
  model_series = []
 
961
  except:
962
  pass
963
 
964
+ # re-attempt if necessary
965
  attempt_count = 0
966
+ while attempt_count < 1:
967
+ # while attempt_count < 3: # May cause 429 Too Many Request
968
  try:
969
  if model in AVAILABLE_MODELS:
970
  if '/' in model:
971
  # Use public HF Space
972
+ # if (model not in hf_clients):
973
+ # hf_clients[model] = Client(model, hf_token=hf_token, headers=hf_headers)
974
+ mdl_space = Client(model, hf_token=hf_token, headers=hf_headers)
975
 
976
  # print(f"{model}: Fetching endpoints of HF Space")
977
  # assume the index is one of the first 9 return params
 
1029
  time.sleep(3)
1030
 
1031
  # Fetch and store client again
1032
+ # hf_clients[model] = Client(model, hf_token=hf_token, headers=hf_headers)
1033
 
1034
  if attempt_count > 2:
1035
  raise gr.Error(f"{model}: Failed to call model")