-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcreate_meta_files.py
52 lines (38 loc) · 1.46 KB
/
create_meta_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 29 10:53:25 2020
@author: krishna
"""
import os
import numpy as np
import argparse
import glob
def create_meta(folder_path,store_loc,mode='train'):
if not os.path.exists(store_loc):
os.makedirs(store_loc)
if mode=='train':
root_dir = os.path.join(folder_path,'TRAIN')
all_files = sorted(glob.glob(root_dir+'/*.json'))
meta_store = store_loc+'/training.txt'
fid = open(meta_store,'w')
for filepath in all_files:
fid.write(filepath+'\n')
fid.close()
elif mode=='test':
root_dir = os.path.join(folder_path,'TEST')
all_files = sorted(glob.glob(root_dir+'/*.json'))
meta_store = store_loc+'/testing.txt'
fid = open(meta_store,'w')
for filepath in all_files:
fid.write(filepath+'\n')
fid.close()
else:
print('Error in creating meta files')
if __name__ == '__main__':
parser = argparse.ArgumentParser("Configuration for data preparation")
parser.add_argument("--processed_data", default="/media/newhd/TIMIT/processed_data", type=str,help='Dataset path')
parser.add_argument("--meta_store_path", default="meta/", type=str,help='Save directory after processing')
config = parser.parse_args()
create_meta(config.processed_data,config.meta_store_path,mode='train')
create_meta(config.processed_data,config.meta_store_path,mode='test')