python - pydub accessing the sampling rate(Hz) and the audio signal from an mp3 file -
just found out interesting python package pydub converts audio file mp3, wav, etc.
as far have read documentation, process follows:
- read mp3 audio file using from_mp3()
- creates wav file using export().
just curious if there way access sampling rate , audio signal(of 1-dimensional array, supposing mono) directly mp3 file without converting wav file. working on thousands of audio files , might expensive convert of them wav file.
if aren't interested in actual audio content of file, may able use pydub.utils.mediainfo()
:
>>> pydub.utils import mediainfo >>> info = mediainfo("/path/to/file.mp3") >>> print info['sample_rate'] 44100 >>> print info['channels'] 1
this uses avlib's avprobe
utility, , returns kinds of info. suggest giving try :)
should much faster opening each mp3 using audiosegment.from_mp3(…)
Comments
Post a Comment