截取铃声python代码
2020-12-13 14:17
标签:art ios color top app exp pytho python form 截取铃声python代码 标签:art ios color top app exp pytho python form 原文地址:https://www.cnblogs.com/ghl666/p/11557955.htmlfrom pydub import AudioSegment
file_name = "张杰 - 这就是爱.mp3"
sound = AudioSegment.from_mp3(file_name)
start_time = "1:22" #截取开始位置
stop_time = "1:57" #截取的末尾位置
start_time = (int(start_time.split(‘:‘)[0])*60+int(start_time.split(‘:‘)[1]))*1000
stop_time = (int(stop_time.split(‘:‘)[0])*60+int(stop_time.split(‘:‘)[1]))*1000
word = sound[start_time:stop_time]
save_name = file_name[:]+‘-截取部分‘
word.export(save_name, format="mp3",tags={‘artist‘: ‘AppLeU0‘, ‘album‘: save_name[:-4]})