alessandro trinca tornidor commited on
Commit
baf2993
1 Parent(s): 6777887

test: updated tests to match pronunciation_accuracy float return type

Browse files
tests/test_lambdaSpeechToScore.py CHANGED
@@ -13,7 +13,7 @@ expected_output = {
13
  "de": {
14
  "real_transcript": text_dict["de"],
15
  "ipa_transcript": "\u026a\u00e7 bi\u02d0n a\u02d0l\u025bksv\u025b\u02d0 b\u025bst\u025b\u02d0 du\u02d0",
16
- "pronunciation_accuracy": "63",
17
  "real_transcripts": text_dict["de"],
18
  "matched_transcripts": "ich bin alexwe - beste du",
19
  "real_transcripts_ipa": "\u026a\u00e7 bi\u02d0n a\u02d0l\u025bks, v\u0250 b\u026ast du\u02d0?",
@@ -26,7 +26,7 @@ expected_output = {
26
  "en": {
27
  "real_transcript": text_dict["en"],
28
  "ipa_transcript": "ha\u026a ha\u028a \u0259r ju",
29
- "pronunciation_accuracy": "69",
30
  "real_transcripts": text_dict["en"],
31
  "matched_transcripts": "hi - how are you",
32
  "real_transcripts_ipa": "ha\u026a \u00f0\u025br, ha\u028a \u0259r ju?",
@@ -82,9 +82,9 @@ def check_output(self, output, expected_output):
82
  output = check_output_by_field(
83
  output, "start_time", "\d+\.\d+", expected_output
84
  )
85
- output = check_output_by_field(
86
- output, "pronunciation_accuracy", "\d+", expected_output
87
- )
88
  output["matched_transcripts"] = expected_output["matched_transcripts"]
89
  output["matched_transcripts_ipa"] = expected_output["matched_transcripts_ipa"]
90
  output["pronunciation_accuracy"] = expected_output["pronunciation_accuracy"]
@@ -205,7 +205,8 @@ class TestGetAccuracyFromRecordedAudio(unittest.TestCase):
205
  )
206
  assert real_transcripts == text_dict[language]
207
  check_value_by_field(is_letter_correct_all_words, "[01]+")
208
- check_value_by_field(pronunciation_accuracy, "\d+")
 
209
  assert len(ipa_transcript.strip()) > 0
210
  assert len(real_transcripts_ipa.strip()) > 0
211
  check_output(self, json.loads(dumped), expected_output[language])
@@ -230,7 +231,8 @@ class TestGetAccuracyFromRecordedAudio(unittest.TestCase):
230
  )
231
  assert real_transcripts == text_dict[language]
232
  check_value_by_field(is_letter_correct_all_words, "[01]+")
233
- check_value_by_field(pronunciation_accuracy, "\d+")
 
234
  assert len(ipa_transcript.strip()) > 0
235
  assert len(real_transcripts_ipa.strip()) > 0
236
  check_output(self, json.loads(dumped), expected_output[language])
 
13
  "de": {
14
  "real_transcript": text_dict["de"],
15
  "ipa_transcript": "\u026a\u00e7 bi\u02d0n a\u02d0l\u025bksv\u025b\u02d0 b\u025bst\u025b\u02d0 du\u02d0",
16
+ "pronunciation_accuracy": 63.0,
17
  "real_transcripts": text_dict["de"],
18
  "matched_transcripts": "ich bin alexwe - beste du",
19
  "real_transcripts_ipa": "\u026a\u00e7 bi\u02d0n a\u02d0l\u025bks, v\u0250 b\u026ast du\u02d0?",
 
26
  "en": {
27
  "real_transcript": text_dict["en"],
28
  "ipa_transcript": "ha\u026a ha\u028a \u0259r ju",
29
+ "pronunciation_accuracy": 69.0,
30
  "real_transcripts": text_dict["en"],
31
  "matched_transcripts": "hi - how are you",
32
  "real_transcripts_ipa": "ha\u026a \u00f0\u025br, ha\u028a \u0259r ju?",
 
82
  output = check_output_by_field(
83
  output, "start_time", "\d+\.\d+", expected_output
84
  )
85
+ pronunciation_accuracy = output["pronunciation_accuracy"]
86
+ assert isinstance(pronunciation_accuracy, float)
87
+ assert pronunciation_accuracy <= 100
88
  output["matched_transcripts"] = expected_output["matched_transcripts"]
89
  output["matched_transcripts_ipa"] = expected_output["matched_transcripts_ipa"]
90
  output["pronunciation_accuracy"] = expected_output["pronunciation_accuracy"]
 
205
  )
206
  assert real_transcripts == text_dict[language]
207
  check_value_by_field(is_letter_correct_all_words, "[01]+")
208
+ assert isinstance(pronunciation_accuracy, float)
209
+ assert pronunciation_accuracy <= 100
210
  assert len(ipa_transcript.strip()) > 0
211
  assert len(real_transcripts_ipa.strip()) > 0
212
  check_output(self, json.loads(dumped), expected_output[language])
 
231
  )
232
  assert real_transcripts == text_dict[language]
233
  check_value_by_field(is_letter_correct_all_words, "[01]+")
234
+ assert isinstance(pronunciation_accuracy, float)
235
+ assert pronunciation_accuracy <= 100
236
  assert len(ipa_transcript.strip()) > 0
237
  assert len(real_transcripts_ipa.strip()) > 0
238
  check_output(self, json.loads(dumped), expected_output[language])
tests/test_lambdaTTS.py CHANGED
@@ -42,14 +42,14 @@ class TestLambdaTTS(unittest.TestCase):
42
  exec_test_lambda_tts(
43
  "Hi there, how are you?",
44
  "en",
45
- b'vf1QWORrGWlvCEQuvI0fajGG7iz2Zqp83p8dVH8pZtY='
46
  )
47
 
48
  def test_lambdaTTS_de_ok(self):
49
  exec_test_lambda_tts(
50
  "Ich bin Alex!",
51
  "de",
52
- b'jkvM+0Whlb1nwf9eiuDyoQZ1ekzb46k3DcW2glYh0YY='
53
  )
54
 
55
  def test_lambdaTTS_empty_text(self):
 
42
  exec_test_lambda_tts(
43
  "Hi there, how are you?",
44
  "en",
45
+ b'6rZkDkF/Jc/7S5aTBlyNvntMng1+N81Flndx3WM5U0g='
46
  )
47
 
48
  def test_lambdaTTS_de_ok(self):
49
  exec_test_lambda_tts(
50
  "Ich bin Alex!",
51
  "de",
52
+ b'4CCWiz7DOOHSmyYcS8KTBvk2E3zHtaX5umtksVln5VA='
53
  )
54
 
55
  def test_lambdaTTS_empty_text(self):
tests/test_serialize.py CHANGED
@@ -95,3 +95,7 @@ class TestSerialize(unittest.TestCase):
95
  'geometry': {'type': 'Point', 'coordinates': [139.021, 35.233]}}
96
  ]
97
  })
 
 
 
 
 
95
  'geometry': {'type': 'Point', 'coordinates': [139.021, 35.233]}}
96
  ]
97
  })
98
+
99
+
100
+ if __name__ == '__main__':
101
+ unittest.main()
tests/test_utilities.py CHANGED
@@ -43,3 +43,7 @@ class TestUtilities(unittest.TestCase):
43
  output_hash = hash_calculate(EVENTS_FOLDER / "GetAccuracyFromRecordedAudio.json", is_file=True)
44
  app_logger.info(f"output_hash json: {output_hash}")
45
  assert b'i83jKpwzfcPitZsrHsnhyFt8xbc+DStpns9rb3vfigw=' == output_hash
 
 
 
 
 
43
  output_hash = hash_calculate(EVENTS_FOLDER / "GetAccuracyFromRecordedAudio.json", is_file=True)
44
  app_logger.info(f"output_hash json: {output_hash}")
45
  assert b'i83jKpwzfcPitZsrHsnhyFt8xbc+DStpns9rb3vfigw=' == output_hash
46
+
47
+
48
+ if __name__ == '__main__':
49
+ unittest.main()