-
Notifications
You must be signed in to change notification settings - Fork 738
Add bits_per_sample to info #1177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9bc0ca4
Added bits_per_sample field to sox_io backend
NicolasHug cd28304
Added tests for sox_io backend
NicolasHug c29834c
Added bits_per_sample support and tests to SoundFile backend
NicolasHug f99885b
fixed FLAC test
NicolasHug 1f5781d
Fixed OGG test
NicolasHug e3f1f09
Merge branch 'master' of github.com:pytorch/audio into bits_per_sample
NicolasHug c80cfd4
Addressed comments: Added links to bit depths + handled unknown subtype
NicolasHug 49d2c7c
Document bits_per_sample=0
NicolasHug c64ea12
fix amr-nb test
NicolasHug 01c26f9
Addressed comments
NicolasHug 17e1cc9
Merge branch 'master' of github.com:pytorch/audio into bits_per_sample
NicolasHug c91d0a3
Use f-strings instead of .format()
NicolasHug 56a7536
Merge branch 'master' of github.com:pytorch/audio into bits_per_sample
NicolasHug 04480b5
Addressed comments
NicolasHug 04b1378
remove unused import
NicolasHug 1d30db6
remove usage of pytest
NicolasHug 2f955e8
Merge branch 'master' of github.com:pytorch/audio into bits_per_sample
NicolasHug 41d2020
Addressed comments
NicolasHug ffee30a
use proper param name
NicolasHug 532397f
expected bps is 0 for amr_nb?
NicolasHug dff1e04
Merge branch 'master' of github.com:pytorch/audio into bits_per_sample
NicolasHug 9f86979
Merge branch 'master' of github.com:pytorch/audio into bits_per_sample
NicolasHug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ def test_wav(self, dtype, sample_rate, num_channels): | |
| assert info.sample_rate == sample_rate | ||
| assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == sox_utils.get_bit_depth(dtype) | ||
|
|
||
| @parameterized.expand(list(itertools.product( | ||
| ['float32', 'int32', 'int16', 'uint8'], | ||
|
|
@@ -52,6 +53,7 @@ def test_wav_multiple_channels(self, dtype, sample_rate, num_channels): | |
| assert info.sample_rate == sample_rate | ||
| assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == sox_utils.get_bit_depth(dtype) | ||
|
|
||
| @parameterized.expand(list(itertools.product( | ||
| [8000, 16000], | ||
|
|
@@ -71,6 +73,7 @@ def test_mp3(self, sample_rate, num_channels, bit_rate): | |
| # mp3 does not preserve the number of samples | ||
| # assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == 0 # bit_per_sample is irrelevant for compressed formats | ||
|
|
||
| @parameterized.expand(list(itertools.product( | ||
| [8000, 16000], | ||
|
|
@@ -89,6 +92,7 @@ def test_flac(self, sample_rate, num_channels, compression_level): | |
| assert info.sample_rate == sample_rate | ||
| assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == 24 # FLAC standard | ||
|
|
||
| @parameterized.expand(list(itertools.product( | ||
| [8000, 16000], | ||
|
|
@@ -107,20 +111,23 @@ def test_vorbis(self, sample_rate, num_channels, quality_level): | |
| assert info.sample_rate == sample_rate | ||
| assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == 0 # bit_per_sample is irrelevant for compressed formats | ||
|
|
||
| @parameterized.expand(list(itertools.product( | ||
| [8000, 16000], | ||
| [1, 2], | ||
| [16, 32], | ||
| )), name_func=name_func) | ||
| def test_sphere(self, sample_rate, num_channels): | ||
| def test_sphere(self, sample_rate, num_channels, bits_per_sample): | ||
| """`sox_io_backend.info` can check sph file correctly""" | ||
| duration = 1 | ||
| path = self.get_temp_path('data.sph') | ||
| sox_utils.gen_audio_file(path, sample_rate, num_channels, duration=duration) | ||
| sox_utils.gen_audio_file(path, sample_rate, num_channels, duration=duration, bit_depth=bits_per_sample) | ||
| info = sox_io_backend.info(path) | ||
| assert info.sample_rate == sample_rate | ||
| assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == bits_per_sample | ||
|
|
||
| @parameterized.expand(list(itertools.product( | ||
| ['float32', 'int32', 'int16', 'uint8'], | ||
|
|
@@ -131,13 +138,15 @@ def test_amb(self, dtype, sample_rate, num_channels): | |
| """`sox_io_backend.info` can check amb file correctly""" | ||
| duration = 1 | ||
| path = self.get_temp_path('data.amb') | ||
| bits_per_sample = sox_utils.get_bit_depth(dtype) | ||
| sox_utils.gen_audio_file( | ||
| path, sample_rate, num_channels, | ||
| bit_depth=sox_utils.get_bit_depth(dtype), duration=duration) | ||
| bit_depth=bits_per_sample, duration=duration) | ||
| info = sox_io_backend.info(path) | ||
| assert info.sample_rate == sample_rate | ||
| assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == bits_per_sample | ||
|
|
||
| def test_amr_nb(self): | ||
| """`sox_io_backend.info` can check amr-nb file correctly""" | ||
|
|
@@ -146,11 +155,13 @@ def test_amr_nb(self): | |
| sample_rate = 8000 | ||
| path = self.get_temp_path('data.amr-nb') | ||
| sox_utils.gen_audio_file( | ||
| path, sample_rate=sample_rate, num_channels=num_channels, bit_depth=16, duration=duration) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try to parameterize |
||
| path, sample_rate=sample_rate, num_channels=num_channels, bit_depth=16, | ||
| duration=duration) | ||
| info = sox_io_backend.info(path) | ||
| assert info.sample_rate == sample_rate | ||
| assert info.num_frames == sample_rate * duration | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == 0 | ||
|
|
||
|
|
||
| @skipIfNoExtension | ||
|
|
@@ -167,6 +178,7 @@ def test_opus(self, bitrate, num_channels, compression_level): | |
| assert info.sample_rate == 48000 | ||
| assert info.num_frames == 32768 | ||
| assert info.num_channels == num_channels | ||
| assert info.bits_per_sample == 0 # bit_per_sample is irrelevant for compressed formats | ||
|
|
||
|
|
||
| @skipIfNoExtension | ||
|
|
@@ -184,3 +196,4 @@ def test_mp3(self): | |
| path = get_asset_path("mp3_without_ext") | ||
| sinfo = sox_io_backend.info(path, format="mp3") | ||
| assert sinfo.sample_rate == 16000 | ||
| assert sinfo.bits_per_sample == 0 # bit_per_sample is irrelevant for compressed formats | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.