Spaces:
Runtime error
Runtime error
File size: 891 Bytes
c800729 3bc3f66 c800729 3bc3f66 c800729 3bc3f66 c800729 3bc3f66 c800729 3bc3f66 c800729 3bc3f66 c800729 3bc3f66 |
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 |
import gradio as gr
from utils.stt import speech_to_text
from utils.nlp import process_query
from utils.tts import text_to_speech
# Load intents and other configurations
import json
with open("intents.json", "r") as f:
intents = json.load(f)
def voice_agent(audio):
# Step 1: Convert speech to text
query = speech_to_text(audio)
# Step 2: Process the query and get a response
response = process_query(query, intents)
# Step 3: Convert the response to speech
audio_response = text_to_speech(response)
return response, audio_response
# Gradio interface
interface = gr.Interface(
fn=voice_agent,
inputs=gr.Audio(source="microphone", type="filepath"),
outputs=[
gr.Textbox(label="Agent Response"),
gr.Audio(label="Voice Response")
],
title="Hotel Booking Voice Agent"
)
if __name__ == "__main__":
interface.launch()
|