库
https://github.com/vivjay30/pychorus
pip install pychorus
import os from pychorus import find_and_output_chorus def extract_chorus(input_directory, output_directory): # 确保输出目录存在 if not os.path.exists(output_directory): os.makedirs(output_directory) # 遍历输入目录中的所有音乐文件 for file_name in os.listdir(input_directory): if file_name.endswith('.mp3'): input_file_path = os.path.join(input_directory, file_name) output_file_path = os.path.join(output_directory, f"chorus_{file_name}") # 使用pychorus提取高潮部分并保存到新文件 find_and_output_chorus(input_file_path, output_file_path,40) if __name__ == "__main__": input_directory = r"D:\music\2023zuixindanqu320" output_directory = r"D:\music\2023zuixindanqu320\out" extract_chorus(input_directory, output_directory)