# Install necessary libraries libraries = [ 'transformers==4.12.2', 'gradio', 'python-pptx==0.6.19', ] for library in libraries: try: subprocess.check_call(['pip', 'install', library]) except subprocess.CalledProcessError as e: print(f"Error installing {library}: {e}") from pptx import Presentation import re from transformers import pipeline import subprocess import gradio as gr def extract_text_from_pptx(file_path): presentation = Presentation(file_path) text = [] for slide_number, slide in enumerate(presentation.slides, start=1): for shape in slide.shapes: if hasattr(shape, "text"): text.append(shape.text) return "\n".join(text) def predict_pptx_content(file_path): extracted_text = extract_text_from_pptx(file_path) cleaned_text = re.sub(r'\s+', ' ', extracted_text) classifier = pipeline("text-classification", model="Ahmed235/roberta_classification") summarizer = pipeline("summarization", model="Falconsai/text_summarization") result = classifier(cleaned_text)[0] predicted_label = result['label'] predicted_probability = result['score'] prediction = { "Predicted Label": predicted_label, "Evaluation": f"Evaluate the topic according to {predicted_label} is: {predicted_probability}", "Summary": summarizer(cleaned_text, max_length=80, min_length=30, do_sample=False) } return prediction # Define the Gradio interface iface = gr.Interface( fn=predict_pptx_content, inputs=gr.File(type="file", label="Upload PowerPoint (.pptx) file"), outputs=["text", "text", "text"], # Predicted Label, Evaluation, Summary live=False, # Change to False for one-time analysis title="

PPTX Analyzer

", ) # Deploy the Gradio interface iface.launch(share=True)