From b590d1b82510d4f39ddaa28c14755bc436d59333 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 23 Nov 2023 14:47:59 -0800 Subject: [PATCH] foix --- demo/c/test/test_leopard_c.py | 11 ++++++++--- demo/c/test/test_util.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/demo/c/test/test_leopard_c.py b/demo/c/test/test_leopard_c.py index fb5afda8..473d7531 100644 --- a/demo/c/test/test_leopard_c.py +++ b/demo/c/test/test_leopard_c.py @@ -19,7 +19,7 @@ from test_util import * -test_parameters = load_test_data() +language_tests = load_languages_test_data() class PorcupineCTestCase(unittest.TestCase): @@ -44,8 +44,13 @@ def _get_model_path_by_language(self, language): model_path_subdir = append_language('lib/common/leopard_params', language) return os.path.join(self._root_dir, '%s.pv' % model_path_subdir) - @parameterized.expand(test_parameters) - def test_leopard(self, language, audio_file_name, ground_truth, error_rate): + @parameterized.expand(language_tests) + def test_leopard( + self, + language, + audio_file_name, + ground_truth, + error_rate): args = [ os.path.join(os.path.dirname(__file__), "../build/leopard_demo"), "-a", self._access_key, diff --git a/demo/c/test/test_util.py b/demo/c/test/test_util.py index 4972fd98..2b0d0823 100644 --- a/demo/c/test/test_util.py +++ b/demo/c/test/test_util.py @@ -28,14 +28,19 @@ def append_language(s, language): return "%s_%s" % (s, language) -def load_test_data(): +def load_languages_test_data(): data_file_path = os.path.join(os.path.dirname(__file__), "../../../resources/.test/test_data.json") with open(data_file_path, encoding="utf8") as data_file: json_test_data = data_file.read() - test_data = json.loads(json_test_data)['tests']['parameters'] + test_data = json.loads(json_test_data)['tests']['language_tests'] test_parameters = [ - (t['language'], t['audio_file'], t['transcript'], t['error_rate']) + ( + t['language'], + t['audio_file'], + t['transcript_with_punctuation'], + t['error_rate'] + ) for t in test_data] return test_parameters