[tests] deflake dither test (#36284)

This commit is contained in:
Joao Gante
2025-02-19 15:13:10 +00:00
committed by GitHub
parent 60226c6ff3
commit fa8cdccd91
14 changed files with 18 additions and 19 deletions

View File

@@ -193,7 +193,7 @@ class ASTFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -308,7 +308,7 @@ class ClapFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -188,7 +188,7 @@ class ClvpFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -108,7 +108,7 @@ class DacFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -132,7 +132,7 @@ class EncodecFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -242,7 +242,7 @@ class MusicgenMelodyFeatureExtractor(SequenceFeatureExtractor):
if sampling_rate is None: if sampling_rate is None:
logger.warning_once( logger.warning_once(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -225,7 +225,7 @@ class SeamlessM4TFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -248,7 +248,7 @@ class Speech2TextFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -252,7 +252,7 @@ class SpeechT5FeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the ``sampling_rate`` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -370,7 +370,7 @@ class UnivNetFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -178,7 +178,7 @@ class Wav2Vec2FeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the ``sampling_rate`` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -255,7 +255,6 @@ class WhisperFeatureExtractor(SequenceFeatureExtractor):
Whether or not to return the number of frames of the input raw_speech. Whether or not to return the number of frames of the input raw_speech.
These num_frames can be used by the model to compute word level timestamps. These num_frames can be used by the model to compute word level timestamps.
""" """
if sampling_rate is not None: if sampling_rate is not None:
if sampling_rate != self.sampling_rate: if sampling_rate != self.sampling_rate:
raise ValueError( raise ValueError(
@@ -265,7 +264,7 @@ class WhisperFeatureExtractor(SequenceFeatureExtractor):
) )
else: else:
logger.warning( logger.warning(
"It is strongly recommended to pass the `sampling_rate` argument to this function. " f"It is strongly recommended to pass the `sampling_rate` argument to `{self.__class__.__name__}()`. "
"Failing to do so can result in silent errors that might be hard to debug." "Failing to do so can result in silent errors that might be hard to debug."
) )

View File

@@ -163,10 +163,10 @@ class Speech2TextFeatureExtractionTest(SequenceFeatureExtractionTestMixin, unitt
# compute features # compute features
input_features_no_dither = feature_extractor_no_dither( input_features_no_dither = feature_extractor_no_dither(
np_speech_inputs, padding=True, return_tensors="np" np_speech_inputs, padding=True, return_tensors="np", sampling_rate=dict_no_dither["sampling_rate"]
).input_features ).input_features
input_features_dither = feature_extractor_dither( input_features_dither = feature_extractor_dither(
np_speech_inputs, padding=True, return_tensors="np" np_speech_inputs, padding=True, return_tensors="np", sampling_rate=dict_dither["sampling_rate"]
).input_features ).input_features
# test there is a difference between features (there's added noise to input signal) # test there is a difference between features (there's added noise to input signal)
@@ -176,7 +176,7 @@ class Speech2TextFeatureExtractionTest(SequenceFeatureExtractionTestMixin, unitt
self.assertTrue(np.abs(diff).mean() > 1e-5) self.assertTrue(np.abs(diff).mean() > 1e-5)
# features are not too different # features are not too different
self.assertTrue(np.abs(diff).mean() <= 1e-3) self.assertTrue(np.abs(diff).mean() <= 1e-3)
self.assertTrue(np.abs(diff).max() <= 1e-2) self.assertTrue(np.abs(diff).max() <= 5e-2)
def test_cepstral_mean_and_variance_normalization(self): def test_cepstral_mean_and_variance_normalization(self):
feature_extractor = self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()) feature_extractor = self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())

View File

@@ -219,10 +219,10 @@ class WhisperFeatureExtractionTest(SequenceFeatureExtractionTestMixin, unittest.
# compute features # compute features
input_features_no_dither = feature_extractor_no_dither( input_features_no_dither = feature_extractor_no_dither(
np_speech_inputs, padding=True, return_tensors="np" np_speech_inputs, padding=True, return_tensors="np", sampling_rate=dict_no_dither["sampling_rate"]
).input_features ).input_features
input_features_dither = feature_extractor_dither( input_features_dither = feature_extractor_dither(
np_speech_inputs, padding=True, return_tensors="np" np_speech_inputs, padding=True, return_tensors="np", sampling_rate=dict_dither["sampling_rate"]
).input_features ).input_features
# test there is a difference between features (there's added noise to input signal) # test there is a difference between features (there's added noise to input signal)
@@ -232,7 +232,7 @@ class WhisperFeatureExtractionTest(SequenceFeatureExtractionTestMixin, unittest.
self.assertTrue(np.abs(diff).mean() > 1e-6) self.assertTrue(np.abs(diff).mean() > 1e-6)
# features are not too different # features are not too different
self.assertTrue(np.abs(diff).mean() <= 1e-4) self.assertTrue(np.abs(diff).mean() <= 1e-4)
self.assertTrue(np.abs(diff).max() <= 1e-3) self.assertTrue(np.abs(diff).max() <= 5e-3)
@require_torch @require_torch
def test_double_precision_pad(self): def test_double_precision_pad(self):