| # gradio_generator.py - Launches the Gradio interface for robot apps | |
| import gradio as gr | |
| import asyncio | |
| from core_creator.voice_to_app import VoiceToAppCreator | |
| def deploy_callback(voice_input): | |
| creator = VoiceToAppCreator(voice_input) | |
| app_package = creator.run_pipeline() | |
| return app_package["blueprint"], app_package["code"] | |
| def robot_behavior(): | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## π€ Voice-to-Robot App Generator") | |
| voice_input = gr.Textbox(label="Describe your robot idea") | |
| blueprint_output = gr.JSON(label="App Blueprint") | |
| code_output = gr.Code(label="Generated Code", language="python") | |
| generate_button = gr.Button("Generate App") | |
| def on_click(voice_input): | |
| return deploy_callback(voice_input) | |
| generate_button.click(fn=on_click, inputs=voice_input, outputs=[blueprint_output, code_output]) | |
| # Ensure an event loop is available | |
| try: | |
| asyncio.get_event_loop() | |
| except RuntimeError: | |
| asyncio.set_event_loop(asyncio.new_event_loop()) | |
| demo.launch() | |