coveralls: 
[![Coverage Status](https://coveralls.io/builds/18160988/badge)](https://coveralls.io/builds/18160988)

Coverage increased (+0.005%) to 98.759% when pulling **b74ac52f02d9cbf04a5e7c1c297039d823060ec7 on lostanlen:patch-1** into **f5671ebe3e5d83277833a0a768a422e9e14a4b0d on rabitt:master**.

lostanlen: Had an offline conversation with `rabitt` and she asked me to convert the `bitrate` field into an Python integer, expressed in bits per second. I'm going to write a simple-minded string parser in `file_info.bitrate` to strip the `k` suffix
rabitt: @lostanlen thanks for catching this, and for the PR! Before I merge, could you please squash your commits down to one?
lostanlen: Tests are passing, this is ready for CR.
This PR have important breaking changes, so it would be best to schedule if for `v1.4`
lostanlen: I implemented the fix to issue #78
Tests are passing. Coverage decreases a little bit because:
1. I don't know how to produce a "zero bit depth" audio file
2. I don't know how to produce an audio file with less than 1kbps bit rate

Some help for 1 and/or 2 would be greatly appreciated.

@rabitt This is ready for a new round of CR 
rabitt: > Tests are passing. Coverage decreases a little bit because:
> 
> 1. I don't know how to produce a "zero bit depth" audio file
>2.  I don't know how to produce an audio file with less than 1kbps bit rate
>
> Some help for 1 and/or 2 would be greatly appreciated.

Just spent some time trying to create "valid" (files SoX knows how to read) files with these stats, and so far I haven't found a way to do it either. The obvious degenerate cases (e.g. a truly empty file with an audio file extension) can't be read in the first place and creates a higher level SoX error. And an 0-length audio file with a header readable by SoX has bit depth information that is nonzero. 

If anyone else has ideas how to hit these cases, help would be welcome! Otherwise, I'd say we ignore these new uncovered lines and merge despite the decreased coverage.
lostanlen: Rebased. Commits squashed into two (one for issue #68, one for issue #78). I might have goofed up with the source tree; do tell me in case I did
rabitt: @lostanlen I don't see the rebased commits - just the original set. Did you `--force` push?
diff --git a/README.md b/README.md
index 3325a5b..7fe349d 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Python wrapper around sox. [Read the Docs here](http://pysox.readthedocs.org).
 
 [![PyPI version](https://badge.fury.io/py/sox.svg)](https://badge.fury.io/py/sox)
 [![Documentation Status](https://readthedocs.org/projects/resampy/badge/?version=latest)](http://pysox.readthedocs.io/en/latest/?badge=latest)
-[![GitHub license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://raw.githubusercontent.com/rabitt/pysox/master/LICENSE.md)
+[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/rabitt/pysox/master/LICENSE.md)
 [![PyPI](https://img.shields.io/pypi/pyversions/Django.svg?maxAge=2592000)]()
 
 [![Build Status](https://travis-ci.org/rabitt/pysox.svg?branch=master)](https://travis-ci.org/rabitt/pysox)
@@ -67,7 +67,7 @@ nosetests .
 
 ```python
 import sox
-# create transformer
+# create trasnformer
 tfm = sox.Transformer()
 # trim the audio between 5 and 10.5 seconds.
 tfm.trim(5, 10.5)
diff --git a/setup.py b/setup.py
index f6ed177..8fc4c8b 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@ if __name__ == "__main__":
         package_data={'sox': []},
         long_description="""Python wrapper around SoX.""",
         keywords='audio effects SoX',
-        license='BSD-3-Clause',
+        license='MIT',
         install_requires=[
         ],
         extras_require={
diff --git a/sox/core.py b/sox/core.py
index 118cd4a..178fbb9 100644
--- a/sox/core.py
+++ b/sox/core.py
@@ -6,7 +6,7 @@ from subprocess import CalledProcessError
 
 from . import NO_SOX
 
-SOXI_ARGS = ['b', 'c', 'a', 'D', 'e', 't', 's', 'r']
+SOXI_ARGS = ['B', 'b', 'c', 'a', 'D', 'e', 't', 's', 'r']
 
 ENCODING_VALS = [
     'signed-integer', 'unsigned-integer', 'floating-point', 'a-law', 'u-law',
diff --git a/sox/file_info.py b/sox/file_info.py
index 9077f1a..d4a373d 100644
--- a/sox/file_info.py
+++ b/sox/file_info.py
@@ -10,9 +10,9 @@ from .core import sox
 from .core import enquote_filepath
 
 
-def bitrate(input_filepath):
+def bitdepth(input_filepath):
     '''
-    Number of bits per sample (0 if not applicable).
+    Number of bits per sample, or None if not applicable.
 
     Parameters
     ----------
@@ -21,17 +21,50 @@ def bitrate(input_filepath):
 
     Returns
     -------
-    bitrate : int
-        number of bits per sample
-        returns 0 if not applicable
+    bitdepth : int or None
+        Number of bits per sample.
+        Returns None if not applicable.
     '''
+    
     validate_input_file(input_filepath)
     output = soxi(input_filepath, 'b')
     if output == '0':
-        logger.warning("Bitrate unavailable for %s", input_filepath)
+        logger.warning("Bit depth unavailable for %s", input_filepath)
+        return None
     return int(output)
 
 
+def bitrate(input_filepath):
+    '''
+    Bit rate averaged over the whole file.
+    Expressed in bytes per second (bps), or None if not applicable.
+
+    Parameters
+    ----------
+    input_filepath : str
+        Path to audio file.
+
+    Returns
+    -------
+    bitrate : float or None
+        Bit rate, expressed in bytes per second.
+        Returns None if not applicable.
+    '''
+    
+    validate_input_file(input_filepath)
+    output = soxi(input_filepath, 'B')
+    # The characters below stand for kilo, Mega, Giga, etc.
+    greek_prefixes = '\0kMGTPEZY'
+    if output == "0":
+        logger.warning("Bit rate unavailable for %s", input_filepath)
+        return None
+    elif output[-1] in greek_prefixes:
+        multiplier = 1000.0**(greek_prefixes.index(output[-1]))
+        return float(output[:-1])*multiplier
+    else:
+        return float(output[:-1])
+
+
 def channels(input_filepath):
     '''
     Show number of channels.
@@ -73,7 +106,7 @@ def comments(input_filepath):
 
 def duration(input_filepath):
     '''
-    Show duration in seconds (0 if unavailable).
+    Show duration in seconds, or None if not available.
 
     Parameters
     ----------
@@ -82,15 +115,15 @@ def duration(input_filepath):
 
     Returns
     -------
-    duration : float
+    duration : float or None
         Duration of audio file in seconds.
-        If unavailable or empty, returns 0.
+        If unavailable or empty, returns None.
     '''
     validate_input_file(input_filepath)
     output = soxi(input_filepath, 'D')
-    if output == '0':
+    if float(output) == 0.0:
         logger.warning("Duration unavailable for %s", input_filepath)
-
+        return None
     return float(output)
 
 
@@ -134,7 +167,7 @@ def file_type(input_filepath):
 
 def num_samples(input_filepath):
     '''
-    Show number of samples (0 if unavailable).
+    Show number of samples, or None if unavailable.
 
     Parameters
     ----------
@@ -143,14 +176,15 @@ def num_samples(input_filepath):
 
     Returns
     -------
-    n_samples : int
+    n_samples : int or None
         total number of samples in audio file.
-        Returns 0 if empty or unavailable
+        Returns None if empty or unavailable.
     '''
     validate_input_file(input_filepath)
     output = soxi(input_filepath, 's')
     if output == '0':
         logger.warning("Number of samples unavailable for %s", input_filepath)
+        return None
     return int(output)
 
 
@@ -313,6 +347,7 @@ def info(filepath):
         Dictionary of file information. Fields are:
             * channels
             * sample_rate
+            * bitdepth
             * bitrate
             * duration
             * num_samples
@@ -322,6 +357,7 @@ def info(filepath):
     info_dictionary = {
         'channels': channels(filepath),
         'sample_rate': sample_rate(filepath),
+        'bitdepth': bitdepth(filepath),
         'bitrate': bitrate(filepath),
         'duration': duration(filepath),
         'num_samples': num_samples(filepath),
diff --git a/sox/transform.py b/sox/transform.py
index df4609e..3dd9a1c 100644
--- a/sox/transform.py
+++ b/sox/transform.py
@@ -2682,7 +2682,7 @@ class Transformer(object):
         Returns
         -------
         power_spectrum : list
-            List of frequency (Hz), amplitude pairs.
+            List of frequency (Hz), amplitdue pairs.
 
         See Also
         --------
@@ -2725,7 +2725,7 @@ class Transformer(object):
         Returns
         -------
         stats_dict : dict
-            List of frequency (Hz), amplitude pairs.
+            List of frequency (Hz), amplitdue pairs.
 
         See Also
         --------
diff --git a/sox/version.py b/sox/version.py
index ad0d588..22a6515 100644
--- a/sox/version.py
+++ b/sox/version.py
@@ -3,4 +3,4 @@
 """Version info"""
 
 short_version = '1.3'
-version = '1.3.5'
+version = '1.3.4'

Is `file_info.bitrate` correct?
Hello

This function seems to be returning the bit depth (aka bits per sample) not the bit rate.

`soxi -b` is the bit depth.

`soxi -B` is the bitrate.

Happy to submit a pull request with a fix and a second function for the bit depth.

Cheers.
diff --git a/tests/test_file_info.py b/tests/test_file_info.py
index cca028f..d960434 100644
--- a/tests/test_file_info.py
+++ b/tests/test_file_info.py
@@ -22,19 +22,40 @@ class TestBitrate(unittest.TestCase):
 
     def test_wav(self):
         actual = file_info.bitrate(INPUT_FILE)
-        expected = 16
+        expected = 706000.0
         self.assertEqual(expected, actual)
 
     def test_aiff(self):
         actual = file_info.bitrate(INPUT_FILE2)
-        expected = 32
+        expected = 768000.0
         self.assertEqual(expected, actual)
 
     def test_empty(self):
         actual = file_info.bitrate(EMPTY_FILE)
+        expected = None
+
+class TestBitdepth(unittest.TestCase):
+
+    def test_wav(self):
+        actual = file_info.bitdepth(INPUT_FILE)
+        expected = 16
+        self.assertEqual(expected, actual)
+
+    def test_aiff(self):
+        actual = file_info.bitdepth(INPUT_FILE2)
+        expected = 32
+        self.assertEqual(expected, actual)
+
+    def test_empty(self):
+        actual = file_info.bitdepth(INPUT_FILE)
         expected = 16
         self.assertEqual(expected, actual)
 
+    def test_aiff(self):
+        actual = file_info.bitdepth(INPUT_FILE2)
+        expected = 32
+        self.assertEqual(expected, actual)
+
 
 class TestChannels(unittest.TestCase):
 
@@ -91,7 +112,7 @@ class TestDuration(unittest.TestCase):
 
     def test_empty(self):
         actual = file_info.duration(EMPTY_FILE)
-        expected = 0
+        expected = None
         self.assertEqual(expected, actual)
 
 
@@ -145,7 +166,7 @@ class TestNumSamples(unittest.TestCase):
 
     def test_empty(self):
         actual = file_info.num_samples(EMPTY_FILE)
-        expected = 0
+        expected = None
         self.assertEqual(expected, actual)
 
 
@@ -220,7 +241,8 @@ class TestInfo(unittest.TestCase):
         expected = {
             'channels': 1,
             'sample_rate': 44100.0,
-            'bitrate': 16,
+            'bitdepth': 16,
+            'bitrate': 706000.0,
             'duration': 10.0,
             'num_samples': 441000,
             'encoding': 'Signed Integer PCM',

pip install -e .[tests]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y sox gcc
3.9
docs/requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.16
babel==2.17.0
certifi==2025.1.31
charset-normalizer==3.4.1
coverage==7.8.0
docutils==0.21.2
exceptiongroup==1.2.2
execnet==2.1.1
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
MarkupSafe==3.0.2
numpydoc==1.8.0
packaging==24.2
pep8==1.7.1
pluggy==1.5.0
Pygments==2.19.1
pytest==8.3.5
pytest-cache==1.0
pytest-cov==6.0.0
pytest-pep8==1.0.6
requests==2.32.3
snowballstemmer==2.2.0
-e git+https://github.com/rabitt/pysox.git@0c87e45ab170b6e08e5ebacc9328c6053db95710#egg=sox
Sphinx==7.4.7
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tabulate==0.9.0
tomli==2.2.1
urllib3==2.3.0
zipp==3.21.0

name: pysox
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.16
      - babel==2.17.0
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - coverage==7.8.0
      - docutils==0.21.2
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - jinja2==3.1.6
      - markupsafe==3.0.2
      - numpydoc==1.8.0
      - packaging==24.2
      - pep8==1.7.1
      - pluggy==1.5.0
      - pygments==2.19.1
      - pytest==8.3.5
      - pytest-cache==1.0
      - pytest-cov==6.0.0
      - pytest-pep8==1.0.6
      - requests==2.32.3
      - snowballstemmer==2.2.0
      - sphinx==7.4.7
      - sphinxcontrib-applehelp==2.0.0
      - sphinxcontrib-devhelp==2.0.0
      - sphinxcontrib-htmlhelp==2.1.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==2.0.0
      - sphinxcontrib-serializinghtml==2.0.0
      - tabulate==0.9.0
      - tomli==2.2.1
      - urllib3==2.3.0
      - zipp==3.21.0
prefix: /opt/conda/envs/pysox

tests/test_file_info.py::TestBitrate::test_aiff tests/test_file_info.py::TestBitrate::test_wav tests/test_file_info.py::TestBitdepth::test_aiff tests/test_file_info.py::TestBitdepth::test_empty tests/test_file_info.py::TestBitdepth::test_wav tests/test_file_info.py::TestDuration::test_empty tests/test_file_info.py::TestNumSamples::test_empty tests/test_file_info.py::TestInfo::test_dictionary
tests/test_file_info.py::TestBitrate::test_empty tests/test_file_info.py::TestChannels::test_aiff tests/test_file_info.py::TestChannels::test_empty tests/test_file_info.py::TestChannels::test_wav tests/test_file_info.py::TestComments::test_aiff tests/test_file_info.py::TestComments::test_empty tests/test_file_info.py::TestComments::test_wav tests/test_file_info.py::TestDuration::test_aiff tests/test_file_info.py::TestDuration::test_spacey_wav tests/test_file_info.py::TestDuration::test_wav tests/test_file_info.py::TestEncoding::test_aiff tests/test_file_info.py::TestEncoding::test_empty tests/test_file_info.py::TestEncoding::test_wav tests/test_file_info.py::TestFileType::test_aiff tests/test_file_info.py::TestFileType::test_empty tests/test_file_info.py::TestFileType::test_wav tests/test_file_info.py::TestNumSamples::test_aiff tests/test_file_info.py::TestNumSamples::test_wav tests/test_file_info.py::TestSampleRate::test_aiff tests/test_file_info.py::TestSampleRate::test_empty tests/test_file_info.py::TestSampleRate::test_wav tests/test_file_info.py::TestSilent::test_empty tests/test_file_info.py::TestSilent::test_nonsilent tests/test_file_info.py::TestSilent::test_silent tests/test_file_info.py::TestFileExtension::test_ext1 tests/test_file_info.py::TestFileExtension::test_ext2 tests/test_file_info.py::TestFileExtension::test_ext3 tests/test_file_info.py::TestFileExtension::test_ext4 tests/test_file_info.py::TestFileExtension::test_ext5 tests/test_file_info.py::TestValidateInputFile::test_invalid_format tests/test_file_info.py::TestValidateInputFile::test_nonexistent tests/test_file_info.py::TestValidateInputFile::test_valid tests/test_file_info.py::TestValidateInputFile::test_valid_wspaces tests/test_file_info.py::TestValidateInputFileList::test_empty_list tests/test_file_info.py::TestValidateInputFileList::test_invalid_format tests/test_file_info.py::TestValidateInputFileList::test_len_one_list tests/test_file_info.py::TestValidateInputFileList::test_nonexistent tests/test_file_info.py::TestValidateInputFileList::test_nonlist tests/test_file_info.py::TestValidateInputFileList::test_valid tests/test_file_info.py::TestValidateOutputFile::test_file_exists tests/test_file_info.py::TestValidateOutputFile::test_invalid_format tests/test_file_info.py::TestValidateOutputFile::test_not_writeable tests/test_file_info.py::TestValidateOutputFile::test_valid tests/test_file_info.py::TestStat::test_silent_file tests/test_file_info.py::TestStatCall::test_stat_call tests/test_file_info.py::TestParseStat::test_empty tests/test_file_info.py::TestParseStat::test_real_output tests/test_file_info.py::TestParseStat::test_simple
setup.py sox/transform.py sox/core.py README.md sox/version.py sox/file_info.py
setup.py sox/transform.py sox/core.py README.md sox/version.py sox/file_info.py