-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathread_wav_files_in_session.py
More file actions
60 lines (48 loc) · 1.35 KB
/
read_wav_files_in_session.py
File metadata and controls
60 lines (48 loc) · 1.35 KB
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
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 05 22:19:38 2017
@author: pwolfe8
Reads wav files in a sorted session folder (1,2,3,4, or 5) and adds it to
a big dictionary holding each emotion:
'Anger',
'Disgust',
'Excited',
'Fear',
'Frustration',
'Happiness',
'Neutral',
'Other',
'Sadness',
'Surprise'
and within that entry for the emotion is another dictionary
holding each file 0...numFiles
"""
import os
from scipy.io import wavfile
bigData = {} # currently file name is bigData. choose different name if needed
datasetPath = 'C:\EmotionDataset'
sessionNumber = 2 #choose a session number to grab
sessionName = datasetPath + 'Session' + str(sessionNumber) + '_sorted/'
emotions = os.listdir(sessionName)
# maxlen = 0
# sessionNumbers = [1,2,3,4,5]
for emotion in emotions:
wavFiles = os.listdir(sessionName + emotion)
emotionData = {}
i = 0
for wavFile in wavFiles:
fs, data = wavfile.read(sessionName + emotion + '/' + wavFile)
# print fs, len(data)
if(len(data) > maxlen):
maxlen = len(data)
emotionData[i]= data
i += 1
bigData[emotion] = emotionData
# so now you can grab the emotions like this:
# bigData.keys()
#
# and grab list of the files inside like this:
# bigData['Anger'].keys()
#
# have fun because all the sentences are different length...
# print maxlen