Код: Выделить всё
def get_files_and_labels(directory):
files = []
labels = []
for root, dirs, files_in_root in os.walk(directory):
# name of the subfolder = class-name
class_name = os.path.basename(root)
for file in files_in_root:
if file.endswith(".wav"):
file_path = os.path.join(root, file)
files.append(file_path)
labels.append(class_name)
if len(files) != len(labels):
com.logger.error("label-array length is not equal to files-array length")
return np.array(files), np.array(labels)
Подробнее здесь: https://stackoverflow.com/questions/790 ... -structure