hexgrad commited on
Commit
ded45ee
·
verified ·
1 Parent(s): 09ddb3d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -211,18 +211,20 @@ def forward_gpu(tokens, voice, speed):
211
  return forward(tokens, voice, speed, device='cuda')
212
 
213
  # Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
214
- def generate(text, voice, ps=None, speed=1, trim=4000, use_gpu='auto', *args):
215
  if voice not in VOICES['cpu']:
216
  voice = 'af'
217
  ps = ps or phonemize(text, voice)
218
- if not isinstance(speed, int) and not isinstance(speed, float):
219
  speed = 1
220
  elif speed < 0.5 or speed > 2:
221
  speed = min(max(0.5, speed), 2)
222
  if not isinstance(trim, int):
223
  trim = 4000
224
- if use_gpu not in ('auto', False, True):
225
  use_gpu = 'auto'
 
 
226
  tokens = tokenize(ps)
227
  if not tokens:
228
  return (None, '')
 
211
  return forward(tokens, voice, speed, device='cuda')
212
 
213
  # Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
214
+ def generate(text, voice, ps=None, speed=1, trim=4000, *args):
215
  if voice not in VOICES['cpu']:
216
  voice = 'af'
217
  ps = ps or phonemize(text, voice)
218
+ if not isinstance(speed, float) and not isinstance(speed, int):
219
  speed = 1
220
  elif speed < 0.5 or speed > 2:
221
  speed = min(max(0.5, speed), 2)
222
  if not isinstance(trim, int):
223
  trim = 4000
224
+ if not args or args[0] not in ('auto', False, True):
225
  use_gpu = 'auto'
226
+ else:
227
+ use_gpu = args[0]
228
  tokens = tokenize(ps)
229
  if not tokens:
230
  return (None, '')