Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from huggingface_hub import snapshot_download
|
| 2 |
from katsu import Katsu
|
| 3 |
from models import build_model
|
|
@@ -245,6 +246,7 @@ def generate(text, voice='af', ps=None, speed=1, trim=3000, use_gpu='auto'):
|
|
| 245 |
tokens = tokens[:510]
|
| 246 |
ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
|
| 247 |
use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
|
|
|
|
| 248 |
try:
|
| 249 |
if use_gpu:
|
| 250 |
out = forward_gpu(tokens, voices, speed)
|
|
@@ -417,16 +419,18 @@ def lf_generate(segments, voice, speed=1, trim=0, pad_between=0, use_gpu=True):
|
|
| 417 |
i = 0
|
| 418 |
while i < len(token_lists):
|
| 419 |
bs = batch_sizes.pop() if batch_sizes else 100
|
|
|
|
|
|
|
| 420 |
try:
|
| 421 |
if use_gpu:
|
| 422 |
-
outs = lf_forward_gpu(
|
| 423 |
else:
|
| 424 |
-
outs = lf_forward(
|
| 425 |
except gr.exceptions.Error as e:
|
| 426 |
if use_gpu:
|
| 427 |
gr.Warning(str(e))
|
| 428 |
gr.Info('Switching to CPU')
|
| 429 |
-
outs = lf_forward(
|
| 430 |
use_gpu = False
|
| 431 |
else:
|
| 432 |
raise gr.Error(e)
|
|
@@ -494,7 +498,7 @@ with gr.Blocks() as lf_tts:
|
|
| 494 |
|
| 495 |
with gr.Blocks() as about:
|
| 496 |
gr.Markdown('''
|
| 497 |
-
Kokoro is a frontier TTS model for its size. It has [80 million](https://hf.co/spaces/hexgrad/Kokoro-TTS/blob/main/app.py#
|
| 498 |
|
| 499 |
### FAQ
|
| 500 |
**Will this be open sourced?**<br/>
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
from huggingface_hub import snapshot_download
|
| 3 |
from katsu import Katsu
|
| 4 |
from models import build_model
|
|
|
|
| 246 |
tokens = tokens[:510]
|
| 247 |
ps = ''.join(next(k for k, v in VOCAB.items() if i == v) for i in tokens)
|
| 248 |
use_gpu = len(ps) > 99 if use_gpu == 'auto' else use_gpu
|
| 249 |
+
print('🔥', datetime.now(), len(ps), voices, use_gpu)
|
| 250 |
try:
|
| 251 |
if use_gpu:
|
| 252 |
out = forward_gpu(tokens, voices, speed)
|
|
|
|
| 419 |
i = 0
|
| 420 |
while i < len(token_lists):
|
| 421 |
bs = batch_sizes.pop() if batch_sizes else 100
|
| 422 |
+
tokens = token_lists[i:i+bs]
|
| 423 |
+
print('📖', datetime.now(), len(tokens), voices, use_gpu)
|
| 424 |
try:
|
| 425 |
if use_gpu:
|
| 426 |
+
outs = lf_forward_gpu(tokens, voices, speed)
|
| 427 |
else:
|
| 428 |
+
outs = lf_forward(tokens, voices, speed)
|
| 429 |
except gr.exceptions.Error as e:
|
| 430 |
if use_gpu:
|
| 431 |
gr.Warning(str(e))
|
| 432 |
gr.Info('Switching to CPU')
|
| 433 |
+
outs = lf_forward(tokens, voices, speed)
|
| 434 |
use_gpu = False
|
| 435 |
else:
|
| 436 |
raise gr.Error(e)
|
|
|
|
| 498 |
|
| 499 |
with gr.Blocks() as about:
|
| 500 |
gr.Markdown('''
|
| 501 |
+
Kokoro is a frontier TTS model for its size. It has [80 million](https://hf.co/spaces/hexgrad/Kokoro-TTS/blob/main/app.py#L32) parameters, uses a lean [StyleTTS 2](https://github.com/yl4579/StyleTTS2) architecture, and was trained on high-quality data. The weights are currently private, but a free public demo is hosted here, at `https://hf.co/spaces/hexgrad/Kokoro-TTS`. The Community tab is open for feature requests, bug reports, etc. For other inquiries, contact `@rzvzn` on Discord.
|
| 502 |
|
| 503 |
### FAQ
|
| 504 |
**Will this be open sourced?**<br/>
|