-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdatastore_savee.py
executable file
·43 lines (30 loc) · 1.46 KB
/
datastore_savee.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
import numpy as np
from datastore import Datastore
from feature_type import FeatureType
from framework import get_dataset, randomize_split
class SaveeDatastore(Datastore):
data_pkl = None
data = []
pre_train_data = []
def __init__(self, feature_type: FeatureType):
if not (FeatureType.MFCC == feature_type):
raise Exception("Only supports {}".format(FeatureType.MFCC.name))
self.data_pkl = get_dataset("savee_sr_22k_2sec_4-classes.pkl")
_data, pre_train_data = randomize_split(self.data_pkl, split_ratio=0.7)
rl_data, eval_data = randomize_split(_data, split_ratio=0.8)
self.data = rl_data
self.pre_train_data = pre_train_data
self.eval_data = eval_data
def get_data(self):
np.random.shuffle(self.data)
x_train_mfcc = np.array([d[FeatureType.MFCC.name] for d in self.data])
y_train_emo = np.array([d['y_emo'] for d in self.data])
return (x_train_mfcc, y_train_emo, None), (None, None, None)
def get_pre_train_data(self):
x_train_mfcc = np.array([d[FeatureType.MFCC.name] for d in self.pre_train_data])
y_train_emo = np.array([d['y_emo'] for d in self.pre_train_data])
return x_train_mfcc, y_train_emo, None
def get_eval_data(self):
x_train_mfcc = np.array([d[FeatureType.MFCC.name] for d in self.eval_data])
y_train_emo = np.array([d['y_emo'] for d in self.eval_data])
return x_train_mfcc, y_train_emo, None