File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Sound extractor from PPT files
2
+
3
+ This is a simple python script to extract embedded audio in ppt files
4
+ and merge them into one file.
5
+
6
+ * To run this script, open the terminal and cd to the directory where your ppt file lies.
7
+ * Type the command python3 extractSound.py Filename.ppt where Filename is the ppt file that you want to extract its embedded audio.
8
+ * Now, you should find a joinedFile.wav file in the same directory.
Original file line number Diff line number Diff line change
1
+ import sys
2
+ import os .path
3
+ import zipfile
4
+ import shutil
5
+ from pydub import AudioSegment
6
+
7
+ def main ():
8
+ fileName = sys .argv [1 ]
9
+ if not os .path .isfile (fileName ):
10
+ print ('File does not exist' )
11
+ return
12
+ with zipfile .ZipFile (fileName ,"r" ) as zip_ref :
13
+ zip_ref .extractall ("targetdir" )
14
+ audioFileNum = 1
15
+ path = "targetdir/ppt/media/audio{}.wav" .format (audioFileNum )
16
+ if not os .path .isfile (path ):
17
+ print ('No audio files in this ppt' )
18
+ return
19
+ combinedSound = AudioSegment .from_wav (path )
20
+ audioFileNum = audioFileNum + 1
21
+ while os .path .isfile ("targetdir/ppt/media/audio{}.wav" .format (audioFileNum )):
22
+ combinedSound = combinedSound + \
23
+ AudioSegment .from_wav ("targetdir/ppt/media/audio{}.wav" .format (audioFileNum ))
24
+ audioFileNum = audioFileNum + 1
25
+ combinedSound .export ("joinedFile.wav" , format = "wav" )
26
+ dir_path = 'targetdir'
27
+ try :
28
+ shutil .rmtree (dir_path )
29
+ except OSError as e :
30
+ print ("Error: %s : %s" % (dir_path , e .strerror ))
31
+ if __name__ == '__main__' :
32
+ main ()
33
+
You can’t perform that action at this time.
0 commit comments