def main(): parser = argparse.ArgumentParser() parser.add_argument("input", #nargs="1" , help="Score to be played, without extension.", #default=config.defaultGenScore ) parser.add_argument("modelFilename", #nargs="1" , help="Model filename", #default=config.defaultModelFilename ) parser.add_argument("outputDir", nargs="?" , help="Music output directory", default = config.defaultOutputDir ) args = parser.parse_args() genScore = sampleLoader.loadGenScore(args.input) genFeat = featureManager.extractGenFeat(genScore) #wrap genFeat by {} because trainFeats is {score1, score2} featureManager.saveJson([genFeat], config.getGenInFeatFilename(args)) #perfFeats = model.genPerfFeats(config.defaultGenFeatFilename, args.modelFilename) m = model.getModelObj() perfFeats = m.gen(args) #wrap perfFeat by {} because trainFeats is {score1, score2} featureManager.saveJson([perfFeats], config.getGenOutFeatFilename(args)) musicGenerator.genMusic(genScore, args)
def genMusic(genScore, args): samples = featureManager.loadJson(config.getGenOutFeatFilename(args)) sample = samples[0] #only one score, to match the format of trainFeat perfFeats = sample['perfFeats'] outScore = featureManager.applyFeats(genScore, perfFeats) musicOutputFunc = getMusicOutputFunc() musicOutputFunc(outScore, args)