-
Notifications
You must be signed in to change notification settings - Fork 2
/
visualizing_audio_files.py
53 lines (49 loc) · 1.37 KB
/
visualizing_audio_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
50
51
import cPickle as pickle
import pprint
import random
import os
import numpy as np
import ipdb
with open('covarep.pkl', 'rb') as f:
data = pickle.load(f)
# ipdb.set_trace()
pp = pprint.PrettyPrinter(indent=4)
# pp.pprint(data[0])
# pp.pprint(len(data))
with open('train.pkl', 'rb') as f:
train_data = pickle.load(f)
with open('valid.pkl', 'rb') as f:
valid_data = pickle.load(f)
with open('test.pkl', 'rb') as f:
test_data = pickle.load(f)
os.system("mkdir -p audio_files")
os.system("mkdir -p audio_files/train")
os.system("mkdir -p audio_files/val")
os.system("mkdir -p audio_files/test")
# pp.pprint(data)
for key,value in data.items():
pp.pprint(key)
for key2,value2 in value.items():
if key2 in train_data:
folder_location = "./audio_files/train/"
elif key2 in valid_data:
folder_location = "./audio_files/val/"
else:
folder_location = "./audio_files/test/"
video_name = key2
pp.pprint(key2)
for key3,value3 in value2.items():
segment_id = key3
pickle_file = folder_location + video_name + '_' + segment_id + '.pkl'
print(pickle_file)
pp.pprint(value3)
# for idx,frame in enumerate(value3):
# if idx == 0:
# covarep_features = frame[2]
# else:
# covarep_features = np.vstack((covarep_features,frame[2]))
# # pp.pprint(facet_features)
# pickle.dump(covarep_features, open(pickle_file,"wb"))
# break
# break
# break