mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Fix AutomaticSpeechRecognitionPipelineTests.run_pipeline_test
(#20597)
* Remove assert exception not triggered * Fix wrong expected exception string * fix * use assertRaisesRegex Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
parent
6a707cf586
commit
9b14c1b6bf
@ -118,15 +118,9 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase, metaclass=Pipel
|
||||
},
|
||||
)
|
||||
else:
|
||||
# Non CTC models cannot use chunk_length
|
||||
with self.assertRaises(ValueError) as v:
|
||||
outputs = speech_recognizer(audio, chunk_length_s=10)
|
||||
self.assertEqual(v.exception, "")
|
||||
|
||||
# Non CTC models cannot use return_timestamps
|
||||
with self.assertRaises(ValueError) as v:
|
||||
with self.assertRaisesRegex(ValueError, "^We cannot return_timestamps yet on non-ctc models !$"):
|
||||
outputs = speech_recognizer(audio, return_timestamps="char")
|
||||
self.assertEqual(v.exception, "")
|
||||
|
||||
@require_torch
|
||||
@slow
|
||||
@ -148,9 +142,8 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase, metaclass=Pipel
|
||||
self.assertEqual(output, {"text": "(Applaudissements)"})
|
||||
|
||||
# Non CTC models cannot use return_timestamps
|
||||
with self.assertRaises(ValueError) as v:
|
||||
with self.assertRaisesRegex(ValueError, "^We cannot return_timestamps yet on non-ctc models !$"):
|
||||
_ = speech_recognizer(waveform, return_timestamps="char")
|
||||
self.assertEqual(str(v.exception), "We cannot return_timestamps yet on non-ctc models !")
|
||||
|
||||
@require_torch
|
||||
def test_small_model_pt_seq2seq(self):
|
||||
|
Loading…
Reference in New Issue
Block a user