Skip to content

Commit

Permalink
adds xfail; misc. cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasohara committed Jan 15, 2024
1 parent 55916eb commit 5648648
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions mezcla/examples/tests/test_hugging_face_speechrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ class TestIt(TestWrapper):
"""Class for command-line based testcase definition"""
script_module = TestWrapper.get_testing_module_name(__file__, THE_MODULE)

## OLD: To be fixed
@pytest.mark.xfail # TODO: remove xfail
## DEBUG:
@trap_exception
def test_data_file(self):
"""Tests run_script w/ data file"""
debug.trace(4, f"TestIt.test_data_file(); self={self}")
Expand All @@ -60,44 +57,45 @@ def test_data_file(self):
self.do_assert(my_re.search(r"testing|one|two|three", output.strip()))
return

## NEW: Added tests for hugging_face_speechrec.py
## TEST 1: Test the vanilla script using a soundfile
@pytest.mark.xfail # TODO: remove xfail
def test_sound_file_default(self):
"""Ensures that test_sound_file_default works properly"""
## NEW: Added tests for hugging_face_speechrec.py
## TEST 1: Test the vanilla script using a soundfile
debug.trace(4, f"TestIt.test_sound_file_default(); self={self}")
audio_file = gh.resolve_path("fuzzy-testing-1-2-3.wav")
output_cmd = f"python3 {HF_SPEECHREC_PATH} {audio_file} 2> /dev/null"
output = gh.run(output_cmd)
self.do_assert(my_re.search(r"testing|one|two|three", output.strip()))
return

## TEST 2: Test the vanilla script using a different soundfile (US English)
@pytest.mark.skip # TODO: Fix path for audio_file
def test_sound_file_us1(self):
"""Ensures that test_sound_file_us1 works properly"""
## TEST 2: Test the vanilla script using a different soundfile (US English)
debug.trace(4, f"TestIt.test_sound_file_us1(); self={self}")
audio_file = gh.resolve_path("examples/resources/speech-wav/us1.wav")
output_cmd = f"python3 {HF_SPEECHREC_PATH} {audio_file} 2> /dev/null"
output = gh.run(output_cmd)
self.do_assert(my_re.search(r"but|we|also|get|to|see|the|whole|thing", output.strip()))
return

## TEST 3: Test the vanilla script using a different soundfile (US English)
@pytest.mark.skip # TODO: Fix path for audio_file
def test_sound_file_us2(self):
"""Ensures that test_sound_file_us2 works properly"""
## TEST 3: Test the vanilla script using a different soundfile (US English)
debug.trace(4, f"TestIt.test_sound_file_us2(); self={self}")
audio_file = gh.resolve_path("examples/resources/speech-wav/us10.wav")
output_cmd = f"python3 {HF_SPEECHREC_PATH} {audio_file} 2> /dev/null"
output = gh.run(output_cmd)
self.do_assert(my_re.search(r"we|tend|to|seek|simple|answers", output.strip()))
return

## TEST 4: Test the script using a different ASR model
## NOTE: Skipped due to use of a different model (i.e. large downloads)
@pytest.mark.skip
def test_sound_file_model(self):
"""Ensures that test_sound_file_model works properly"""
## TEST 4: Test the script using a different ASR model
## NOTE: Skipped due to use of a different model (i.e. large downloads)
audio_file = gh.resolve_path("fuzzy-testing-1-2-3.wav")
asr_model = "openai/whisper-large-v3"
output_cmd = f"ASR_MODEL={asr_model} python3 {HF_SPEECHREC_PATH} {audio_file} 2> /dev/null"
Expand Down

0 comments on commit 5648648

Please sign in to comment.