iajitpanday commited on
Commit
856ea39
·
verified ·
1 Parent(s): 6642ed5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -51
app.py CHANGED
@@ -397,8 +397,31 @@ def admin_get_conversations():
397
  if 'conn' in locals():
398
  conn.close()
399
 
400
- # Complete build_gradio_interface function with fixed Audio component
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
 
 
402
  def build_gradio_interface():
403
  # Admin section
404
  with gr.Blocks() as admin_interface:
@@ -460,7 +483,7 @@ def build_gradio_interface():
460
  outputs=output_json
461
  )
462
 
463
- # Debug interface
464
  with gr.Blocks() as debug_interface:
465
  gr.Markdown("# Debug Interface")
466
  audio_input = gr.Audio(label="Test Audio Input")
@@ -481,57 +504,8 @@ def build_gradio_interface():
481
 
482
  return demo
483
 
484
- # Add these debug functions to your application
485
-
486
- def debug_audio(audio):
487
- """Debug function to understand audio format"""
488
- try:
489
- result = {
490
- "type": type(audio).__name__,
491
- "is_tuple": isinstance(audio, tuple),
492
- "length": len(audio) if hasattr(audio, "__len__") else "N/A"
493
- }
494
-
495
- if isinstance(audio, tuple) and len(audio) == 2:
496
- result["data_type"] = type(audio[0]).__name__
497
- result["sample_rate"] = audio[1]
498
-
499
- if hasattr(audio[0], "shape"):
500
- result["shape"] = audio[0].shape
501
- result["dtype"] = str(audio[0].dtype)
502
- result["min_val"] = float(audio[0].min())
503
- result["max_val"] = float(audio[0].max())
504
-
505
- return {"debug_info": result}
506
- except Exception as e:
507
- return {"error": str(e)}
508
-
509
- # Add this to your Gradio interface for testing
510
- def add_debug_tab(interface):
511
- with gr.Blocks() as debug_interface:
512
- gr.Markdown("# Debug Interface")
513
- audio_input = gr.Audio(label="Test Audio Input")
514
- debug_btn = gr.Button("Debug Audio Format")
515
- output_json = gr.JSON(label="Debug Info")
516
-
517
- debug_btn.click(
518
- debug_audio,
519
- inputs=audio_input,
520
- outputs=output_json
521
- )
522
-
523
- # Add the debug tab to your interface
524
- interface.tabs.append(debug_interface)
525
- interface.tab_names.append("Debug")
526
-
527
- return interface
528
-
529
-
530
  # Create and launch the interface
531
  interface = build_gradio_interface()
532
 
533
- # Add debug tab if needed
534
- interface = add_debug_tab(interface)
535
-
536
  # Launch for Hugging Face Spaces
537
  interface.launch()
 
397
  if 'conn' in locals():
398
  conn.close()
399
 
400
+ # Debug function
401
+ def debug_audio(audio):
402
+ """Debug function to understand audio format"""
403
+ try:
404
+ result = {
405
+ "type": type(audio).__name__,
406
+ "is_tuple": isinstance(audio, tuple),
407
+ "length": len(audio) if hasattr(audio, "__len__") else "N/A"
408
+ }
409
+
410
+ if isinstance(audio, tuple) and len(audio) == 2:
411
+ result["data_type"] = type(audio[0]).__name__
412
+ result["sample_rate"] = audio[1]
413
+
414
+ if hasattr(audio[0], "shape"):
415
+ result["shape"] = audio[0].shape
416
+ result["dtype"] = str(audio[0].dtype)
417
+ result["min_val"] = float(audio[0].min())
418
+ result["max_val"] = float(audio[0].max())
419
+
420
+ return {"debug_info": result}
421
+ except Exception as e:
422
+ return {"error": str(e)}
423
 
424
+ # Fixed: Complete build_gradio_interface function that includes the debug tab directly
425
  def build_gradio_interface():
426
  # Admin section
427
  with gr.Blocks() as admin_interface:
 
483
  outputs=output_json
484
  )
485
 
486
+ # Debug interface
487
  with gr.Blocks() as debug_interface:
488
  gr.Markdown("# Debug Interface")
489
  audio_input = gr.Audio(label="Test Audio Input")
 
504
 
505
  return demo
506
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
507
  # Create and launch the interface
508
  interface = build_gradio_interface()
509
 
 
 
 
510
  # Launch for Hugging Face Spaces
511
  interface.launch()