File size: 772 Bytes
c800729
423ebdd
c800729
423ebdd
 
 
c800729
423ebdd
 
 
 
 
 
 
 
 
c800729
423ebdd
 
 
 
 
 
 
3bc3f66
c800729
423ebdd
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
import gradio as gr
import speech_recognition as sr

def booking_agent(input_text):
    # Example placeholder for hotel booking logic
    return f"Hotel booked successfully for: {input_text}"

def voice_booking(audio):
    recognizer = sr.Recognizer()
    with sr.AudioFile(audio.name) as source:
        audio_data = recognizer.record(source)
        try:
            text = recognizer.recognize_google(audio_data)
            return booking_agent(text)
        except sr.UnknownValueError:
            return "Sorry, could not understand the audio."

# Gradio Interface
iface = gr.Interface(
    fn=voice_booking,
    inputs=gr.inputs.Audio(),
    outputs="text",
    title="Hotel Booking Chatbot",
    description="Use voice or text to book a hotel",
)

iface.launch()