Spaces:
Running
Running
barghavani
commited on
Commit
•
2334c6b
1
Parent(s):
30f5d93
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,8 @@ from langchain.chains.question_answering import load_qa_chain
|
|
10 |
from langchain.prompts import PromptTemplate
|
11 |
from dotenv import load_dotenv
|
12 |
from streamlit_webrtc import webrtc_streamer, WebRtcMode, ClientSettings
|
|
|
|
|
13 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
14 |
|
15 |
|
@@ -79,33 +81,17 @@ def main():
|
|
79 |
st.header("QnA with Multiple PDF files💁")
|
80 |
|
81 |
# Audio recording
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
)
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
while True:
|
94 |
-
frame = webrtc_ctx.audio_receiver.get_frame(timeout=1)
|
95 |
-
if frame is None:
|
96 |
-
break
|
97 |
-
audio_frames.append(frame)
|
98 |
-
|
99 |
-
if len(audio_frames) > 0:
|
100 |
-
audio_bytes = b"".join(frame.to_ndarray().tobytes() for frame in audio_frames)
|
101 |
-
with open("query.wav", "wb") as f:
|
102 |
-
f.write(audio_bytes)
|
103 |
-
|
104 |
-
model = whisper.load_model("large")
|
105 |
-
result = model.transcribe("query.wav", language="en", fp16=False)
|
106 |
-
user_question = result["text"]
|
107 |
-
st.write("Transcribed Question:", user_question)
|
108 |
-
user_input(user_question)
|
109 |
|
110 |
with st.sidebar:
|
111 |
st.title("Menu:")
|
|
|
10 |
from langchain.prompts import PromptTemplate
|
11 |
from dotenv import load_dotenv
|
12 |
from streamlit_webrtc import webrtc_streamer, WebRtcMode, ClientSettings
|
13 |
+
from audio_recorder_streamlit import audio_recorder
|
14 |
+
|
15 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
16 |
|
17 |
|
|
|
81 |
st.header("QnA with Multiple PDF files💁")
|
82 |
|
83 |
# Audio recording
|
84 |
+
audio_bytes = audio_recorder(pause_threshold=2.0)
|
85 |
+
|
86 |
+
if audio_bytes:
|
87 |
+
with open("query.wav", "wb") as f:
|
88 |
+
f.write(audio_bytes)
|
89 |
+
|
90 |
+
model = whisper.load_model("large")
|
91 |
+
result = model.transcribe("query.wav", language="en", fp16=False)
|
92 |
+
user_question = result["text"]
|
93 |
+
st.write("Transcribed Question:", user_question)
|
94 |
+
user_input(user_question)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
with st.sidebar:
|
97 |
st.title("Menu:")
|