-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e51809
commit 21556d6
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|