-
Notifications
You must be signed in to change notification settings - Fork 713
[COMPARISON TESTS] Use pre-computed values in librosa compat test #4018
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
25 commits
Select commit
Hold shift + click to select a range
dc073ea
Attempting autouse fixture
samanklesaria 6da31fd
Mock calls to librosa by reading from cache
samanklesaria dd1ee02
Add librosa cache
samanklesaria f90ddaf
Convert single cache file to one per test
samanklesaria b8389e9
Raise tolerance for librosa power tests
samanklesaria a1729f9
Remove colons in request string
samanklesaria 4dde9b6
Re-generate librosa expected results
samanklesaria b538475
Use newer numpy
samanklesaria 1e9bcd7
Fix pillow typo
samanklesaria 5443243
Require numpy >= 1.26
samanklesaria e3b26d0
Merge branch 'main' into librosa_mock
samanklesaria 02bf73b
Use numpy>=1.26
samanklesaria eaaa22c
Use explicit seed of zero for vocoder tests
samanklesaria f33fc37
Add docstring for mock_function
samanklesaria e3dae11
Expand docstring form mock_function
samanklesaria edb0768
Merge branch 'main' into librosa_mock
samanklesaria 5e5c7ed
Comment out expected-value creation code
samanklesaria 764f917
Remove if checks. Those should never ever be False. If they are, this…
NicolasHug 8be08ca
Make test runnable from arbitrary dir
NicolasHug c278819
Add comment to explain what Request Mixin is
NicolasHug db17ee1
Clarify if-statement in librosa_mock
samanklesaria c6b7bbc
Revert mistaken deletion of deprecation test
samanklesaria 0157f60
Fix mfcc_from_waveform issue
samanklesaria b21b4db
Merge cpu and cuda results
samanklesaria 91daa09
Disable generation again
samanklesaria 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,62 @@ | ||
import re | ||
import os | ||
from pathlib import Path | ||
import torch | ||
|
||
def mock_function(f): | ||
""" | ||
Create a mocked version of a function from the librosa library that loads a precomputed result | ||
if it exists. The commented out part otherwise computes the result and saves it for future use. | ||
This is used to compare torchaudio functionality to the equivalent functionalty in librosa without | ||
depending on librosa after results are precomputed. | ||
""" | ||
this_file = Path(__file__).parent.resolve() | ||
expected_results_folder = this_file / "torchaudio_unittest" / "assets" / "librosa_expected_results" | ||
def wrapper(request, *args, **kwargs): | ||
mocked_results = expected_results_folder / f"{request}.pt" | ||
return torch.load(mocked_results, weights_only=False) | ||
|
||
# Old definition used for generation: | ||
# if os.path.exists(mocked_results): | ||
# return torch.load(mocked_results, weights_only=False) | ||
# import librosa | ||
# result = eval(f)(*args, **kwargs) | ||
# if request is not None: | ||
# mocked_results.parent.mkdir(parents=True, exist_ok=True) | ||
# torch.save(result, mocked_results) | ||
# return result | ||
return wrapper | ||
|
||
griffinlim = mock_function("librosa.griffinlim") | ||
|
||
mel = mock_function("librosa.filters.mel") | ||
|
||
power_to_db = mock_function("librosa.core.power_to_db") | ||
|
||
amplitude_to_db = mock_function("librosa.core.amplitude_to_db") | ||
|
||
phase_vocoder = mock_function("librosa.phase_vocoder") | ||
|
||
spectrogram = mock_function("librosa.core.spectrum._spectrogram") | ||
|
||
mel_spectrogram = mock_function("librosa.feature.melspectrogram") | ||
|
||
def _mfcc_from_waveform(waveform, sample_rate, n_fft, hop_length, n_mels, n_mfcc): | ||
import librosa | ||
melspec = librosa.feature.melspectrogram( | ||
y=waveform[0].cpu().numpy(), | ||
sr=sample_rate, | ||
n_fft=n_fft, | ||
win_length=n_fft, | ||
hop_length=hop_length, | ||
n_mels=n_mels, | ||
htk=True, | ||
norm=None, | ||
pad_mode="reflect", | ||
) | ||
return librosa.feature.mfcc(S=librosa.core.power_to_db(melspec), n_mfcc=n_mfcc, dct_type=2, norm="ortho") | ||
|
||
mfcc_from_waveform = mock_function("_mfcc_from_waveform") | ||
|
||
|
||
spectral_centroid = mock_function("librosa.feature.spectral_centroid") |
Binary file added
BIN
+355 KB
...test/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_amplitude_to_DB.pt
Binary file not shown.
Binary file added
BIN
+355 KB
...unctional/librosa_compatibility_test.py__TestFunctionalCPU__test_amplitude_to_DB_power.pt
Binary file not shown.
Binary file added
BIN
+164 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_00.pt
Binary file not shown.
Binary file added
BIN
+164 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_01.pt
Binary file not shown.
Binary file added
BIN
+164 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_02.pt
Binary file not shown.
Binary file added
BIN
+164 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_03.pt
Binary file not shown.
Binary file added
BIN
+516 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_04.pt
Binary file not shown.
Binary file added
BIN
+516 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_05.pt
Binary file not shown.
Binary file added
BIN
+516 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_06.pt
Binary file not shown.
Binary file added
BIN
+516 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_07.pt
Binary file not shown.
Binary file added
BIN
+515 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_08.pt
Binary file not shown.
Binary file added
BIN
+515 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_09.pt
Binary file not shown.
Binary file added
BIN
+515 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_10.pt
Binary file not shown.
Binary file added
BIN
+515 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_11.pt
Binary file not shown.
Binary file added
BIN
+228 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_12.pt
Binary file not shown.
Binary file added
BIN
+228 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_13.pt
Binary file not shown.
Binary file added
BIN
+229 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_14.pt
Binary file not shown.
Binary file added
BIN
+229 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_15.pt
Binary file not shown.
Binary file added
BIN
+226 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_16.pt
Binary file not shown.
Binary file added
BIN
+226 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_17.pt
Binary file not shown.
Binary file added
BIN
+226 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_18.pt
Binary file not shown.
Binary file added
BIN
+226 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_19.pt
Binary file not shown.
Binary file added
BIN
+227 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_20.pt
Binary file not shown.
Binary file added
BIN
+227 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_21.pt
Binary file not shown.
Binary file added
BIN
+283 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_22.pt
Binary file not shown.
Binary file added
BIN
+283 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_23.pt
Binary file not shown.
Binary file added
BIN
+42.4 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_24.pt
Binary file not shown.
Binary file added
BIN
+42.4 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_25.pt
Binary file not shown.
Binary file added
BIN
+52.5 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_26.pt
Binary file not shown.
Binary file added
BIN
+52.5 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_create_mel_fb_27.pt
Binary file not shown.
Binary file added
BIN
+197 KB
...nittest/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_griffinlim_0.pt
Binary file not shown.
Binary file added
BIN
+197 KB
...test/functional/librosa_compatibility_test.py__TestFunctionalCPU__test_griffinlim_0_99.pt
Binary file not shown.
Binary file added
BIN
+355 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCUDA__test_amplitude_to_DB.pt
Binary file not shown.
Binary file added
BIN
+355 KB
...nctional/librosa_compatibility_test.py__TestFunctionalCUDA__test_amplitude_to_DB_power.pt
Binary file not shown.
Binary file added
BIN
+197 KB
...ittest/functional/librosa_compatibility_test.py__TestFunctionalCUDA__test_griffinlim_0.pt
Binary file not shown.
Binary file added
BIN
+197 KB
...est/functional/librosa_compatibility_test.py__TestFunctionalCUDA__test_griffinlim_0_99.pt
Binary file not shown.
Binary file added
BIN
+19.5 MB
...tional/librosa_compatibility_test.py__TestFunctionalComplexCPU__test_phase_vocoder_0_5.pt
Binary file not shown.
Binary file added
BIN
+9.69 MB
...ional/librosa_compatibility_test.py__TestFunctionalComplexCPU__test_phase_vocoder_1_01.pt
Binary file not shown.
Binary file added
BIN
+7.52 MB
...tional/librosa_compatibility_test.py__TestFunctionalComplexCPU__test_phase_vocoder_1_3.pt
Binary file not shown.
Binary file added
BIN
+19.5 MB
...ional/librosa_compatibility_test.py__TestFunctionalComplexCUDA__test_phase_vocoder_0_5.pt
Binary file not shown.
Binary file added
BIN
+9.69 MB
...onal/librosa_compatibility_test.py__TestFunctionalComplexCUDA__test_phase_vocoder_1_01.pt
Binary file not shown.
Binary file added
BIN
+7.52 MB
...ional/librosa_compatibility_test.py__TestFunctionalComplexCUDA__test_phase_vocoder_1_3.pt
Binary file not shown.
Binary file added
BIN
+60.5 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_00.pt
Binary file not shown.
Binary file added
BIN
+60.4 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_01.pt
Binary file not shown.
Binary file added
BIN
+59.8 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_02.pt
Binary file not shown.
Binary file added
BIN
+60 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_03.pt
Binary file not shown.
Binary file added
BIN
+233 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_04.pt
Binary file not shown.
Binary file added
BIN
+233 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_05.pt
Binary file not shown.
Binary file added
BIN
+233 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_06.pt
Binary file not shown.
Binary file added
BIN
+233 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_07.pt
Binary file not shown.
Binary file added
BIN
+118 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_08.pt
Binary file not shown.
Binary file added
BIN
+118 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_09.pt
Binary file not shown.
Binary file added
BIN
+117 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_10.pt
Binary file not shown.
Binary file added
BIN
+118 KB
...ttest/transforms/librosa_compatibility_test.py__TestTransforms__test_MelSpectrogram_11.pt
Binary file not shown.
Binary file added
BIN
+178 KB
..._unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_Spectrogram_0.pt
Binary file not shown.
Binary file added
BIN
+524 KB
..._unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_Spectrogram_1.pt
Binary file not shown.
Binary file added
BIN
+180 KB
..._unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_Spectrogram_2.pt
Binary file not shown.
Binary file added
BIN
+354 KB
..._unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_Spectrogram_3.pt
Binary file not shown.
Binary file added
BIN
+179 KB
...est/transforms/librosa_compatibility_test.py__TestTransforms__test_Spectrogram_complex.pt
Binary file not shown.
Binary file added
BIN
+351 KB
...nittest/transforms/librosa_compatibility_test.py__TestTransforms__test_magnitude_to_db.pt
Binary file not shown.
Binary file added
BIN
+39.6 KB
...chaudio_unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_mfcc_0.pt
Binary file not shown.
Binary file added
BIN
+39 KB
...chaudio_unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_mfcc_1.pt
Binary file not shown.
Binary file added
BIN
+95.6 KB
...chaudio_unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_mfcc_2.pt
Binary file not shown.
Binary file added
BIN
+351 KB
...io_unittest/transforms/librosa_compatibility_test.py__TestTransforms__test_power_to_db.pt
Binary file not shown.
Binary file added
BIN
+3.11 KB
...est/transforms/librosa_compatibility_test.py__TestTransforms__test_spectral_centroid_0.pt
Binary file not shown.
Binary file added
BIN
+4.04 KB
...est/transforms/librosa_compatibility_test.py__TestTransforms__test_spectral_centroid_1.pt
Binary file not shown.
Binary file added
BIN
+5.92 KB
...est/transforms/librosa_compatibility_test.py__TestTransforms__test_spectral_centroid_2.pt
Binary file not shown.
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
Oops, something went wrong.
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.