Spaces:
Zandintel
/
Runtime error

Zandintel commited on
Commit
3755a93
·
verified ·
1 Parent(s): 9b27d77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -314,22 +314,34 @@ def build_interface():
314
  type="filepath",
315
  )
316
 
317
- # Replace the API tab with explicit API endpoint definition
318
  with gr.Tab("API"):
319
- gr.Markdown("""### API Endpoint: `/api/tts`""")
320
  with gr.Row():
321
  api_text = gr.Textbox(label="Text", value="API test sentence")
322
  api_language = gr.Dropdown(choices=supported_language_codes, value="en-us", label="Language")
323
  api_btn = gr.Button("Generate Speech")
324
  api_output = gr.Audio(label="Generated Speech")
325
 
326
- # Connect the UI components
327
  api_btn.click(
328
  fn=simple_api_generate_speech,
329
  inputs=[api_text, api_language],
330
  outputs=api_output
331
  )
332
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  model_choice.change(
334
  fn=update_ui,
335
  inputs=[model_choice],
@@ -415,15 +427,6 @@ def build_interface():
415
  outputs=[output_audio, seed_number],
416
  )
417
 
418
- # Add explicit API route for external access
419
- demo.add_api_route(
420
- path="/api/tts",
421
- fn=simple_api_generate_speech,
422
- inputs=[api_text, api_language],
423
- outputs=api_output,
424
- methods=["POST"]
425
- )
426
-
427
  return demo
428
 
429
 
@@ -431,5 +434,5 @@ if __name__ == "__main__":
431
  demo = build_interface()
432
  share = getenv("GRADIO_SHARE", "True").lower() in ("true", "1", "t")
433
 
434
- # Launch with corrected parameters (removed ssr_mode=True)
435
  demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=share)
 
314
  type="filepath",
315
  )
316
 
317
+ # API Interface
318
  with gr.Tab("API"):
319
+ gr.Markdown("""### Text-to-Speech API""")
320
  with gr.Row():
321
  api_text = gr.Textbox(label="Text", value="API test sentence")
322
  api_language = gr.Dropdown(choices=supported_language_codes, value="en-us", label="Language")
323
  api_btn = gr.Button("Generate Speech")
324
  api_output = gr.Audio(label="Generated Speech")
325
 
326
+ # Connect the API components
327
  api_btn.click(
328
  fn=simple_api_generate_speech,
329
  inputs=[api_text, api_language],
330
  outputs=api_output
331
  )
332
 
333
+ # Example usage
334
+ gr.Examples(
335
+ examples=[
336
+ ["This is a test of the text to speech system.", "en-us"],
337
+ ["Esto es una prueba del sistema de síntesis de voz.", "es"],
338
+ ["Dies ist ein Test des Text-zu-Sprache-Systems.", "de"]
339
+ ],
340
+ fn=simple_api_generate_speech,
341
+ inputs=[api_text, api_language],
342
+ outputs=api_output
343
+ )
344
+
345
  model_choice.change(
346
  fn=update_ui,
347
  inputs=[model_choice],
 
427
  outputs=[output_audio, seed_number],
428
  )
429
 
 
 
 
 
 
 
 
 
 
430
  return demo
431
 
432
 
 
434
  demo = build_interface()
435
  share = getenv("GRADIO_SHARE", "True").lower() in ("true", "1", "t")
436
 
437
+ # Launch with queue enabled
438
  demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=share)