Update app.py
Browse files
app.py
CHANGED
@@ -492,7 +492,7 @@ st.markdown("🔹 Powered by Mayank, Wasim, Pravishank – Innovating Healthcare
|
|
492 |
|
493 |
import streamlit as st
|
494 |
import speech_recognition as sr
|
495 |
-
import sounddevice as sd
|
496 |
from deep_translator import GoogleTranslator
|
497 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
498 |
import matplotlib.pyplot as plt
|
@@ -539,18 +539,23 @@ def get_user_location():
|
|
539 |
if option == "Home":
|
540 |
user_question = st.text_input("Type your symptoms or disease name:")
|
541 |
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
|
|
|
|
|
|
|
|
|
|
554 |
|
555 |
# lang = st.selectbox("Select Language", ["English", "Hindi", "Spanish"])
|
556 |
# if lang != "English":
|
|
|
492 |
|
493 |
import streamlit as st
|
494 |
import speech_recognition as sr
|
495 |
+
# import sounddevice as sd
|
496 |
from deep_translator import GoogleTranslator
|
497 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
498 |
import matplotlib.pyplot as plt
|
|
|
539 |
if option == "Home":
|
540 |
user_question = st.text_input("Type your symptoms or disease name:")
|
541 |
|
542 |
+
st.title("🎤 AI Health Assistant - Speech to Text")
|
543 |
+
|
544 |
+
uploaded_file = st.file_uploader("Upload an audio file (.wav)", type=["wav"])
|
545 |
+
|
546 |
+
if uploaded_file:
|
547 |
+
recognizer = sr.Recognizer()
|
548 |
+
with sr.AudioFile(uploaded_file) as source:
|
549 |
+
st.info("Processing audio...")
|
550 |
+
audio = recognizer.record(source)
|
551 |
+
|
552 |
+
try:
|
553 |
+
text = recognizer.recognize_google(audio)
|
554 |
+
st.success(f"Recognized Text: {text}")
|
555 |
+
except sr.UnknownValueError:
|
556 |
+
st.error("Could not understand the audio")
|
557 |
+
except sr.RequestError:
|
558 |
+
st.error("Error with the speech recognition service")
|
559 |
|
560 |
# lang = st.selectbox("Select Language", ["English", "Hindi", "Spanish"])
|
561 |
# if lang != "English":
|