I tried SER in machine learning from a site called dataflair and for the following code,
#DataFlair - Load the data and extract features for each sound file
def load_data(test_size=0.2):
x,y=[],[]
for file in glob.glob("D:\archive\Actor_01\03-01-01-01-01-01-01.wav"):
file_name=os.path.basename(file)
emotion=emotions[file_name.split("-")[2]]
if emotion not in observed_emotions:
continue
feature=extract_feature(file, mfcc=True, chroma=True, mel=True)
x.append(feature)
y.append(emotion)
return train_test_split(np.array(x), y, test_size=test_size, random_state=9)
#DataFlair - Split the dataset
x_train,x_test,y_train,y_test=load_data(test_size=0.25)
i got this error-
ValueError Traceback (most recent call last)
Input In [10], in <cell line: 2>()
1 #DataFlair - Split the dataset
----> 2 x_train,x_test,y_train,y_test=load_data(test_size=0.25)
Input In [9], in load_data(test_size)
10 x.append(feature)
11 y.append(emotion)
---> 12 return train_test_split(np.array(x), y, test_size=test_size, random_state=9)
File ~\anaconda3\lib\site-packages\sklearn\model_selection\_split.py:2420, in train_test_split(test_size, train_size, random_state, shuffle, stratify, *arrays)
2417 arrays = indexable(*arrays)
2419 n_samples = _num_samples(arrays[0])
-> 2420 n_train, n_test = _validate_shuffle_split(
2421 n_samples, test_size, train_size, default_test_size=0.25
2422 )
2424 if shuffle is False:
2425 if stratify is not None:
File ~\anaconda3\lib\site-packages\sklearn\model_selection\_split.py:2098, in _validate_shuffle_split(n_samples, test_size, train_size, default_test_size)
2095 n_train, n_test = int(n_train), int(n_test)
2097 if n_train == 0:
-> 2098 raise ValueError(
2099 "With n_samples={}, test_size={} and train_size={}, the "
2100 "resulting train set will be empty. Adjust any of the "
2101 "aforementioned parameters.".format(n_samples, test_size, train_size)
2102 )
2104 return n_train, n_test
ValueError: With n_samples=0, test_size=0.25 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.
what are these errors and how do i overcome them? it works just fine on the website, https://data-flair.training/blogs/python-mini-project-speech-emotion-recognition/