from moviepy.editor import AudioFileClip
def clip_audio(input_file, output_file, start_time, end_time, bit_rate):
"""
剪切音频文件
:param input_file: 输入音频文件路径
:param output_file: 输出音频文件路径
:param start_time: 开始时间
:param end_time: 结束时间
:param bit_rate: 码率
"""
clip = AudioFileClip(input_file).subclip(start_time, end_time)
clip.write_audiofile(output_file, bitrate=bit_rate)
input_file_name = r"D:\剑来.mp3"
output_file_name = r"D:\剑来_320k_001.mp3"
cut_start_time = '00:00:05'
cut_end_time = '00:01:46'
music_bit_rate = '320k'
clip_audio(input_file_name, output_file_name, cut_start_time, cut_end_time, music_bit_rate)