prasanth345 commited on
Commit
cedbd5e
·
verified ·
1 Parent(s): 5372002

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -23
app.py CHANGED
@@ -1,27 +1,24 @@
 
1
  import gradio as gr
2
- import speech_recognition as sr
3
 
4
- def booking_agent(input_text):
5
- # Example placeholder for hotel booking logic
6
- return f"Hotel booked successfully for: {input_text}"
 
 
 
 
 
7
 
8
- def voice_booking(audio):
9
- recognizer = sr.Recognizer()
10
- with sr.AudioFile(audio.name) as source:
11
- audio_data = recognizer.record(source)
12
- try:
13
- text = recognizer.recognize_google(audio_data)
14
- return booking_agent(text)
15
- except sr.UnknownValueError:
16
- return "Sorry, could not understand the audio."
 
17
 
18
- # Gradio Interface
19
- iface = gr.Interface(
20
- fn=voice_booking,
21
- inputs=gr.inputs.Audio(),
22
- outputs="text",
23
- title="Hotel Booking Chatbot",
24
- description="Use voice or text to book a hotel",
25
- )
26
-
27
- iface.launch()
 
1
+ # app.py
2
  import gradio as gr
 
3
 
4
+ def chatbot_response(message):
5
+ # Simple response logic
6
+ responses = {
7
+ "book a hotel": "Sure! What date and location?",
8
+ "check availability": "Let me check the availability...",
9
+ "hotel pricing": "Here are the pricing options...",
10
+ }
11
+ return responses.get(message.lower(), "Sorry, I didn't understand that.")
12
 
13
+ with gr.Blocks() as chatbot:
14
+ gr.Markdown("# Hotel Booking Chatbot")
15
+ with gr.Row():
16
+ message_input = gr.Textbox(label="Your Message")
17
+ with gr.Row():
18
+ submit_button = gr.Button("Send")
19
+ with gr.Row():
20
+ output = gr.Textbox(label="Chatbot Response")
21
+
22
+ submit_button.click(chatbot_response, inputs=message_input, outputs=output)
23
 
24
+ chatbot.launch()