Spaces:
Running
Running
File size: 1,830 Bytes
28d0c5f 74a35d9 025384a 2a62680 28d0c5f 025384a 28d0c5f 2a62680 28d0c5f 2a62680 9b75ad3 28d0c5f e8a1983 28d0c5f 2a62680 28d0c5f 2a62680 28d0c5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import unittest
import epitran
from aip_trainer import pronunciationTrainer
from aip_trainer.models import RuleBasedModels
class TestPhonemConverter(unittest.TestCase):
def test_english_ok(self):
phonem_converter = RuleBasedModels.EngPhonemConverter()
output = phonem_converter.convertToPhonem('Hello, this is a test')
self.assertEqual(output, 'hɛˈloʊ, ðɪs ɪz ə tɛst')
def test_german_ok(self):
deu_latn = epitran.Epitran('deu-Latn')
phonem_converter = RuleBasedModels.EpitranPhonemConverter(deu_latn)
output = phonem_converter.convertToPhonem('Hallo, das ist ein Test')
self.assertEqual(output, 'haloː, daːs ɪst aɪ̯n tɛst')
trainer_SST_lambda = {'de': pronunciationTrainer.getTrainer("de")}
class TestScore(unittest.TestCase):
def test_exact_transcription(self):
words_real = 'Ich habe sehr viel glück, am leben und gesund zu sein'
real_and_transcribed_words, _, _ = trainer_SST_lambda['de'].matchSampleAndRecordedWords(
words_real, words_real)
pronunciation_accuracy, _ = trainer_SST_lambda['de'].getPronunciationAccuracy(
real_and_transcribed_words)
self.assertEqual(int(pronunciation_accuracy), 100)
def test_incorrect_transcription(self):
words_real = 'Ich habe sehr viel glück, am leben und gesund zu sein'
words_transcribed = 'Ic hab zeh viel guck am und gesund tu sein'
real_and_transcribed_words, _, _ = trainer_SST_lambda['de'].matchSampleAndRecordedWords(
words_real, words_transcribed)
pronunciation_accuracy, _ = trainer_SST_lambda['de'].getPronunciationAccuracy(
real_and_transcribed_words)
self.assertEqual(int(pronunciation_accuracy), 71)
if __name__ == '__main__':
unittest.main()
|