-
Notifications
You must be signed in to change notification settings - Fork 744
An implemenation of the ITU-R BS.1770-4 loudness recommendation #2472
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bc2cda3
initial commit and tests
bshall 05fe162
Fixed doc string and renamed function to
bshall 2d91fa2
Moved loudness test out of unittest directory
bshall 4243b5a
Added Loudness transform
bshall a02ccbc
Removed float types for contants
bshall f968789
Moved sample_rate to __init__ in Loudness transform
bshall d8c24af
Fixed doc string
bshall 7e97e15
Refactored loudness tests
bshall 4e72bca
Added loudness entries to functional.rst and transforms.rst
bshall 93f350f
Replaced constant bias with variable
bshall 01f979f
Added expecttest and parameterized to integration test workflow
bshall b173b58
Added scipy to integration test workflow
bshall 9c54cd7
Removed torchaudio_unittest module from loudness test
bshall 2dbeab0
nits
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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| """Test suite for compliance with the ITU-R BS.1770-4 recommendation""" | ||
| import zipfile | ||
|
|
||
| import pytest | ||
|
|
||
| import torch | ||
| import torchaudio | ||
| import torchaudio.functional as F | ||
|
|
||
|
|
||
| # Test files linked in https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BS.2217-2-2016-PDF-E.pdf | ||
| @pytest.mark.parametrize( | ||
| "filename,url,expected", | ||
| [ | ||
| ( | ||
| "1770-2_Comp_RelGateTest", | ||
| "http://www.itu.int/dms_pub/itu-r/oth/11/02/R11020000010030ZIPM.zip", | ||
| -10.0, | ||
| ), | ||
| ( | ||
| "1770-2_Comp_AbsGateTest", | ||
| "http://www.itu.int/dms_pub/itu-r/oth/11/02/R11020000010029ZIPM.zip", | ||
| -69.5, | ||
| ), | ||
| ( | ||
| "1770-2_Comp_24LKFS_500Hz_2ch", | ||
| "http://www.itu.int/dms_pub/itu-r/oth/11/02/R11020000010018ZIPM.zip", | ||
| -24.0, | ||
| ), | ||
| ( | ||
| "1770-2 Conf Mono Voice+Music-24LKFS", | ||
| "http://www.itu.int/dms_pub/itu-r/oth/11/02/R11020000010038ZIPM.zip", | ||
| -24.0, | ||
| ), | ||
| ], | ||
| ) | ||
| def test_loudness(tmp_path, filename, url, expected): | ||
| zippath = tmp_path / filename | ||
| torch.hub.download_url_to_file(url, zippath, progress=False) | ||
| with zipfile.ZipFile(zippath) as file: | ||
| file.extractall(zippath.parent) | ||
|
|
||
| waveform, sample_rate = torchaudio.load(zippath.with_suffix(".wav")) | ||
| loudness = F.loudness(waveform, sample_rate) | ||
| expected = torch.tensor(expected, dtype=loudness.dtype, device=loudness.device) | ||
| assert torch.allclose(loudness, expected, rtol=0.01, atol=0.1) |
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.