Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -245,7 +245,7 @@ def clamp_speed(speed):
|
|
245 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
246 |
def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto', sk=None):
|
247 |
sk = os.environ['SK'] if text in sents else sk
|
248 |
-
if sk
|
249 |
return (None, '')
|
250 |
voices = resolve_voices(voice, warn=ps)
|
251 |
ps = ps or phonemize(text, voice)
|
@@ -259,6 +259,7 @@ def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto', sk=N
|
|
259 |
tokens = tokens[:510]
|
260 |
ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
|
261 |
use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
|
|
|
262 |
try:
|
263 |
if use_gpu:
|
264 |
out = forward_gpu(tokens, voices, speed, sk)
|
@@ -271,14 +272,14 @@ def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto', sk=N
|
|
271 |
out = forward(tokens, voices, speed, sk)
|
272 |
else:
|
273 |
raise gr.Error(e)
|
274 |
-
print(
|
275 |
return (None, '')
|
276 |
trim = int(trim / speed)
|
277 |
if trim > 0:
|
278 |
if trim * 2 >= len(out):
|
279 |
return (None, '')
|
280 |
out = out[trim:-trim]
|
281 |
-
print(
|
282 |
return ((SAMPLE_RATE, out), ps)
|
283 |
|
284 |
def toggle_autoplay(autoplay):
|
|
|
245 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
246 |
def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto', sk=None):
|
247 |
sk = os.environ['SK'] if text in sents else sk
|
248 |
+
if sk not in {os.environ['SK'], os.environ['ARENA']}:
|
249 |
return (None, '')
|
250 |
voices = resolve_voices(voice, warn=ps)
|
251 |
ps = ps or phonemize(text, voice)
|
|
|
259 |
tokens = tokens[:510]
|
260 |
ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
|
261 |
use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
|
262 |
+
debug = '🏆' if sk == os.environ['ARENA'] else '🔥'
|
263 |
try:
|
264 |
if use_gpu:
|
265 |
out = forward_gpu(tokens, voices, speed, sk)
|
|
|
272 |
out = forward(tokens, voices, speed, sk)
|
273 |
else:
|
274 |
raise gr.Error(e)
|
275 |
+
print(debug, datetime.now(), voices, len(ps), use_gpu, repr(e))
|
276 |
return (None, '')
|
277 |
trim = int(trim / speed)
|
278 |
if trim > 0:
|
279 |
if trim * 2 >= len(out):
|
280 |
return (None, '')
|
281 |
out = out[trim:-trim]
|
282 |
+
print(debug, datetime.now(), voices, len(ps), use_gpu, len(out))
|
283 |
return ((SAMPLE_RATE, out), ps)
|
284 |
|
285 |
def toggle_autoplay(autoplay):
|