ojasrohatgi commited on
Commit
6ddca97
·
verified ·
1 Parent(s): 998932f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -24
app.py CHANGED
@@ -9,10 +9,9 @@ from reportlab.lib.pagesizes import A4
9
  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
10
  from reportlab.platypus import SimpleDocTemplate, Paragraph
11
  from reportlab.lib.enums import TA_JUSTIFY
12
- import pyttsx3
13
 
14
  # Initialize the summarization pipeline
15
- summarizer = pipeline("summarization", model="facebook/bart-small") # facebook/bart-large-cnn
16
 
17
  # Set page layout to wide
18
  st.set_page_config(layout="wide")
@@ -36,16 +35,9 @@ def create_pdf(text):
36
  return pdf_buffer
37
 
38
 
39
- # Function to read aloud the summary
40
- def read_aloud(text):
41
- engine = pyttsx3.init()
42
- engine.say(text)
43
- engine.runAndWait()
44
-
45
-
46
  # Main application
47
  def main():
48
- st.title("Abstractive Article Summarizer")
49
 
50
  url = st.text_input("Enter the URL of an article:", key="url")
51
  max_chunk = 300
@@ -117,20 +109,13 @@ def main():
117
  else:
118
  st.warning(f"Compression may be excessive.\nThe summary could be too brief and miss important details.")
119
 
120
- # Display buttons in columns
121
- col1, col2 = st.columns([1, 1])
122
-
123
- with col1:
124
- st.download_button(
125
- label="Download Summary as PDF",
126
- data=pdf_buffer,
127
- file_name="summarized_article.pdf",
128
- mime="application/pdf"
129
- )
130
-
131
- with col2:
132
- if st.button("Read Aloud Summary"):
133
- read_aloud(summary_text)
134
 
135
  except Exception as e:
136
  st.warning(f"Error: {e}")
 
9
  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
10
  from reportlab.platypus import SimpleDocTemplate, Paragraph
11
  from reportlab.lib.enums import TA_JUSTIFY
 
12
 
13
  # Initialize the summarization pipeline
14
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
15
 
16
  # Set page layout to wide
17
  st.set_page_config(layout="wide")
 
35
  return pdf_buffer
36
 
37
 
 
 
 
 
 
 
 
38
  # Main application
39
  def main():
40
+ st.title("Enhanced Article Extractor and Summarizer")
41
 
42
  url = st.text_input("Enter the URL of an article:", key="url")
43
  max_chunk = 300
 
109
  else:
110
  st.warning(f"Compression may be excessive.\nThe summary could be too brief and miss important details.")
111
 
112
+ # Display download button
113
+ st.download_button(
114
+ label="Download Summary as PDF",
115
+ data=pdf_buffer,
116
+ file_name="summarized_article.pdf",
117
+ mime="application/pdf"
118
+ )
 
 
 
 
 
 
 
119
 
120
  except Exception as e:
121
  st.warning(f"Error: {e}")