kemuriririn commited on
Commit
7f2c965
·
1 Parent(s): 7fcb739

(wip)debug

Browse files
Files changed (1) hide show
  1. tts.py +6 -4
tts.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  from dotenv import load_dotenv
3
  import random
4
  from gradio_client import Client, handle_file,file
 
5
 
6
  load_dotenv()
7
 
@@ -9,6 +10,8 @@ ZEROGPU_TOKENS = os.getenv("ZEROGPU_TOKENS", "").split(",")
9
 
10
 
11
  def get_zerogpu_token():
 
 
12
  return random.choice(ZEROGPU_TOKENS)
13
 
14
 
@@ -44,12 +47,11 @@ data = {"text": "string", "provider": "string", "model": "string"}
44
 
45
  def set_client_for_session(space:str, user_token=None):
46
  if user_token is None:
47
- x_ip_token = get_zerogpu_token()
 
48
  else:
49
  x_ip_token = user_token
50
-
51
- # The "gradio/text-to-image" space is a ZeroGPU space
52
- return Client(space, headers={"X-IP-Token": x_ip_token})
53
 
54
  def predict_index_tts(text, user_token=None, reference_audio_path=None):
55
  client = set_client_for_session("kemuriririn/IndexTTS",user_token=user_token)
 
2
  from dotenv import load_dotenv
3
  import random
4
  from gradio_client import Client, handle_file,file
5
+ from huggingface_hub.constants import HF_TOKEN_PATH
6
 
7
  load_dotenv()
8
 
 
10
 
11
 
12
  def get_zerogpu_token():
13
+ if not ZEROGPU_TOKENS or ZEROGPU_TOKENS == [""]:
14
+ return os.getenv("HF_TOKEN")
15
  return random.choice(ZEROGPU_TOKENS)
16
 
17
 
 
47
 
48
  def set_client_for_session(space:str, user_token=None):
49
  if user_token is None:
50
+
51
+ return Client(space, hf_token=get_zerogpu_token())
52
  else:
53
  x_ip_token = user_token
54
+ return Client(space, headers={"X-IP-Token": x_ip_token})
 
 
55
 
56
  def predict_index_tts(text, user_token=None, reference_audio_path=None):
57
  client = set_client_for_session("kemuriririn/IndexTTS",user_token=user_token)