SpeechT5_hy / archive /test_gradio.py
Edmon02's picture
feat: Implement project organization plan and optimize TTS deployment
3f1840e
#!/usr/bin/env python3
"""
Gradio Compatibility Test
========================
Quick test to verify Gradio interface compatibility.
"""
import gradio as gr
import numpy as np
def test_interface():
"""Test basic Gradio interface creation."""
def simple_predict(text):
return f"Processed: {text}"
# Test interface creation with modern Gradio
with gr.Blocks(title="Test Interface") as interface:
gr.Markdown("# Test Interface")
with gr.Row():
text_input = gr.Textbox(label="Input")
output = gr.Textbox(label="Output")
btn = gr.Button("Process")
# Test examples
gr.Examples(
examples=[["Test 1"], ["Test 2"]],
inputs=[text_input],
outputs=[output],
fn=simple_predict
)
# Test event handlers
btn.click(
fn=simple_predict,
inputs=[text_input],
outputs=[output],
show_progress="minimal"
)
print("βœ… Gradio interface test passed!")
return interface
if __name__ == "__main__":
print("πŸ§ͺ Testing Gradio compatibility...")
try:
interface = test_interface()
print("πŸŽ‰ All Gradio features working correctly!")
# Don't launch, just test creation
print("πŸ“‹ Interface created successfully with:")
print(" β€’ Modern Blocks API")
print(" β€’ Updated event handlers")
print(" β€’ Compatible Examples component")
print(" β€’ Proper show_progress values")
except Exception as e:
print(f"❌ Gradio compatibility test failed: {e}")
exit(1)