Update app.py
Browse files
app.py
CHANGED
|
@@ -170,27 +170,43 @@ If you would like to use our V2 Model with GPU, then go to this [link](https://c
|
|
| 170 |
|
| 171 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
| 172 |
API_NAME = None if API_OPEN else False
|
| 173 |
-
with gr.Blocks() as app:
|
| 174 |
with gr.Row():
|
| 175 |
gr.Markdown(BANNER_TEXT, container=True)
|
| 176 |
with gr.Row():
|
| 177 |
with gr.Column():
|
| 178 |
-
text = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
| 179 |
with gr.Row():
|
| 180 |
-
voice = gr.Dropdown(
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
info='GPU is usually faster, but has a usage quota',
|
| 186 |
-
interactive=CUDA_AVAILABLE
|
| 187 |
)
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
with gr.Column():
|
| 191 |
-
gr.TabbedInterface([generate_tab], ['Generate'])
|
|
|
|
|
|
|
| 192 |
random_btn.click(fn=get_random_text, inputs=[voice], outputs=[text], api_name=API_NAME)
|
| 193 |
-
generate_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
tokenize_btn.click(fn=tokenize_first, inputs=[text, voice], outputs=[out_ps], api_name=API_NAME)
|
| 195 |
predict_btn.click(fn=predict, inputs=[text, voice, speed], outputs=[out_audio], api_name=API_NAME)
|
| 196 |
|
|
|
|
| 170 |
|
| 171 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
| 172 |
API_NAME = None if API_OPEN else False
|
| 173 |
+
with gr.Blocks(css=custom_css) as app:
|
| 174 |
with gr.Row():
|
| 175 |
gr.Markdown(BANNER_TEXT, container=True)
|
| 176 |
with gr.Row():
|
| 177 |
with gr.Column():
|
| 178 |
+
text = gr.Textbox(
|
| 179 |
+
label='Input Text',
|
| 180 |
+
info=f"Up to ~500 characters per Generate, or {'∞' if CHAR_LIMIT is None else CHAR_LIMIT} characters per Stream"
|
| 181 |
+
)
|
| 182 |
with gr.Row():
|
| 183 |
+
voice = gr.Dropdown(
|
| 184 |
+
list(CHOICES.items()),
|
| 185 |
+
value='af_heart',
|
| 186 |
+
label='Voice',
|
| 187 |
+
info='Choose from our wide range of natural-sounding voices'
|
|
|
|
|
|
|
| 188 |
)
|
| 189 |
+
# Remove the GPU choice dropdown and always use GPU if available
|
| 190 |
+
use_gpu = CUDA_AVAILABLE # This will be used internally
|
| 191 |
+
speed = gr.Slider(
|
| 192 |
+
minimum=0.5,
|
| 193 |
+
maximum=2,
|
| 194 |
+
value=1,
|
| 195 |
+
step=0.1,
|
| 196 |
+
label='Speech Rate'
|
| 197 |
+
)
|
| 198 |
+
random_btn = gr.Button('Sample Text', variant='secondary')
|
| 199 |
with gr.Column():
|
| 200 |
+
gr.TabbedInterface([generate_tab], ['Generate Audio'])
|
| 201 |
+
|
| 202 |
+
# Keep the button click handlers but remove use_gpu from the visible inputs
|
| 203 |
random_btn.click(fn=get_random_text, inputs=[voice], outputs=[text], api_name=API_NAME)
|
| 204 |
+
generate_btn.click(
|
| 205 |
+
fn=generate_first,
|
| 206 |
+
inputs=[text, voice, speed],
|
| 207 |
+
outputs=[out_audio, out_ps],
|
| 208 |
+
api_name=API_NAME
|
| 209 |
+
)
|
| 210 |
tokenize_btn.click(fn=tokenize_first, inputs=[text, voice], outputs=[out_ps], api_name=API_NAME)
|
| 211 |
predict_btn.click(fn=predict, inputs=[text, voice, speed], outputs=[out_audio], api_name=API_NAME)
|
| 212 |
|