def test_synthesise_en(self): text = 'Hello, this is Alex, How may i help You?' cfg = { 'Audio': { 'sample_rate': 16000, }, 'TTS': { 'type': 'Google', 'Google': { 'debug': True, 'language': 'en-us', 'preprocessing': as_project_path("resources/tts/prep_google_en.cfg"), 'tempo': 1.0, }, }, } wav_path = '/tmp/google.wav' tts = GoogleTTS(cfg) wav = tts.synthesize(text) audio.save_wav(cfg, wav_path, wav) file = wave.open(wav_path) wav_length = float(file.getnframes()) / file.getframerate() self.assertGreaterEqual(3.5, wav_length) self.assertLessEqual(2.5, wav_length)
def test_synthesise_en(self): text = 'Hello, this is alex, the call is recorded, how may I help You?' cfg = { 'Audio': { 'sample_rate': 16000, }, 'TTS': { 'type': 'VoiceRss', 'VoiceRss': { 'language': 'en-us', 'preprocessing': as_project_path("resources/tts/prep_voicerss_en.cfg"), 'tempo': 1.0, 'api_key': 'ea29b823c83a426bbfe99f4cbce109f6' } } } wav_path = '/tmp/voice_rss_tts.wav' tts = VoiceRssTTS(cfg) wav = tts.synthesize(text) audio.save_wav(cfg, wav_path, wav) file = wave.open(wav_path) wav_length = float(file.getnframes()) / file.getframerate() self.assertEquals(5.292, wav_length)
def test_synthesise_en(self): text = 'Hello, this is Alex, How may i help You?' cfg = { 'Audio': { 'sample_rate': 16000, }, 'TTS': { 'type': 'Google', 'Google': { 'debug': True, 'language': 'en-us', 'preprocessing': as_project_path("resources/tts/prep_google_en.cfg"), 'tempo': 1.0, }, }, } wav_path = '/tmp/google.wav' tts = GoogleTTS(cfg) wav = tts.synthesize(text) audio.save_wav(cfg, wav_path, wav) file = wave.open(wav_path) wav_length = float(file.getnframes()) / file.getframerate() self.assertEquals(3.06, wav_length)
print "Language: ", language print c = { 'TTS': { 'Google': { 'debug': False, 'preprocessing': as_project_path("resources/tts/prep_speechtech_en.cfg"), 'tempo': 1.0, 'language': language } } } cfg = Config.load_configs(log=False) cfg.update(c) tts = GoogleTTS(cfg) print 'calling TTS' wav = tts.synthesize(text) print 'saving the TTS audio in ./tmp/google_tts.wav' audio.save_wav(cfg, './tmp/google_tts.wav', wav) print 'playing audio' audio.play(cfg, wav)
print text = 'Hello. Thank you for calling. ' voice = 'kal' print "Synthesize text:", text print "Voice: ", voice print c = { 'TTS': { 'Flite': { 'debug': False, 'voice': 'kal' } } } cfg = Config.load_configs(log=False) cfg.update(c) tts = FliteTTS(cfg) print 'calling TTS' wav = tts.synthesize(text) print 'saving the TTS audio in ./tmp/flite_tts.wav' audio.save_wav(cfg, './tmp/flite_tts.wav', wav) print 'playing audio' audio.play(cfg, wav)
print "Synthesize text:", text print "Voice: ", voice print c = { "TTS": { "debug": False, "type": "VoiceRss", "VoiceRss": { "language": "en-us", "preprocessing": as_project_path("resources/tts/prep_voicerss_en.cfg"), "tempo": 1.0, "api_key": "ea29b823c83a426bbfe99f4cbce109f6", }, } } cfg = Config.load_configs(log=False) cfg.update(c) tts = VoiceRssTTS(cfg) print "calling TTS" wav = tts.synthesize(text) print "saving the TTS audio in ./tmp/voice_rss_tts.wav" audio.save_wav(cfg, "./tmp/voice_rss_tts.wav", wav) print "playing audio" audio.play(cfg, wav)
print text = 'Hello. Thank you for calling.' language = 'en' print "Synthesize text:", text print "Language: ", language print c = { 'TTS': { 'Google': { 'debug': False, 'language': language } } } cfg = Config.load_configs(log=False) cfg.update(c) tts = GoogleTTS(cfg) print 'calling TTS' wav = tts.synthesize(text) print 'saving the TTS audio in ./tmp/google_tts.wav' audio.save_wav(cfg, './tmp/google_tts.wav', wav) print 'playing audio' audio.play(cfg, wav)
c = { 'TTS': { 'debug': False, 'type': 'VoiceRss', 'VoiceRss': { 'language': 'en-us', 'preprocessing': as_project_path("resources/tts/prep_voicerss_en.cfg"), 'tempo': 1.0, 'api_key': 'ea29b823c83a426bbfe99f4cbce109f6' } } } cfg = Config.load_configs(log=False) cfg.update(c) tts = VoiceRssTTS(cfg) print 'calling TTS' wav = tts.synthesize(text) print 'saving the TTS audio in ./tmp/voice_rss_tts.wav' audio.save_wav(cfg, './tmp/voice_rss_tts.wav', wav) print 'playing audio' audio.play(cfg, wav)
from alex.components.tts.flite import FliteTTS from alex.utils.config import Config if __name__ == '__main__': print "Testing Flite TTS" print "=" * 120 print text = 'Hello. Thank you for calling. ' voice = 'kal' print "Synthesize text:", text print "Voice: ", voice print c = {'TTS': {'Flite': {'debug': False, 'voice': 'kal'}}} cfg = Config.load_configs(log=False) cfg.update(c) tts = FliteTTS(cfg) print 'calling TTS' wav = tts.synthesize(text) print 'saving the TTS audio in ./tmp/flite_tts.wav' audio.save_wav(cfg, './tmp/flite_tts.wav', wav) print 'playing audio' audio.play(cfg, wav)