Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -286,6 +286,8 @@ def trim_if_needed(out, trim):
|
|
286 |
|
287 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
288 |
def generate(text, voice='af', ps=None, speed=1, trim=0.5, use_gpu='auto', sk=None):
|
|
|
|
|
289 |
ps = ps or phonemize(text, voice)
|
290 |
if sk not in {os.environ['SK'], os.environ['ARENA'], os.environ['TEMP']}:
|
291 |
assert text in sents or ps.strip('"') in harvard_sentences, ('❌', datetime.now(), text, voice, use_gpu, sk)
|
@@ -420,6 +422,8 @@ def change_language(value):
|
|
420 |
from gradio_client import Client
|
421 |
client = Client('hexgrad/kokoro-src', hf_token=os.environ['SRC'])
|
422 |
def preview(text, voice, speed, trim, sk):
|
|
|
|
|
423 |
assert sk == os.environ['SK'], ('❌', datetime.now(), text, voice, sk)
|
424 |
try:
|
425 |
audio, out_ps = client.predict(text=text, voice=voice, speed=speed, trim=trim, use_gpu=True, sk=sk, api_name='/generate')
|
|
|
286 |
|
287 |
# Must be backwards compatible with https://huggingface.co/spaces/Pendrokar/TTS-Spaces-Arena
|
288 |
def generate(text, voice='af', ps=None, speed=1, trim=0.5, use_gpu='auto', sk=None):
|
289 |
+
if not text.strip():
|
290 |
+
return (None, '')
|
291 |
ps = ps or phonemize(text, voice)
|
292 |
if sk not in {os.environ['SK'], os.environ['ARENA'], os.environ['TEMP']}:
|
293 |
assert text in sents or ps.strip('"') in harvard_sentences, ('❌', datetime.now(), text, voice, use_gpu, sk)
|
|
|
422 |
from gradio_client import Client
|
423 |
client = Client('hexgrad/kokoro-src', hf_token=os.environ['SRC'])
|
424 |
def preview(text, voice, speed, trim, sk):
|
425 |
+
if not text.strip():
|
426 |
+
return None
|
427 |
assert sk == os.environ['SK'], ('❌', datetime.now(), text, voice, sk)
|
428 |
try:
|
429 |
audio, out_ps = client.predict(text=text, voice=voice, speed=speed, trim=trim, use_gpu=True, sk=sk, api_name='/generate')
|