Unverified Commit 9b14c1b6 authored by Yih-Dar's avatar Yih-Dar Committed by GitHub
Browse files

Fix `AutomaticSpeechRecognitionPipelineTests.run_pipeline_test` (#20597)



* Remove assert exception not triggered

* Fix wrong expected exception string

* fix

* use assertRaisesRegex
Co-authored-by: default avatarydshieh <ydshieh@users.noreply.github.com>
parent 6a707cf5
...@@ -118,15 +118,9 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase, metaclass=Pipel ...@@ -118,15 +118,9 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase, metaclass=Pipel
}, },
) )
else: 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 # 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") outputs = speech_recognizer(audio, return_timestamps="char")
self.assertEqual(v.exception, "")
@require_torch @require_torch
@slow @slow
...@@ -148,9 +142,8 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase, metaclass=Pipel ...@@ -148,9 +142,8 @@ class AutomaticSpeechRecognitionPipelineTests(unittest.TestCase, metaclass=Pipel
self.assertEqual(output, {"text": "(Applaudissements)"}) self.assertEqual(output, {"text": "(Applaudissements)"})
# Non CTC models cannot use return_timestamps # 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") _ = speech_recognizer(waveform, return_timestamps="char")
self.assertEqual(str(v.exception), "We cannot return_timestamps yet on non-ctc models !")
@require_torch @require_torch
def test_small_model_pt_seq2seq(self): def test_small_model_pt_seq2seq(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment