Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,9 +4,6 @@ import gradio as gr
|
|
| 4 |
import os
|
| 5 |
import random
|
| 6 |
import torch
|
| 7 |
-
import logging
|
| 8 |
-
|
| 9 |
-
logging.basicConfig(level=logging.INFO)
|
| 10 |
|
| 11 |
IS_DUPLICATE = not os.getenv('SPACE_ID', '').startswith('Quantamhash/')
|
| 12 |
CUDA_AVAILABLE = torch.cuda.is_available()
|
|
@@ -26,7 +23,6 @@ def forward_gpu(ps, ref_s, speed):
|
|
| 26 |
return models[True](ps, ref_s, speed)
|
| 27 |
|
| 28 |
def generate_first(text, voice='af_heart', speed=1, use_gpu=CUDA_AVAILABLE):
|
| 29 |
-
logging.info(f"Received request: text={text}, voice={voice}, speed={speed}, use_gpu={use_gpu}")
|
| 30 |
text = text if CHAR_LIMIT is None else text.strip()[:CHAR_LIMIT]
|
| 31 |
pipeline = pipelines[voice[0]]
|
| 32 |
pack = pipeline.load_voice(voice)
|
|
@@ -132,8 +128,11 @@ for v in CHOICES.values():
|
|
| 132 |
|
| 133 |
TOKEN_NOTE = '''
|
| 134 |
💡 Customize pronunciation with Markdown link syntax and /slashes/ like `[Qhash-TTS]`
|
|
|
|
| 135 |
💬 To adjust intonation, try punctuation `;:,.!?—…"()“”` or stress `ˈ` and `ˌ`
|
|
|
|
| 136 |
⬇️ Lower stress `[1 level](-1)` or `[2 levels](-2)`
|
|
|
|
| 137 |
⬆️ Raise stress 1 level `[or](+2)` 2 levels (only works on less stressed, usually short words)
|
| 138 |
'''
|
| 139 |
|
|
@@ -163,9 +162,10 @@ with gr.Blocks() as stream_tab:
|
|
| 163 |
|
| 164 |
BANNER_TEXT = '''
|
| 165 |
[***Qhash-TTS*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/sbapan41/Qhash-TTS)
|
|
|
|
| 166 |
This demo only showcases English, but you can directly use the model to access other languages.
|
| 167 |
'''
|
| 168 |
-
API_OPEN =
|
| 169 |
API_NAME = None if API_OPEN else False
|
| 170 |
with gr.Blocks() as app:
|
| 171 |
with gr.Row():
|
|
@@ -199,4 +199,4 @@ with gr.Blocks() as app:
|
|
| 199 |
predict_btn.click(fn=predict, inputs=[text, voice, speed], outputs=[out_audio], api_name=API_NAME)
|
| 200 |
|
| 201 |
if __name__ == '__main__':
|
| 202 |
-
app.queue(api_open=API_OPEN).launch(show_api=API_OPEN, ssr_mode=True)
|
|
|
|
| 4 |
import os
|
| 5 |
import random
|
| 6 |
import torch
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
IS_DUPLICATE = not os.getenv('SPACE_ID', '').startswith('Quantamhash/')
|
| 9 |
CUDA_AVAILABLE = torch.cuda.is_available()
|
|
|
|
| 23 |
return models[True](ps, ref_s, speed)
|
| 24 |
|
| 25 |
def generate_first(text, voice='af_heart', speed=1, use_gpu=CUDA_AVAILABLE):
|
|
|
|
| 26 |
text = text if CHAR_LIMIT is None else text.strip()[:CHAR_LIMIT]
|
| 27 |
pipeline = pipelines[voice[0]]
|
| 28 |
pack = pipeline.load_voice(voice)
|
|
|
|
| 128 |
|
| 129 |
TOKEN_NOTE = '''
|
| 130 |
💡 Customize pronunciation with Markdown link syntax and /slashes/ like `[Qhash-TTS]`
|
| 131 |
+
|
| 132 |
💬 To adjust intonation, try punctuation `;:,.!?—…"()“”` or stress `ˈ` and `ˌ`
|
| 133 |
+
|
| 134 |
⬇️ Lower stress `[1 level](-1)` or `[2 levels](-2)`
|
| 135 |
+
|
| 136 |
⬆️ Raise stress 1 level `[or](+2)` 2 levels (only works on less stressed, usually short words)
|
| 137 |
'''
|
| 138 |
|
|
|
|
| 162 |
|
| 163 |
BANNER_TEXT = '''
|
| 164 |
[***Qhash-TTS*** **is an open-weight TTS model with 82 million parameters.**](https://huggingface.co/sbapan41/Qhash-TTS)
|
| 165 |
+
|
| 166 |
This demo only showcases English, but you can directly use the model to access other languages.
|
| 167 |
'''
|
| 168 |
+
API_OPEN = os.getenv('SPACE_ID') != 'Quantamhash/Qhash-TTS'
|
| 169 |
API_NAME = None if API_OPEN else False
|
| 170 |
with gr.Blocks() as app:
|
| 171 |
with gr.Row():
|
|
|
|
| 199 |
predict_btn.click(fn=predict, inputs=[text, voice, speed], outputs=[out_audio], api_name=API_NAME)
|
| 200 |
|
| 201 |
if __name__ == '__main__':
|
| 202 |
+
app.queue(api_open=API_OPEN).launch(show_api=API_OPEN, ssr_mode=True)
|