barghavani commited on
Commit
e815db6
·
verified ·
1 Parent(s): 2225d19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -15
app.py CHANGED
@@ -102,23 +102,29 @@ def user_input(user_question):
102
 
103
 
104
  def main():
105
- st.set_page_config("Chat PDF")
106
- st.header("QnA with Multiple PDF files💁")
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.title("Menu:")
115
- pdf_docs = st.file_uploader("Upload your PDF Files and Click on the Submit & Process Button", accept_multiple_files=True)
116
- if st.button("Submit & Process"):
117
- with st.spinner("Processing..."):
118
- raw_text = get_pdf_text(pdf_docs)
119
- text_chunks = get_text_chunks(raw_text)
120
- get_vector_store(text_chunks)
121
- st.success("Done")
 
 
 
 
 
 
 
 
 
 
 
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