Extracting speaker notes from a PowerPoint pptx file with PHP & Python

Extracting speaker notes from a PowerPoint pptx file with PHP & Python

This tutorial was done on Mac and will need to be changed for your operating system. 

First make sure you have Python installed. This should already be on your system on a Mac. Mine is locatted /usr/local/bin/python3. In the python file we create later you will need to change the top #!/usr/local/bin/python3 to match 

Create a file called index.php in your root. In Terminal run php -S localhost:8080.

In the index file paste.

<?php
$notes = exec("[Full path to your Py file we create in a minute] 2>&1");
print_r($notes);

Now create another file called notesexport.py in the root, paste the following.

#!/usr/local/bin/python3

from pptx import Presentation

file = 'presentation.pptx'

ppt=Presentation(file)

notes = []

for page, slide in enumerate(ppt.slides):

# this is the notes that doesn't appear on the ppt slide,

# but really the 'presenter' note.

textNote = slide.notes_slide.notes_text_frame.text

notes.append((page,textNote))

print(notes)

In your terminal navigate to the root folder and run the following commands:

sudo chmod +x notesexport.py

sudo easy_install pip

phyton3 -m pip install python-pptx

Create a presentation in your root folder called presentation.pptx and add some speaker notes to it on different slides. Go to localhost:8080 and you should now see the pages with the speaker notes. 

Categories: Posts