Download scripts/read_presentation.py from MHamdan/SPARKNET: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/spaces/MHamdan/SPARKNET/resolve/76c3b0a8cd44eb930c2ad41fc0e95acdb3cd2bab/scripts/read_presentation.py
- Command line
-
hf download hf://spaces/MHamdan/SPARKNET@76c3b0a8cd44eb930c2ad41fc0e95acdb3cd2bab/scripts/read_presentation.py
-
curl -L -o read_presentation.py https://huggingface.co/spaces/MHamdan/SPARKNET/resolve/76c3b0a8cd44eb930c2ad41fc0e95acdb3cd2bab/scripts/read_presentation.py
2.11 kB
| """ | |
| Read and analyze SPARKNET presentation | |
| """ | |
| import sys | |
| from pptx import Presentation | |
| def read_presentation(pptx_path): | |
| """Read PowerPoint presentation and extract content""" | |
| try: | |
| prs = Presentation(pptx_path) | |
| print(f"Total Slides: {len(prs.slides)}\n") | |
| print("=" * 80) | |
| for idx, slide in enumerate(prs.slides, 1): | |
| print(f"\n{'='*80}") | |
| print(f"SLIDE {idx}") | |
| print('='*80) | |
| # Get slide title | |
| title = "" | |
| for shape in slide.shapes: | |
| if shape.has_text_frame: | |
| if shape.is_placeholder: | |
| phf = shape.placeholder_format | |
| if phf.type == 1: # Title placeholder | |
| title = shape.text | |
| break | |
| print(f"Title: {title if title else '(No title)'}") | |
| print("-" * 80) | |
| # Get all text content | |
| print("Content:") | |
| for shape in slide.shapes: | |
| if shape.has_text_frame: | |
| for paragraph in shape.text_frame.paragraphs: | |
| text = paragraph.text.strip() | |
| if text: | |
| level = paragraph.level | |
| indent = " " * level | |
| print(f"{indent}- {text}") | |
| # Check for speaker notes | |
| if slide.has_notes_slide: | |
| notes_slide = slide.notes_slide | |
| if notes_slide.notes_text_frame: | |
| notes = notes_slide.notes_text_frame.text.strip() | |
| if notes: | |
| print("\nSpeaker Notes:") | |
| print(notes) | |
| print("\n" + "="*80) | |
| except Exception as e: | |
| print(f"Error reading presentation: {e}", file=sys.stderr) | |
| import traceback | |
| traceback.print_exc() | |
| return False | |
| return True | |
| if __name__ == "__main__": | |
| pptx_path = "/home/mhamdan/SPARKNET/presentation/SPARKNET_Academic_Presentation.pptx" | |
| read_presentation(pptx_path) | |