Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -165,6 +165,13 @@ This demo only showcases English, but you can directly use the model to access o
|
|
165 |
'''
|
166 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
167 |
API_NAME = None if API_OPEN else False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
with gr.Blocks() as app:
|
169 |
with gr.Row():
|
170 |
gr.Markdown(BANNER_TEXT, container=True)
|
@@ -187,14 +194,14 @@ with gr.Blocks() as app:
|
|
187 |
frankenstein_btn = gr.Button('💀 Frankenstein 📗', variant='secondary')
|
188 |
with gr.Column():
|
189 |
gr.TabbedInterface([generate_tab, stream_tab], ['Generate', 'Stream'])
|
190 |
-
random_btn.click(fn=get_random_quote, inputs=[], outputs=[text], api_name=
|
191 |
-
gatsby_btn.click(fn=get_gatsby, inputs=[], outputs=[text], api_name=
|
192 |
-
frankenstein_btn.click(fn=get_frankenstein, inputs=[], outputs=[text], api_name=
|
193 |
-
generate_btn.click(fn=generate_first, inputs=[text, voice, speed, use_gpu], outputs=[out_audio, out_ps], api_name=
|
194 |
tokenize_btn.click(fn=tokenize_first, inputs=[text, voice], outputs=[out_ps], api_name=API_NAME)
|
195 |
-
stream_event = stream_btn.click(fn=generate_all, inputs=[text, voice, speed, use_gpu], outputs=[out_stream], api_name=
|
196 |
stop_btn.click(fn=None, cancels=stream_event)
|
197 |
predict_btn.click(fn=predict, inputs=[text, voice, speed], outputs=[out_audio], api_name=API_NAME)
|
198 |
|
199 |
if __name__ == '__main__':
|
200 |
-
app.queue(api_open=API_OPEN).launch(show_api=API_OPEN, allowed_paths=["/"], server_name="0.0.0.0", server_port=7860, root_path="",ssr_mode=False)
|
|
|
165 |
'''
|
166 |
API_OPEN = os.getenv('SPACE_ID') != 'hexgrad/Kokoro-TTS'
|
167 |
API_NAME = None if API_OPEN else False
|
168 |
+
API_ENDPOINTS = {
|
169 |
+
"generate_first": "generate",
|
170 |
+
"generate_all": "generate_stream",
|
171 |
+
"get_random_quote": "random_quote",
|
172 |
+
"get_gatsby": "gatsby",
|
173 |
+
"get_frankenstein": "frankenstein"
|
174 |
+
}
|
175 |
with gr.Blocks() as app:
|
176 |
with gr.Row():
|
177 |
gr.Markdown(BANNER_TEXT, container=True)
|
|
|
194 |
frankenstein_btn = gr.Button('💀 Frankenstein 📗', variant='secondary')
|
195 |
with gr.Column():
|
196 |
gr.TabbedInterface([generate_tab, stream_tab], ['Generate', 'Stream'])
|
197 |
+
random_btn.click(fn=get_random_quote, inputs=[], outputs=[text], api_name=API_ENDPOINTS["get_random_quote"])
|
198 |
+
gatsby_btn.click(fn=get_gatsby, inputs=[], outputs=[text], api_name=API_ENDPOINTS["get_gatsby"])
|
199 |
+
frankenstein_btn.click(fn=get_frankenstein, inputs=[], outputs=[text], api_name=API_ENDPOINTS["get_frankenstein"])
|
200 |
+
generate_btn.click(fn=generate_first, inputs=[text, voice, speed, use_gpu], outputs=[out_audio, out_ps], api_name=API_ENDPOINTS["generate_first"])
|
201 |
tokenize_btn.click(fn=tokenize_first, inputs=[text, voice], outputs=[out_ps], api_name=API_NAME)
|
202 |
+
stream_event = stream_btn.click(fn=generate_all, inputs=[text, voice, speed, use_gpu], outputs=[out_stream], api_name=API_ENDPOINTS["generate_all"])
|
203 |
stop_btn.click(fn=None, cancels=stream_event)
|
204 |
predict_btn.click(fn=predict, inputs=[text, voice, speed], outputs=[out_audio], api_name=API_NAME)
|
205 |
|
206 |
if __name__ == '__main__':
|
207 |
+
app.queue(api_open=API_OPEN).launch(show_api=API_OPEN, allowed_paths=["/"], server_name="0.0.0.0", server_port=7860, root_path="", ssr_mode=False, share=True)
|