!pip install PyPDF2 import PyPDF2 from PyPDF2 import PdfReader # Open the PDF file pdf_file_path = "C:/Users/styli/OneDrive/Desktop/OPIT/AAI/Assessment 3/Article 11 Hidden Technical Debt in Machine Learning Systems.pdf" # Use the new PdfReader class to read the PDF pdf_reader = PdfReader(pdf_file_path) # Initialize an empty string to hold the content content = "" # Extract text from each page and concatenate it to the content variable for page in pdf_reader.pages: text = page.extract_text() content += text + "\n" import re # Pattern to match in-text citations (e.g., [1], [2, 3], or (Author, Year)) in_text_citations_pattern = r'\[\d+(,\s*\d+)*\]|\([A-Za-z ]+,\s*\d{4}\)' # Pattern to match the References section at the end of the document references_section_pattern = r'\nReferences[\s\S]*' # Remove in-text citations text_without_citations = re.sub(in_text_citations_pattern, '', content) # Remove the References section text_without_references = re.sub(references_section_pattern, '', text_without_citations) # The new variable without the references cleaned_text = text_without_references !pip install transformers from transformers import T5ForConditionalGeneration, T5Tokenizer model_name = 't5-large' tokenizer = T5Tokenizer.from_pretrained(model_name) model = T5ForConditionalGeneration.from_pretrained(model_name) # Encode the text to input_ids (token ids) to_tokenize = "summarize: " + content inputs = tokenizer.encode(to_tokenize, return_tensors="pt", max_length=512, truncation=True) summary_ids = model.generate(inputs, max_length=48, length_penalty=2, num_beams=5, early_stopping=True) summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True) Summary=summary.capitalize() print(Summary) pip install pyttsx3 import pyttsx3 from IPython.display import Audio # Setup the text-to-speech engine engine = pyttsx3.init() # Generate speech engine.save_to_file(Summary, 'summary.mp3') engine.runAndWait() # Blocks while processing all currently queued commands # Play the audio in Jupyter Notebook Audio('summary.mp3', autoplay=True)