|
16 | 16 | from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio |
17 | 17 | from parameterized import parameterized |
18 | 18 |
|
19 | | -from ..utils import CACHE_DIR, get_test_cases_multiple |
| 19 | +from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, get_test_cases_multiple |
20 | 20 |
|
21 | 21 |
|
22 | 22 | class TestNormalizeWithAudio: |
23 | | - normalizer = NormalizerWithAudio(input_case='cased', lang='sv', cache_dir=CACHE_DIR, overwrite_cache=False) |
| 23 | + normalizer_with_audio = ( |
| 24 | + NormalizerWithAudio(input_case='cased', lang='sv', cache_dir=CACHE_DIR, overwrite_cache=False) |
| 25 | + if RUN_AUDIO_BASED_TESTS |
| 26 | + else None |
| 27 | + ) |
24 | 28 |
|
25 | 29 | @parameterized.expand(get_test_cases_multiple('sv/data_text_normalization/test_cases_normalize_with_audio.txt')) |
26 | 30 | @pytest.mark.run_only_on('CPU') |
27 | 31 | @pytest.mark.unit |
28 | 32 | def test_norm(self, test_input, expected): |
29 | | - pred = self.normalizer.normalize(test_input, n_tagged=150, punct_post_process=False) |
30 | | - assert len(set(pred).intersection(set(expected))) == len( |
31 | | - expected |
32 | | - ), f'missing: {set(expected).difference(set(pred))}' |
| 33 | + if self.normalizer_with_audio: |
| 34 | + pred = self.normalizer_with_audio.normalize(test_input, n_tagged=150, punct_post_process=False) |
| 35 | + assert len(set(pred).intersection(set(expected))) == len( |
| 36 | + expected |
| 37 | + ), f'missing: {set(expected).difference(set(pred))}' |
0 commit comments