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:

  1. read mp3 audio file using from_mp3()
  2. 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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -