Spaces:
Runtime error
Runtime error
#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 | |