<jupyter_start><jupyter_text>The purpose of this jupyter notebook is to create labels for our dataset.I have made the labels for 10 categories with their truth values in binary form.<jupyter_code>import pandas as pd
import glob<jupyter_output><empty_output><jupyter_text>Loading the file paths of the RAVDESS dataset. The directory used below contains all the .wav files from the dataset without any segregation on the basis of speech actors.<jupyter_code>files = glob.glob(r"D:\Kaggle\datasets\Audio_Speech_Actors_01-24\RAVDESS/*.wav")
print(len(files))   #get the total number of files in the dataset<jupyter_output>1440<jupyter_text>Initializing label arrays as list of zeros the length of number of files in the dataset.<jupyter_code>male_angry = [0]*len(files)
male_sad = [0]*len(files)
male_fearful = [0]*len(files)
male_calm = [0]*len(files)
male_happy = [0]*len(files)

female_angry = [0]*len(files)
female_sad = [0]*len(files)
female_fearful = [0]*len(files)
female_calm = [0]*len(files)
female_happy = [0]*len(files)

fname = []<jupyter_output><empty_output><jupyter_text>Assigning the truth value 1 to the respective array element for each .wav file according to the information provided by the RAVDESS dataset creators. I have separated the information in the names of the .wav files to get 'tags' for each file, and have used these tags to determine the labels for them.* The filename consists of a 7-part numerical identifier (e.g., 03-01-06-01-02-01-12.wav)* Emotion (01 = neutral, 02 = calm, 03 = happy, 04 = sad, 05 = angry, 06 = fearful, 07 = disgust, 08 = surprised).  [3rd tag]* Actor (01 to 24. Odd numbered actors are male, even numbered actors are female). [7th tag]<jupyter_code>for i,file in enumerate(files):
    tags = file.replace("D:\\Kaggle\\datasets\\Audio_Speech_Actors_01-24\\RAVDESS\\","").replace(".wav","").split("-")
    fname.append(file.replace("D:\\Kaggle\\datasets\\Audio_Speech_Actors_01-24\\RAVDESS\\",""))
    if(int(tags[2]) == 2 and int(tags[6])%2 == 0):
        female_calm[i] = 1
    elif(int(tags[2]) == 3 and int(tags[6])%2 == 0):
        female_happy[i] = 1
    elif(int(tags[2]) == 4 and int(tags[6])%2 == 0):
        female_sad[i] = 1
    elif(int(tags[2]) == 5 and int(tags[6])%2 == 0):
        female_angry[i] = 1
    elif(int(tags[2]) == 6 and int(tags[6])%2 == 0):
        female_fearful[i] = 1
        
        
    elif(int(tags[2]) == 2 and int(tags[6])%2 != 0):
        male_calm[i] = 1
    elif(int(tags[2]) == 3 and int(tags[6])%2 != 0):
        male_happy[i] = 1
    elif(int(tags[2]) == 4 and int(tags[6])%2 != 0):
        male_sad[i] = 1
    elif(int(tags[2]) == 5 and int(tags[6])%2 != 0):
        male_angry[i] = 1
    elif(int(tags[2]) == 6 and int(tags[6])%2 != 0):
        male_fearful[i] = 1<jupyter_output><empty_output><jupyter_text>Creating a dataframe with file names and their labels. However since I have not used all the possible categories in my labeling process, there are files having no boolean true value for any of the categories used. This is not good for the model, as it results in model learning incorrect features due to ambiguity of having all labels as zeros for a file.<jupyter_code>df = pd.DataFrame({"fname":fname,"male_angry":male_angry,"male_happy":male_happy,"male_calm":male_calm,"male_fearful":male_fearful,"male_sad":male_sad,"female_angry":female_angry,"female_happy":female_happy,"female_calm":female_calm,"female_fearful":female_fearful,"female_sad":female_sad})
df.head()<jupyter_output><empty_output><jupyter_text>To resolve the ambiguity of having all labels as zeros for a file, I removed all such files.<jupyter_code>cd = pd.DataFrame() 
for i in range(len(df)):
    if(len(set(df.iloc[i,1:])) == 2):
        cd = pd.concat((cd,df.loc[i:i]))
print(len(cd))
cd = cd.reset_index(drop = True)<jupyter_output>960<jupyter_text>Final dataframe.<jupyter_code>cd<jupyter_output><empty_output><jupyter_text>Exporting the dataframe as csv file.<jupyter_code>cd.to_csv(r"D:\Kaggle\datasets\Audio_Speech_Actors_01-24\RAVDESS\dataset.csv",index = False,header = True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14048375274859518, 'fraction_numerical': 0.03298314194967017, 'mean_word_length': 4.95924308588064, 'pattern_counts': {'":': 11, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '527613', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1451, 'n_words': 383, 'path': 'creating_labels.ipynb', 'repo_name': 'Azithral/Speech-Emotion-Recognition', 'size': '4093'}