Upload app.py
Browse files
app.py
CHANGED
|
@@ -211,14 +211,18 @@ 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, speed, trim, use_gpu, *args):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
if not isinstance(trim, int):
|
| 216 |
trim = 4000
|
| 217 |
if use_gpu not in ('auto', False, True):
|
| 218 |
use_gpu = 'auto'
|
| 219 |
-
if voice not in VOICES['cpu']:
|
| 220 |
-
voice = 'af'
|
| 221 |
-
ps = ps or phonemize(text, voice)
|
| 222 |
tokens = tokenize(ps)
|
| 223 |
if not tokens:
|
| 224 |
return (None, '')
|
|
@@ -373,7 +377,7 @@ def segment_and_tokenize(text, voice, skip_square_brackets=True, newline_split=2
|
|
| 373 |
segments = [row for t in texts for row in recursive_split(t, voice)]
|
| 374 |
return [(i, *row) for i, row in enumerate(segments)]
|
| 375 |
|
| 376 |
-
def lf_generate(segments, voice, speed, trim, pad_between, use_gpu):
|
| 377 |
token_lists = list(map(tokenize, segments['Tokens']))
|
| 378 |
wavs = []
|
| 379 |
trim = int(trim / 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, '')
|
|
|
|
| 377 |
segments = [row for t in texts for row in recursive_split(t, voice)]
|
| 378 |
return [(i, *row) for i, row in enumerate(segments)]
|
| 379 |
|
| 380 |
+
def lf_generate(segments, voice, speed=1, trim=0, pad_between=0, use_gpu=True):
|
| 381 |
token_lists = list(map(tokenize, segments['Tokens']))
|
| 382 |
wavs = []
|
| 383 |
trim = int(trim / speed)
|