Unverified Commit 080cd303 authored by Tejasvi S Tomar's avatar Tejasvi S Tomar Committed by GitHub
Browse files

Fix incorrect extension parsing in sox_io_backend.save(#885)

* Fix incorrect extension parsing in sox_io_backend.save
* Add tests for compression=None
parent 2205cc9e
...@@ -235,7 +235,7 @@ class TestSave(SaveTestBase): ...@@ -235,7 +235,7 @@ class TestSave(SaveTestBase):
@parameterized.expand(list(itertools.product( @parameterized.expand(list(itertools.product(
[8000, 16000], [8000, 16000],
[1, 2], [1, 2],
[-4.2, -0.2, 0, 0.2, 96, 128, 160, 192, 224, 256, 320], [None, -4.2, -0.2, 0, 0.2, 96, 128, 160, 192, 224, 256, 320],
)), name_func=name_func) )), name_func=name_func)
def test_mp3(self, sample_rate, num_channels, bit_rate): def test_mp3(self, sample_rate, num_channels, bit_rate):
"""`sox_io_backend.save` can save mp3 format.""" """`sox_io_backend.save` can save mp3 format."""
...@@ -254,7 +254,7 @@ class TestSave(SaveTestBase): ...@@ -254,7 +254,7 @@ class TestSave(SaveTestBase):
@parameterized.expand(list(itertools.product( @parameterized.expand(list(itertools.product(
[8000, 16000], [8000, 16000],
[1, 2], [1, 2],
list(range(9)), [None] + list(range(9)),
)), name_func=name_func) )), name_func=name_func)
def test_flac(self, sample_rate, num_channels, compression_level): def test_flac(self, sample_rate, num_channels, compression_level):
"""`sox_io_backend.save` can save flac format.""" """`sox_io_backend.save` can save flac format."""
...@@ -273,7 +273,7 @@ class TestSave(SaveTestBase): ...@@ -273,7 +273,7 @@ class TestSave(SaveTestBase):
@parameterized.expand(list(itertools.product( @parameterized.expand(list(itertools.product(
[8000, 16000], [8000, 16000],
[1, 2], [1, 2],
[-1, 0, 1, 2, 3, 3.6, 5, 10], [None, -1, 0, 1, 2, 3, 3.6, 5, 10],
)), name_func=name_func) )), name_func=name_func)
def test_vorbis(self, sample_rate, num_channels, quality_level): def test_vorbis(self, sample_rate, num_channels, quality_level):
"""`sox_io_backend.save` can save vorbis format.""" """`sox_io_backend.save` can save vorbis format."""
......
...@@ -159,7 +159,7 @@ def save( ...@@ -159,7 +159,7 @@ def save(
See the detail at http://sox.sourceforge.net/soxformat.html. See the detail at http://sox.sourceforge.net/soxformat.html.
""" """
if compression is None: if compression is None:
ext = str(filepath)[-3:].lower() ext = str(filepath).split('.')[-1].lower()
if ext in ['wav', 'sph']: if ext in ['wav', 'sph']:
compression = 0. compression = 0.
elif ext == 'mp3': elif ext == 'mp3':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment