Spaces:
Runtime error
Runtime error
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() | |