I've tried many things to open and convert an audio file into a numpy array but nothing works.
import numpy as np
import pyglet
song = pyglet.media.load('sample-000000.mp3')
np.array(song)
I want an array of numbers, not an array containing a pyglet file.
Out[1]:
array(<pyglet.media.codecs.wmf.WMFSource object at 0x00000222A8118808>,
dtype=object)
Thanks for help.
use pydub
import pydub
import numpy as np
a = pydub.AudioSegment.from_mp3("file.mp3")
arry = np.array(a.get_array_of_samples())
print(arry)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.