def RappText2Speech(self, text, language): ch = RappPlatformAPI(address=addr) response = ch.textToSpeech(text, language, RAPPtext2speech_full_path) f = open( RAPPtext2speech_full_path, 'r' ) #at RPi: f = open(RAPPtext2speech_full_path).read() #serializable return f
class TextToSpeechTests(unittest.TestCase): def setUp(self): self.ch = RappPlatformAPI() def test_greek_test(self): destFilePath = '/tmp/ttsClient.wav' response = self.ch.textToSpeech('Καλησπέρα. Είμαι ο ναο', 'el', destFilePath) self.assertEqual(response['error'], u'') self.assertEqual(os.path.getsize(destFilePath) > 0, True) def test_tts_erroneous(self): destFilePath = '/tmp/ttsClient.wav' response = self.ch.textToSpeech(3, 'el', destFilePath) self.assertNotEqual(response['error'], u'') response = self.ch.textToSpeech([], 'el', destFilePath) self.assertNotEqual(response['error'], u'') #response = self.ch.textToSpeech('Καλησπέρα. Είμαι ο ναο', '', destFilePath) #self.assertNotEqual(response['error'], u'') response = self.ch.textToSpeech('Καλησπέρα. Είμαι ο ναο', 3, destFilePath) self.assertNotEqual(response['error'], u'') response = self.ch.textToSpeech('Καλησπέρα. Είμαι ο ναο', [], destFilePath) self.assertNotEqual(response['error'], u'') #response = self.ch.textToSpeech('Καλησπέρα. Είμαι ο ναο', 'el', '') #self.assertNotEqual(response['error'], u'') response = self.ch.textToSpeech('Καλησπέρα. Είμαι ο ναο', 'el', []) self.assertNotEqual(response['error'], u'') response = self.ch.textToSpeech('Καλησπέρα. Είμαι ο ναο', 'el', 3) self.assertNotEqual(response['error'], u'')