1

I'm working with pydub to check bit_depth and framerate from audio files (wav and flacc). How I can verify if its floating point?

https://en.wikipedia.org/wiki/Audio_bit_depth#Floating_point

I've tried to check the type of sample_rate from pydub, but its always int

Ramon Medeiros
  • 2,272
  • 2
  • 24
  • 41

1 Answers1

0

Sample rate is on the X-axis of an audio file. It is always int and the value changes from 11025 to 22050 or 44100 Hz.

You are looking for the bit depth of the audio file. Older music had 8 bit. CDs have 16 bit. Floating point would be 32 bit. At first sight, it would be impossible to tell the difference between a 32 bit integer and a 32 bit float.

However, this information is given in the fmt part, at least of a RIFF WAV file. The German Wikipedia has a list of file formats (here). 0x0003 IEEE FLOAT should be what you are looking for.

In pydub, this gives you the format info:

from pydub.utils import mediainfo_json

info = mediainfo_json('example.wav')
audio_streams = [x for x in info['streams'] if x['codec_type'] == 'audio']
print(audio_streams[0].get('sample_fmt'))

With an example file that has 32 bit floats, I get flt as output. Your mileage may vary.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222