Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
·
333afb5
1
Parent(s):
d009a59
test: update test cases for lambdaSpeechToScore.get_speech_to_score_tuple because of a new variable in the return tuple
Browse files
tests/lambdas/test_lambdaSpeechToScore.py
CHANGED
@@ -68,7 +68,8 @@ def check_output_by_field(output, key, match, expected_output):
|
|
68 |
return output
|
69 |
|
70 |
|
71 |
-
def check_output(self, output, expected_output):
|
|
|
72 |
self.maxDiff = None
|
73 |
try:
|
74 |
assert len(output["matched_transcripts"].strip()) > 0
|
@@ -92,7 +93,19 @@ def check_output(self, output, expected_output):
|
|
92 |
output["ipa_transcript"] = expected_output["ipa_transcript"]
|
93 |
output["real_transcript"] = expected_output["real_transcript"]
|
94 |
output["real_transcripts_ipa"] = expected_output["real_transcripts_ipa"]
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
except Exception as e:
|
97 |
app_logger.error(f"e:{e}.")
|
98 |
raise e
|
@@ -196,6 +209,7 @@ class TestGetAccuracyFromRecordedAudio(unittest.TestCase):
|
|
196 |
pronunciation_accuracy,
|
197 |
ipa_transcript,
|
198 |
real_transcripts_ipa,
|
|
|
199 |
dumped,
|
200 |
) = lambdaSpeechToScore.get_speech_to_score_tuple(
|
201 |
real_text=text_dict[language],
|
@@ -209,7 +223,8 @@ class TestGetAccuracyFromRecordedAudio(unittest.TestCase):
|
|
209 |
assert pronunciation_accuracy <= 100
|
210 |
assert len(ipa_transcript.strip()) > 0
|
211 |
assert len(real_transcripts_ipa.strip()) > 0
|
212 |
-
|
|
|
213 |
|
214 |
def test_get_speech_to_score_tuple_en_ok(self):
|
215 |
from aip_trainer.lambdas import lambdaSpeechToScore
|
@@ -222,6 +237,7 @@ class TestGetAccuracyFromRecordedAudio(unittest.TestCase):
|
|
222 |
pronunciation_accuracy,
|
223 |
ipa_transcript,
|
224 |
real_transcripts_ipa,
|
|
|
225 |
dumped,
|
226 |
) = lambdaSpeechToScore.get_speech_to_score_tuple(
|
227 |
real_text=text_dict[language],
|
@@ -235,7 +251,8 @@ class TestGetAccuracyFromRecordedAudio(unittest.TestCase):
|
|
235 |
assert pronunciation_accuracy <= 100
|
236 |
assert len(ipa_transcript.strip()) > 0
|
237 |
assert len(real_transcripts_ipa.strip()) > 0
|
238 |
-
|
|
|
239 |
|
240 |
def test_get_speech_to_score_dict__de_empty_input_text(self):
|
241 |
language = "de"
|
|
|
68 |
return output
|
69 |
|
70 |
|
71 |
+
def check_output(self, output, expected_output, check_audio_files=False):
|
72 |
+
from pathlib import Path
|
73 |
self.maxDiff = None
|
74 |
try:
|
75 |
assert len(output["matched_transcripts"].strip()) > 0
|
|
|
93 |
output["ipa_transcript"] = expected_output["ipa_transcript"]
|
94 |
output["real_transcript"] = expected_output["real_transcript"]
|
95 |
output["real_transcripts_ipa"] = expected_output["real_transcripts_ipa"]
|
96 |
+
if check_audio_files:
|
97 |
+
audio_files = output["audio_files"]
|
98 |
+
for audio_file in audio_files:
|
99 |
+
path_audio_file = Path(audio_file)
|
100 |
+
app_logger.info(f"path_audio_file:{path_audio_file}.")
|
101 |
+
assert path_audio_file.is_file()
|
102 |
+
path_audio_file.unlink()
|
103 |
+
|
104 |
+
output["audio_files"] = [*audio_files]
|
105 |
+
expected_output["audio_files"] = [*audio_files]
|
106 |
+
app_logger.info(f"output audio_files:{output['audio_files']}.")
|
107 |
+
app_logger.info(f"expected_output audio_files:{expected_output['audio_files']}.")
|
108 |
+
self.assertDictEqual(output, expected_output)
|
109 |
except Exception as e:
|
110 |
app_logger.error(f"e:{e}.")
|
111 |
raise e
|
|
|
209 |
pronunciation_accuracy,
|
210 |
ipa_transcript,
|
211 |
real_transcripts_ipa,
|
212 |
+
num_words,
|
213 |
dumped,
|
214 |
) = lambdaSpeechToScore.get_speech_to_score_tuple(
|
215 |
real_text=text_dict[language],
|
|
|
223 |
assert pronunciation_accuracy <= 100
|
224 |
assert len(ipa_transcript.strip()) > 0
|
225 |
assert len(real_transcripts_ipa.strip()) > 0
|
226 |
+
assert num_words == 6
|
227 |
+
check_output(self, json.loads(dumped), expected_output[language], check_audio_files=True)
|
228 |
|
229 |
def test_get_speech_to_score_tuple_en_ok(self):
|
230 |
from aip_trainer.lambdas import lambdaSpeechToScore
|
|
|
237 |
pronunciation_accuracy,
|
238 |
ipa_transcript,
|
239 |
real_transcripts_ipa,
|
240 |
+
num_words,
|
241 |
dumped,
|
242 |
) = lambdaSpeechToScore.get_speech_to_score_tuple(
|
243 |
real_text=text_dict[language],
|
|
|
251 |
assert pronunciation_accuracy <= 100
|
252 |
assert len(ipa_transcript.strip()) > 0
|
253 |
assert len(real_transcripts_ipa.strip()) > 0
|
254 |
+
assert num_words == 5
|
255 |
+
check_output(self, json.loads(dumped), expected_output[language], check_audio_files=True)
|
256 |
|
257 |
def test_get_speech_to_score_dict__de_empty_input_text(self):
|
258 |
language = "de"
|