[tests] deflake dither test (#36284)
This commit is contained in:
@@ -193,7 +193,7 @@ class ASTFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ class ClapFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ class ClvpFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class DacFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class EncodecFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ class MusicgenMelodyFeatureExtractor(SequenceFeatureExtractor):
|
||||
|
||||
if sampling_rate is None:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ class SeamlessM4TFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ class Speech2TextFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ class SpeechT5FeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ class UnivNetFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ class Wav2Vec2FeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -255,7 +255,6 @@ class WhisperFeatureExtractor(SequenceFeatureExtractor):
|
||||
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.
|
||||
"""
|
||||
|
||||
if sampling_rate is not None:
|
||||
if sampling_rate != self.sampling_rate:
|
||||
raise ValueError(
|
||||
@@ -265,7 +264,7 @@ class WhisperFeatureExtractor(SequenceFeatureExtractor):
|
||||
)
|
||||
else:
|
||||
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."
|
||||
)
|
||||
|
||||
|
||||
@@ -163,10 +163,10 @@ class Speech2TextFeatureExtractionTest(SequenceFeatureExtractionTestMixin, unitt
|
||||
|
||||
# compute features
|
||||
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_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
|
||||
|
||||
# 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)
|
||||
# features are not too different
|
||||
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):
|
||||
feature_extractor = self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
|
||||
|
||||
@@ -219,10 +219,10 @@ class WhisperFeatureExtractionTest(SequenceFeatureExtractionTestMixin, unittest.
|
||||
|
||||
# compute features
|
||||
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_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
|
||||
|
||||
# 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)
|
||||
# features are not too different
|
||||
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
|
||||
def test_double_precision_pad(self):
|
||||
|
||||
Reference in New Issue
Block a user