Skip to content

Commit

Permalink
added file for audio modality
Browse files Browse the repository at this point in the history
  • Loading branch information
THEFASHIONGEEK authored Dec 2, 2019
1 parent 1e51809 commit 21556d6
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions vid_to_wav.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import subprocess
import os
import zipfile

## Runnin a loop throught all the zipped training file to extract all .wav audio files
for i in range(1,76):
if i<10:
zipfilename = 'training80_0'+str(i)+'.zip'
else:
zipfilename = 'training80_'+str(i)+'.zip'
## Accessing the zipfile i
archive = zipfile.ZipFile('data/'+zipfilename, 'r')
zipfilename = zipfilename.split('.zip')[0]
#archive.extractall('unzippedData/'+zipfilename)
for file_name in archive.namelist():
file_name=(file_name.split('.mp4'))[0]
try:
if not os.path.exists('VoiceData/trainingData/'):
os.makedirs('VoiceData/trainingData/')
except OSError:
print ('Error: Creating directory of data')
command = "ffmpeg -i unzippedData/{}/{}.mp4 -ab 320k -ac 2 -ar 44100 -vn VoiceData/trainingData/{}.wav".format(zipfilename,file_name,file_name)
subprocess.call(command, shell=True)

for i in range(1,26):
if i<10:
zipfilename = 'validation80_0'+str(i)+'.zip'
else:
zipfilename = 'validation80_'+str(i)+'.zip'
## Accessing the zipfile i
archive = zipfile.ZipFile('data/'+zipfilename, 'r')
zipfilename = zipfilename.split('.zip')[0]
#archive.extractall('unzippedData/'+zipfilename)
for file_name in archive.namelist():
file_name=(file_name.split('.mp4'))[0]
try:
if not os.path.exists('VoiceData/validationData/'):
os.makedirs('VoiceData/validationData/')
except OSError:
print ('Error: Creating directory of data')
command = "ffmpeg -i unzippedData/{}/{}.mp4 -ab 320k -ac 2 -ar 44100 -vn VoiceData/validationData/{}.wav".format(zipfilename,file_name,file_name)
subprocess.call(command, shell=True)


0 comments on commit 21556d6

Please sign in to comment.