hexgrad commited on
Commit
e99077e
·
verified ·
1 Parent(s): bb3b6bc

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -233,7 +233,7 @@ SAMPLE_RATE = 24000
233
 
234
  @torch.no_grad()
235
  def forward(tokens, voices, speed, sk, device='cpu'):
236
- assert sk in {os.environ['SK'], os.environ['ARENA']}, sk
237
  ref_s = torch.mean(torch.stack([VOICES[device][v][len(tokens)] for v in voices]), dim=0)
238
  tokens = torch.LongTensor([[0, *tokens, 0]]).to(device)
239
  input_lengths = torch.LongTensor([tokens.shape[-1]]).to(device)
@@ -290,7 +290,7 @@ def trim_if_needed(out, trim):
290
  # Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
291
  def generate(text, voice='af', ps=None, speed=1, trim=0.5, use_gpu='auto', sk=None):
292
  ps = ps or phonemize(text, voice)
293
- if sk not in {os.environ['SK'], os.environ['ARENA']}:
294
  assert text in sents or ps.strip('"') in harvsents, ('❌', datetime.now(), text, voice, use_gpu, sk)
295
  sk = os.environ['ARENA']
296
  voices = resolve_voices(voice, warn=ps)
@@ -304,7 +304,7 @@ def generate(text, voice='af', ps=None, speed=1, trim=0.5, use_gpu='auto', sk=No
304
  tokens = tokens[:510]
305
  ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
306
  use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
307
- debug = '🏆' if sk == os.environ['ARENA'] else '🔥'
308
  try:
309
  if use_gpu:
310
  out = forward_gpu(tokens, voices, speed, sk)
 
233
 
234
  @torch.no_grad()
235
  def forward(tokens, voices, speed, sk, device='cpu'):
236
+ assert sk in {os.environ['SK'], os.environ['ARENA'], os.environ['TEMP']}, sk
237
  ref_s = torch.mean(torch.stack([VOICES[device][v][len(tokens)] for v in voices]), dim=0)
238
  tokens = torch.LongTensor([[0, *tokens, 0]]).to(device)
239
  input_lengths = torch.LongTensor([tokens.shape[-1]]).to(device)
 
290
  # Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
291
  def generate(text, voice='af', ps=None, speed=1, trim=0.5, use_gpu='auto', sk=None):
292
  ps = ps or phonemize(text, voice)
293
+ if sk not in {os.environ['SK'], os.environ['ARENA'], os.environ['TEMP']}:
294
  assert text in sents or ps.strip('"') in harvsents, ('❌', datetime.now(), text, voice, use_gpu, sk)
295
  sk = os.environ['ARENA']
296
  voices = resolve_voices(voice, warn=ps)
 
304
  tokens = tokens[:510]
305
  ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
306
  use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
307
+ debug = '🔥' if sk == os.environ['SK'] else '🏆'
308
  try:
309
  if use_gpu:
310
  out = forward_gpu(tokens, voices, speed, sk)