Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate Tom dev #37

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions mezcla/tests/test_convert_emoticons.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TestIt(TestWrapper):
script_module = TestWrapper.get_testing_module_name(__file__, THE_MODULE)
script_file = my_re.sub(rf"{D}tests{D}test_", f"{D}", __file__)

@trap_exception
@pytest.mark.xfail # TODO: remove xfail
def test_over_script(self):
"""Makes sure works as expected over script itself"""
debug.trace(4, f"TestIt.test_over_script(); self={self}")
Expand All @@ -74,7 +74,7 @@ def test_over_script(self):
self.do_assert(not my_re.search(loose_emoticon_regex, output_san_Japanese_example.encode()))
return

@trap_exception
@pytest.mark.xfail # TODO: remove xfail
def test_over_script_sans_comments(self):
"""Makes sure works as expected over script itself"""
debug.trace(4, f"TestIt.test_over_script_sans_comments(); self={self}")
Expand Down