Spaces:
Runtime error
Runtime error
DSatishchandra
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ from transformers import pipeline
|
|
7 |
# Initialize recognizer for speech recognition
|
8 |
recognizer = sr.Recognizer()
|
9 |
|
10 |
-
# Initialize Hugging Face NLP pipeline for intent recognition
|
11 |
-
nlp = pipeline("zero-shot-classification")
|
12 |
|
13 |
# Define the food menu
|
14 |
menu = {
|
@@ -28,6 +28,7 @@ def process_order(order):
|
|
28 |
# Function to handle speech recognition
|
29 |
def recognize_speech(audio):
|
30 |
try:
|
|
|
31 |
text = recognizer.recognize_google(audio)
|
32 |
response = process_order(text)
|
33 |
|
@@ -45,7 +46,7 @@ def create_gradio_interface():
|
|
45 |
with gr.Blocks() as demo:
|
46 |
gr.Markdown("## AI Voice Bot for Food Ordering")
|
47 |
|
48 |
-
#
|
49 |
audio_input = gr.Audio(source="microphone", type="numpy", label="Speak to the bot")
|
50 |
|
51 |
# Display the bot's response after recognition
|
|
|
7 |
# Initialize recognizer for speech recognition
|
8 |
recognizer = sr.Recognizer()
|
9 |
|
10 |
+
# Initialize Hugging Face NLP pipeline for intent recognition using a specific model
|
11 |
+
nlp = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
12 |
|
13 |
# Define the food menu
|
14 |
menu = {
|
|
|
28 |
# Function to handle speech recognition
|
29 |
def recognize_speech(audio):
|
30 |
try:
|
31 |
+
# Recognize speech using SpeechRecognition
|
32 |
text = recognizer.recognize_google(audio)
|
33 |
response = process_order(text)
|
34 |
|
|
|
46 |
with gr.Blocks() as demo:
|
47 |
gr.Markdown("## AI Voice Bot for Food Ordering")
|
48 |
|
49 |
+
# Audio Input: User speaks into microphone
|
50 |
audio_input = gr.Audio(source="microphone", type="numpy", label="Speak to the bot")
|
51 |
|
52 |
# Display the bot's response after recognition
|