def test_get_engine_for_lang(self): tts = Talkey( espeak={'options': {'enabled': False}}, ) self.assertEqual(tts.get_engine_for_lang('fr').SLUG, 'pico') with self.assertRaisesRegexp(TTSError, 'Could not match language'): tts.get_engine_for_lang('af')
def test_create_weighted(self): tts = Talkey(preferred_languages=['en', 'af']) for txt in self.TXTS: self.assertEqual(txt[0], tts.classify(txt[2])) tts = Talkey(preferred_languages=['en', 'af'], preferred_factor=2.0) self.assertEqual(self.TXTS[2][1], tts.classify(self.TXTS[2][2]))
def test_create_basic(self): tts = Talkey() for txt in self.TXTS: self.assertEqual(txt[1], tts.classify(txt[2])) self.assertEqual(tts.get_engine_for_lang('en').SLUG, 'espeak') tts.say('Old McDonald had a farm') inst, filename, output = LAST_PLAY self.assertIn('WAVE audio', output) self.assertEqual(inst, tts.engines[0]) self.assertFalse(isfile(filename), 'Tempfile not deleted')
def test_create_language_config(self): tts = Talkey(espeak={ 'languages': { 'en': { 'voice': 'english-mb-en1', 'words_per_minute': 130 }, } }, ) eng = tts.engines[0] self.assertEqual(eng.languages_options['en'][0], 'english-mb-en1') self.assertEqual(eng.languages_options['en'][1]['words_per_minute'], 130)
def test_create_empty(self): with self.assertRaisesRegexp(TTSError, 'No supported languages'): Talkey( espeak={'options': { 'enabled': False }}, festival={'options': { 'enabled': False }}, pico={'options': { 'enabled': False }}, flite={'options': { 'enabled': False }}, say={'options': { 'enabled': False }}, )
def test_engine_preference(self): tts = Talkey(engine_preference=['pico']) self.assertEqual(tts.engines[0].SLUG, 'pico') self.assertEqual(tts.engines[1].SLUG, 'espeak')
def test_get_engine_for_lang(self): tts = Talkey(espeak={'options': {'enabled': False}}, ) self.assertEqual(tts.get_engine_for_lang('fr').SLUG, 'pico') with self.assertRaisesRegexp(TTSError, 'Could not match language'): tts.get_engine_for_lang('af')