MayankGupta06 commited on
Commit
213818c
·
verified ·
1 Parent(s): 21f8383

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
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
- if st.button("🎤 Speak Symptoms"):
543
- recognizer = sr.Recognizer()
544
- with sr.Microphone() as source:
545
- st.info("Listening...")
546
- try:
547
- audio = recognizer.listen(source)
548
- user_question = recognizer.recognize_google(audio)
549
- st.success(f"Recognized: {user_question}")
550
- except sr.UnknownValueError:
551
- st.error("Could not understand audio")
552
- except sr.RequestError:
553
- st.error("Error in speech recognition service")
 
 
 
 
 
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":