Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,12 +15,16 @@ def extract_text_from_pdf(pdf_file):
|
|
| 15 |
st.error(f"Error reading the PDF: {e}")
|
| 16 |
return text
|
| 17 |
|
| 18 |
-
# Function to generate discussion points
|
| 19 |
def generate_discussion_points(text, user_prompt=None):
|
| 20 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
|
|
|
|
|
|
| 21 |
if user_prompt:
|
| 22 |
-
text = user_prompt + " " + text
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
return summary[0]['summary_text']
|
| 25 |
|
| 26 |
# Function to convert text to speech
|
|
@@ -31,13 +35,13 @@ def text_to_speech(text, output_file="output.mp3"):
|
|
| 31 |
|
| 32 |
# Streamlit app starts here
|
| 33 |
st.title("📄 PDF Discussion Points Generator with User Prompts")
|
| 34 |
-
st.write("Upload a
|
| 35 |
|
| 36 |
# File uploader
|
| 37 |
uploaded_file = st.file_uploader("Upload a PDF", type=["pdf"])
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
user_prompt = st.
|
| 41 |
|
| 42 |
if uploaded_file:
|
| 43 |
# Extract text from uploaded PDF
|
|
|
|
| 15 |
st.error(f"Error reading the PDF: {e}")
|
| 16 |
return text
|
| 17 |
|
| 18 |
+
# Function to generate discussion points with adjustable summary length
|
| 19 |
def generate_discussion_points(text, user_prompt=None):
|
| 20 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 21 |
+
|
| 22 |
+
# Optionally include the user's prompt to guide the summary
|
| 23 |
if user_prompt:
|
| 24 |
+
text = user_prompt + " " + text
|
| 25 |
+
|
| 26 |
+
# Adjust the max_length and min_length for a longer summary
|
| 27 |
+
summary = summarizer(text, max_length=300, min_length=100, do_sample=False)
|
| 28 |
return summary[0]['summary_text']
|
| 29 |
|
| 30 |
# Function to convert text to speech
|
|
|
|
| 35 |
|
| 36 |
# Streamlit app starts here
|
| 37 |
st.title("📄 PDF Discussion Points Generator with User Prompts")
|
| 38 |
+
st.write("Upload a PDF file to generate discussion points and listen to them. Optionally, provide a prompt to guide the summary.")
|
| 39 |
|
| 40 |
# File uploader
|
| 41 |
uploaded_file = st.file_uploader("Upload a PDF", type=["pdf"])
|
| 42 |
|
| 43 |
+
# Input for user-defined summary prompt
|
| 44 |
+
user_prompt = st.text_area("Enter a prompt to guide the summary (optional)", height=100)
|
| 45 |
|
| 46 |
if uploaded_file:
|
| 47 |
# Extract text from uploaded PDF
|