import streamlit as st from io import StringIO from pdf_txt import pdf_to_text from summarizer1 import summarizer from summarizer2 import generate_summary from pathlib import Path import os st.markdown("

Text Summarizer

", unsafe_allow_html=True) file = st.file_uploader("Please choose a file", type=['txt', 'pdf']) st.markdown("
OR
", unsafe_allow_html=True) text = st.text_area("Input Text For Summary (More than 200 words)", height=200) col1, col2, col3 = st.columns(3) if col1.button('SUMMARIZE'): #try: if file is not None: if bool(text)== True: st.error("ERROR: YOU CAN'T ENTER BOTH") st.stop() else: if file.name[-3:] == "pdf": path=Path("uploaded_pdfs/" + file.name) path.write_bytes(file.getvalue()) text = pdf_to_text("uploaded_pdfs/" + file.name) else: stringio = StringIO(file.getvalue().decode("utf-8")) text=stringio.read() textfile = open("content.txt","w") textfile.write(text) textfile.close() summary1=summarizer(text) summary2=generate_summary("content.txt") st.markdown("

Your Summary :

" , unsafe_allow_html=True) st.markdown("

> Summary 1 :

" , unsafe_allow_html=True) st.write(summary1) st.markdown("

> Summary 2 :

" , unsafe_allow_html=True) st.write(summary2)