Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,8 @@ import requests
|
|
10 |
import json
|
11 |
import openai
|
12 |
|
|
|
|
|
13 |
# Define a function to split text into chunks
|
14 |
def chunk_text(text, chunk_size=2000):
|
15 |
chunks = []
|
@@ -25,6 +27,10 @@ def chunk_text(text, chunk_size=2000):
|
|
25 |
if 'learning_objectives' not in st.session_state:
|
26 |
st.session_state.learning_objectives = ""
|
27 |
|
|
|
|
|
|
|
|
|
28 |
# Streamlit User Input Form
|
29 |
st.title("Patent Claims Extraction")
|
30 |
|
@@ -40,7 +46,7 @@ if audio_file is not None:
|
|
40 |
|
41 |
# Moved the submit_button check here
|
42 |
if 'submit_button' in st.session_state:
|
43 |
-
model =
|
44 |
|
45 |
if audio_data:
|
46 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as audio_file:
|
@@ -140,5 +146,11 @@ for chunk in chunks:
|
|
140 |
summary = bert_legal_model(chunk, min_length=8, ratio=0.05)
|
141 |
summaries.append(summary)
|
142 |
|
|
|
143 |
# Now you have a list of summaries for each chunk
|
144 |
# You can access them using `summaries[0]`, `summaries[1]`, etc.
|
|
|
|
|
|
|
|
|
|
|
|
10 |
import json
|
11 |
import openai
|
12 |
|
13 |
+
# initialize userinput
|
14 |
+
userinput = ""
|
15 |
# Define a function to split text into chunks
|
16 |
def chunk_text(text, chunk_size=2000):
|
17 |
chunks = []
|
|
|
27 |
if 'learning_objectives' not in st.session_state:
|
28 |
st.session_state.learning_objectives = ""
|
29 |
|
30 |
+
# Initialize the Whisper model outside the button
|
31 |
+
if 'whisper_model' not in st.session_state:
|
32 |
+
st.session_state.whisper_model = whisper.load_model("base")
|
33 |
+
|
34 |
# Streamlit User Input Form
|
35 |
st.title("Patent Claims Extraction")
|
36 |
|
|
|
46 |
|
47 |
# Moved the submit_button check here
|
48 |
if 'submit_button' in st.session_state:
|
49 |
+
model = st.session_state.whisper_model
|
50 |
|
51 |
if audio_data:
|
52 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as audio_file:
|
|
|
146 |
summary = bert_legal_model(chunk, min_length=8, ratio=0.05)
|
147 |
summaries.append(summary)
|
148 |
|
149 |
+
|
150 |
# Now you have a list of summaries for each chunk
|
151 |
# You can access them using `summaries[0]`, `summaries[1]`, etc.
|
152 |
+
# After generating summaries
|
153 |
+
for i, summary in enumerate(summaries):
|
154 |
+
st.write(f"### Summary {i+1}")
|
155 |
+
st.write(summary)
|
156 |
+
|