pydub 把音频按时间段切成小段

from pydub import AudioSegment
from pydub.utils import make_chunks

audio = AudioSegment.from_file("./nnqdzj01.mp3", "mp3")

size = 30000  #切割的毫秒数 10s=10000

chunks = make_chunks(audio, size)  #将文件切割为30s一块

for i, chunk in enumerate(chunks):
    chunk_name = "./nnqdz01-wav30/nnqdzj00-{0}.wav".format(i)
    print(chunk_name)
    chunk.export(chunk_name, format="wav")

参考
python--把音频按时间段切成小段(重叠和不重叠)

上一篇:千锋重庆Java培训学习Java内存监控工具的介绍


下一篇:Java框架-MyBatis三剑客之MyBatis Generator(mybatis-generator MBG插件)详解(下)