Spaces:
Runtime error
Runtime error
File size: 848 Bytes
1d4f575 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#Conversion script for midi to abc files.
import os
import subprocess
def abs_paths(dir):
for dir_path,_,filenames in os.walk(dir):
for f in filenames:
yield os.path.abspath(os.path.join(dir_path, f))
for file in abs_paths("data"):
# print(file)
# os.makedirs("n-grams/data/converted/")
filename=file.split("/")[-1]
# print(filename)
newfile = filename.split(".")[0]
newfile = 'converted/'+newfile+'.abc'
# os.system('midi2abc -f filename')
print(file)
print(newfile)
f = open(newfile,'w',encoding="utf8")
temp = subprocess.Popen(['midi2abc', '-f', file,">>",newfile],stdout = f)#subprocess.PIPE)
# get the output as a stringi
output = str(temp.communicate())
# f = open(newfile,"w",encoding="utf8")
# f.write(output)
# store the output in the list
|