Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import asyncio
|
| 3 |
import speech_recognition as sr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Mock AI core for demonstration purposes
|
| 6 |
class AICore:
|
|
@@ -29,14 +33,17 @@ def submit_query(query, chat_history):
|
|
| 29 |
def listen_voice_command():
|
| 30 |
recognizer = sr.Recognizer()
|
| 31 |
with sr.Microphone() as source:
|
| 32 |
-
|
| 33 |
audio = recognizer.listen(source)
|
| 34 |
try:
|
| 35 |
query = recognizer.recognize_google(audio)
|
|
|
|
| 36 |
return query
|
| 37 |
except sr.UnknownValueError:
|
|
|
|
| 38 |
return "Could not understand audio"
|
| 39 |
except sr.RequestError as e:
|
|
|
|
| 40 |
return f"Could not request results; {e}"
|
| 41 |
|
| 42 |
# Gradio app
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import asyncio
|
| 3 |
import speech_recognition as sr
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
# Configure logging
|
| 7 |
+
logging.basicConfig(level=logging.INFO)
|
| 8 |
|
| 9 |
# Mock AI core for demonstration purposes
|
| 10 |
class AICore:
|
|
|
|
| 33 |
def listen_voice_command():
|
| 34 |
recognizer = sr.Recognizer()
|
| 35 |
with sr.Microphone() as source:
|
| 36 |
+
logging.info("Listening...")
|
| 37 |
audio = recognizer.listen(source)
|
| 38 |
try:
|
| 39 |
query = recognizer.recognize_google(audio)
|
| 40 |
+
logging.info(f"Voice input recognized: {query}")
|
| 41 |
return query
|
| 42 |
except sr.UnknownValueError:
|
| 43 |
+
logging.error("Could not understand audio")
|
| 44 |
return "Could not understand audio"
|
| 45 |
except sr.RequestError as e:
|
| 46 |
+
logging.error(f"Could not request results; {e}")
|
| 47 |
return f"Could not request results; {e}"
|
| 48 |
|
| 49 |
# Gradio app
|