text_plain_output_1.png
import music21

import os

import pandas as pd

USE_MUSESCORE = True

if USE_MUSESCORE:
    env = music21.environment.Environment()
    env['musescoreDirectPNGPath'] = '../input/data-challenge-igad-2022-data-set/3 - Challenge/musescore.exe'
    env['musicxmlPath'] = '../input/data-challenge-igad-2022-data-set/3 - Challenge/musescore.exe'

train_directory = '../input/data-challenge-igad-2022-data-set/3 - Challenge/train'
test_directory = '../input/data-challenge-igad-2022-data-set/3 - Challenge/X_test'
train_files = os.listdir(train_directory)
test_files = os.listdir(test_directory)

scores_train = [music21.converter.parse(os.path.join(train_directory, train_files[i])) for i in range(len(train_files))]
scores_test = [music21.converter.parse(os.path.join(test_directory, test_files[i])) for i in range(len(test_files))]
train_dict = {'NOM_FICHIER': train_files, 'SCORE': scores_train}
test_dict = {'NOM_FICHIER': test_files, 'SCORE': scores_test}
df_train = pd.DataFrame(train_dict)
df_test = pd.DataFrame(test_dict)

df_test.iloc[0, 5][0:2]

df_test.head()