Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
890 views
in Technique[技术] by (71.8m points)

audio - Read MP3 in Python 3

What I want to do is simply

mp3 = read_mp3(mp3_filename)
audio_left = mp3.audio_channels[0]

where audio_left will contain raw PCM audio data.

I was looking at Play a Sound with Python, but most of the suggested modules are not ported to Python 3 yet. If possible I'd like to avoid having to install a fully-fledged game dev library.

I'm a complete Python beginner, so I'd like to start off using Python 3.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could use librosa:

import librosa
y, sr = librosa.load('your_file.mp3')

Further information: https://github.com/librosa/librosa


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...