python的音频处理

from pydub import AudioSegment
from pydub.playback import play

song = AudioSegment.from_file("s.mp3", format="mp3")

print(len(song))
print('采样率',song.frame_rate) #采样率
print('时长',song.duration_seconds) #时长  
print('采样宽度',song.sample_width)# 采样宽度
print('声道数',song.channels) #声道数
#print('比特率',song.bit_rate) #比特率
#print('格式',song.format) #格式
#test_sound = AudioSegment.silent(duration=1000)  # 生成1秒的静音
#print("Pydub导入成功!音频对象已创建:", test_sound)
play(song)  

  

posted @ 2025-08-20 11:14  华腾智算  阅读(18)  评论(0)    收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL