In this script, we will work with the audio files. We will extract the following features:
intensity
f0
spectral centroid / spectral center of gravity
formants
Code to load packages and prepare the environment
# packagesimport osimport globimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport scipyfrom scipy.signal import butter, filtfilt, sosfiltimport librosaimport parselmouthimport IPython.display as ipdimport seaborn as snsimport pickleimport randomcurfolder = os.getcwd()datasetfolder = os.path.join(curfolder, '..', '..', "data")# PARSEL dataaudiofolder = os.path.join(datasetfolder, 'Conversations') # last level for participant folderwavtotrack = glob.glob(os.path.join(audiofolder, "*", "Raw_Audio", "*.wav"), recursive =True)# keep only those that have conv-self in name (conv-other are the same so not necessary to duplicate)wavtotrack = [x for x in wavtotrack if'conv-self'in x]print('Number of audio files found: ', len(wavtotrack))# Create folder to save processed acoustic time seriesACfolder_processed = os.path.join(curfolder, "..", "..", 'TS_acoustics')ifnot os.path.exists(ACfolder_processed): os.makedirs(ACfolder_processed)