voicekkk / app.py
prasanth345's picture
Update app.py
3bc3f66 verified
raw
history blame
891 Bytes
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()