Read MP3 in Python3

0 votes
I am a beginner in Python and so I am using Python 3 for the following :

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. Is there any way?
Mar 4, 2019 in Python by ana1504.k
• 7,910 points
3,689 views

1 answer to this question.

0 votes
It is easier to convert the file from mp3 to wav with some tools such as :

$ ffmpeg -i foo.mp3 -vn -acodec pcm_s16le -ac 1 -ar 44100 -f wav foo.wav
or
$ mpg123 -w foo.wav foo.mp3
 

Then read the WAV with one of the python WAV libraries. I'd recommend PySoundFile because it works with most generated WAV correctly and installed without issue. Hope this helps.
answered Mar 4, 2019 by SDeb
• 13,300 points

Related Questions In Python

+3 votes
5 answers

How to read multiple data files in python

Firstly we will import pandas to read ...READ MORE

answered Apr 6, 2018 in Python by DeepCoder786
• 1,720 points
15,333 views
0 votes
2 answers

Unable to use print statement in python3

print will work when you use print("Your ...READ MORE

answered Feb 14, 2019 in Python by Shashank
• 1,370 points
1,299 views
0 votes
1 answer

Raw_input method is not working in python3. How to use it?

raw_input is not supported anymore in python3. ...READ MORE

answered May 5, 2018 in Python by aayushi
• 750 points
3,380 views
0 votes
3 answers

how to use print statement in python3?

Brackets are required to print the output. >>> ...READ MORE

answered Nov 25, 2021 in Python by anonymous
1,653 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,466 views
0 votes
1 answer
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 13,300 points
1,822 views
0 votes
1 answer

Read & write data in mifare card

Hi, you can check out the following ...READ MORE

answered Nov 29, 2018 in Python by SDeb
• 13,300 points
2,119 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP