Created
May 5, 2019 04:11
-
-
Save Tmn07/7b6f14dc6cf6f766f03a199052a3a69b to your computer and use it in GitHub Desktop.
midi2wav demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import pretty_midi | |
from os import walk | |
from midi2audio import FluidSynth | |
# 从path指定的文件夹中找出全部mid后缀的文件 | |
def find_postfix_indir(path, postfix): | |
all_data = [] | |
for dirpath, dirnames, filenames in walk(path): | |
for f in filenames: | |
if f.endswith(postfix.lower()) or f.endswith(postfix.upper()): | |
# print(dirpath+"\\"+f) | |
all_data.append(dirpath+"/"+f) | |
return all_data | |
def main(): | |
data = find_postfix_indir("data", "mid") | |
# 单个测试 | |
f = data[0] | |
fs = FluidSynth() | |
fs.midi_to_audio(f, "test.wav") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment