- i have been trying to show a score converted from krn file
import music21 as m
import os
test_data = "D:/Programming/DATA - SCIENCE/deep learning/music generation/data/test"
def load_krn_files(data_path):
# go through the whole files
songs = []
for path , subdirs,files in os.walk(data_path):
for file in files :
if file [-3:] == "krn":
song = m.converter.parse(os.path.join(path,file))
songs.append(song)
return songs
def preproccessing(data_path):
pass
#1 ) load the kern files and pars them
if __name__ == "__main__":
songs = load_krn_files(test_data)
print(f"loaded {len(songs)} songs.")
song = songs[0]
song.show()
- but the method (show) return the following error
loaded 12 songs. Traceback (most recent call last): File "d:/Programming/DATA - SCIENCE/deep learning/music generation/scripts/preprocess.py", line 25, in song.show() File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\site-packages\music21\stream\base.py", line 334, in show return super().show(fmt=fmt, app=app, **keywords) File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\site-packages\music21\base.py", line 2788, in show return formatWriter.show(self, File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\site-packages\music21\converter\subConverters.py", line 1114, in show self.launch(returnedFilePath, fmt=fmt, app=app)
File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\site-packages\music21\converter\subConverters.py", line 197, in launch subprocess.run(cmd, check=False, shell=shell)
File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\site-packages\run_init_.py", line 145, in new process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell) File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\site-packages\run_init_.py", line 121, in create_process shlex.split(command), File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\shlex.py", line 311, in split return list(lex) File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\shlex.py", line 300, in next token = self.get_token() File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\shlex.py", line 109, in get_token raw = self.read_token() File "C:\Users\ae504\AppData\Local\Programs\Python\Python38\lib\shlex.py", line 140, in read_token nextchar = self.instream.read(1) AttributeError: 'tuple' object has no attribute 'read'