Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
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,
|
215 |
if voice not in VOICES['cpu']:
|
216 |
voice = 'af'
|
217 |
ps = ps or phonemize(text, voice)
|
218 |
-
if not isinstance(speed,
|
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
|
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, '')
|