可在nano或者gax上面使用(已测试过)

将mp3文件转换为wav文件

trans_mp3_to_wav.py

1
2
3
4
5
6
7
8
from pydub import AudioSegment

# 这里filepath填的是.mp3文件的名字(也可加上路径)
def trans_mp3_to_wav(filepath):
song = AudioSegment.from_mp3(filepath)
song.export("test.wav", format="wav")

trans_mp3_to_wav('test.mp3')

播放

play_wav.py

1
2
3
4
5
from pydub import AudioSegment
from pydub.playback import play

song = AudioSegment.from_wav("test.wav")
play(song)