File size: 1,607 Bytes
d078b7e
630a481
376658d
630a481
a294fd3
630a481
19487ce
a294fd3
19487ce
630a481
19487ce
 
 
134db29
839548e
 
630a481
839548e
a294fd3
 
839548e
 
a294fd3
839548e
a294fd3
839548e
 
a294fd3
839548e
 
a294fd3
 
839548e
a294fd3
839548e
 
a294fd3
839548e
054b40b
630a481
839548e
 
 
 
 
630a481
 
a294fd3
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import gradio as gr
from deployer.simulator_interface import VirtualRobot

def robot_behavior(user_input: str):
    """Handle robot interaction logic"""
    bot = VirtualRobot()
    text = user_input.lower().strip()
    
    if any(g in text for g in ["hello", "hi", "hey", "welcome"]):
        return bot.perform_action("wave") + "\n" + bot.perform_action("say Hello there!")
    if text.startswith("say"):
        return bot.perform_action(text)
    return bot.perform_action("say I didn't understand that. Try again!")

def create_interface():
    """Create the Gradio interface components"""
    with gr.Blocks() as demo:
        gr.Markdown("# 🤖 RoboSage App\n\nYour robot, your voice.")
        
        with gr.Row():
            input_text = gr.Textbox(label="Speak or Type", lines=1)
            send_button = gr.Button("Send", variant="primary")
        
        output_text = gr.Textbox(label="Robot Response", interactive=False)
        
        # Event handlers
        send_button.click(
            fn=robot_behavior,
            inputs=input_text,
            outputs=output_text
        )
        
        input_text.submit(
            fn=robot_behavior,
            inputs=input_text,
            outputs=output_text
        )
    
    return demo

def launch_gradio_app(title="RoboSage App", description="Your robot, your voice."):
    """Launch the Gradio application"""
    interface = create_interface()
    return interface

if __name__ == "__main__":
    app = launch_gradio_app()
    app.launch(
        server_name="0.0.0.0",
        server_port=7860,
        share=False
    )