Skip to content

Commit

Permalink
foix
Browse files Browse the repository at this point in the history
  • Loading branch information
laves committed Nov 23, 2023
1 parent a292442 commit b590d1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions demo/c/test/test_leopard_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from test_util import *

test_parameters = load_test_data()
language_tests = load_languages_test_data()


class PorcupineCTestCase(unittest.TestCase):
Expand All @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions demo/c/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b590d1b

Please sign in to comment.