Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -102,23 +102,29 @@ def user_input(user_question):
|
|
102 |
|
103 |
|
104 |
def main():
|
105 |
-
st.set_page_config("
|
106 |
-
st.header("
|
107 |
-
|
108 |
-
user_question = st.text_input(result.text)
|
109 |
-
|
110 |
-
if user_question:
|
111 |
-
user_input(user_question)
|
112 |
|
113 |
with st.sidebar:
|
114 |
-
st.
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
|
124 |
|
|
|
102 |
|
103 |
|
104 |
def main():
|
105 |
+
st.set_page_config(page_title="Voice-enabled PDF QnA")
|
106 |
+
st.header("Ask questions by voice or text from PDFs")
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
with st.sidebar:
|
109 |
+
pdf_docs = st.file_uploader("Upload PDFs:", accept_multiple_files=True)
|
110 |
+
submit_button = st.button("Process PDFs")
|
111 |
+
|
112 |
+
# Handling PDF processing
|
113 |
+
if submit_button and pdf_docs:
|
114 |
+
with st.spinner("Extracting text from PDFs..."):
|
115 |
+
raw_text = get_pdf_text(pdf_docs)
|
116 |
+
text_chunks = get_text_chunks(raw_text)
|
117 |
+
get_vector_store(text_chunks)
|
118 |
+
st.success("PDFs processed and ready for questions.")
|
119 |
+
|
120 |
+
# Voice recording for question
|
121 |
+
audio_file = st.file_uploader("Record your question as audio (WAV format):", type=["wav"])
|
122 |
+
if audio_file:
|
123 |
+
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
|
124 |
+
tmp_file.write(audio_file.getvalue())
|
125 |
+
transcribed_text = transcribe(tmp_file.name)
|
126 |
+
st.text_input("Transcribed question:", transcribed_text)
|
127 |
+
user_input(transcribed_text)
|
128 |
|
129 |
|
130 |
|