This is a tutorial on how to

Configure a python environment

python3
exit()
mkdir emodb; cd emodb
python3 -m venv ./venv
source ./venv/bin/activate
(venv)>
deactivate
pip install pandas numpy jupyter audformat opensmile sklearn matplotlib
jupyter notebook &

Get and unpack the Berlin EmoDB emotional database

!wget -c https://tubcloud.tu-berlin.de/s/23rPJe5rPAjmrxX/download
!mv download emodb_audformat.zip
!unzip emodb_audformat.zip
!rm emodb_audformat.zip
import audformat
db = audformat.Database.load('./emodb')
db
!pwd
import os
root = '/...my current directory.../emodb/'
db.map_files(lambda x: os.path.join(root, x))
import IPython
IPython.display.Audio(db.tables['emotion'].df.index[0])

Extract acoustic features

df = db.tables['emotion'].df
df.emotion.value_counts().plot(kind='pie')
import opensmile
smile = opensmile.Smile(
feature_set=opensmile.FeatureSet.GeMAPSv01b,
feature_level=opensmile.FeatureLevel.Functionals,
)
feats_df = smile.process_files(df.index)
feats_df.shape
feats_df.head(n=1)

Perform a statistical classification on the data

test_labels = df.iloc[:100,].emotion
train_labels = df.iloc[100:,].emotion
test_feats = feats_df.iloc[:100,]
train_feats = feats_df.iloc[100:,]
from sklearn import svm
clf = svm.SVC()
clf.fit(train_feats, train_labels)
pred_labels  = clf.predict(test_feats)
from sklearn.metrics import confusion_matrix
confusion_matrix(test_labels.emotion, pred_labels)
from sklearn.metrics import recall_score
recall_score(test_labels, pred_labels, average='macro')
clf = svm.SVC(kernel='linear', C=.001)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store