File size: 1,075 Bytes
cb8e471
ea3d5fc
 
cb8e471
ea3d5fc
 
cb8e471
 
521ec8e
cb8e471
ea3d5fc
521ec8e
cb8e471
 
 
 
 
 
ea3d5fc
cb8e471
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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()