def load_specs(piece_paths, audio_file): """ Compute spectrograms given piece paths """ spectrograms = [] for piece_path in piece_paths: audio_path = get_performance_audio_path(piece_path, audio_file) spec = processor.process(audio_path).T spectrograms.append(spec) return spectrograms
print(col.print_colored("\nRunning full evaluation:", col.UNDERLINE)) ranks = [] for i, tp in enumerate(te_pieces): # compute spectrogram from file if args.real_perf: audio_file = get_performance_audio_path(piece_paths[i], "01_performance") else: audio_file = os.path.join(piece_paths[i], "score_ppq.flac") if not os.path.exists(audio_file): continue # compute spectrogram spec = processor.process(audio_file).T # detect piece from spectrogram ret_result, ret_votes = a2s_srv.detect_score(spec, top_k=len(te_pieces), n_candidates=args.n_candidates, verbose=False) if tp in ret_result: rank = ret_result.index(tp) + 1 ratio = ret_votes[ret_result.index(tp)] else: rank = len(ret_result) ratio = 0.0 ranks.append(rank) if ranks[-1] == 1: color = col.OKGREEN elif ranks[-1] <= 5: color = col.OKBLUE