def __init__(self, access_key='', secret_key='', region=None, voice=None, speech_rate=None, sentence_break=None): super(self.__class__, self).__init__() self._pyvonavoice = pyvona.Voice(access_key, secret_key) self._pyvonavoice.codec = "mp3" if region: self._pyvonavoice.region = region if voice: self._pyvonavoice.voice_name = voice if speech_rate: self._pyvonavoice.speech_rate = speech_rate if sentence_break: self._pyvonavoice.sentence_break = sentence_break
def __init__(self, *args, **kwargs): plugin.TTSPlugin.__init__(self, *args, **kwargs) access_key = profile.get(['ivona-tts', 'access_key']) if not access_key: raise ValueError("Ivona access key not configured!") secret_key = profile.get(['ivona-tts', 'secret_key']) if not secret_key: raise ValueError("Ivona secret key not configured!") region = profile.get(['ivona-tts', 'region']) voice = profile.get(['ivona-tts', 'voice']) speech_rate = profile.get(['ivona-tts', 'speech_rate']) try: sentence_break = int(profile.get(['ivona-tts', 'sentence_break'])) except (TypeError, ValueError): sentence_break = None language = profile.get(['language'], "en-US") self._pyvonavoice = pyvona.Voice(access_key, secret_key) self._pyvonavoice.codec = "mp3" if region is not None: self._pyvonavoice.region = region # Use an appropriate voice for the chosen language try: all_voices = json.loads(self._pyvonavoice.list_voices())["Voices"] except TypeError: all_voices = self._pyvonavoice.list_voices()["Voices"] suitable_voices = [v for v in all_voices if v["Language"] == language] if len(suitable_voices) == 0: raise ValueError("Language '%s' not supported" % language) else: if voice is not None and len([v for v in suitable_voices if v["Name"] == voice]) > 0: # Use voice from config self._pyvonavoice.voice_name = voice else: # Use any voice for that language voice = suitable_voices[0]["Name"] self._pyvonavoice.voice_name = voice if speech_rate is not None: self._pyvonavoice.speech_rate = speech_rate if sentence_break is not None: self._pyvonavoice.sentence_break = sentence_break
def __init__(self, logger, profile): self.logger = logger self.profile = profile self.snd_dev = profile['output_device_name'] PHRASES_CACHE_DB = 'cache_phrases_google.db' self.cache = persistent_cache.audioCache(PHRASES_CACHE_DB, logger, 'google', self.snd_dev) #self.cache.listCacheEntries() self.ivona = pyvona.Voice(profile['ivona-tts']['access_key'], profile['ivona-tts']['secret_key']) self.ivona.codec = "mp3" self.ivona.region = profile['ivona-tts']['region'] self.ivona.voice_name = profile['ivona-tts']['voice'] self.ivona.speech_rate = profile['ivona-tts']['speech_rate'] self.ivona.sentence_break = profile['ivona-tts']['sentence_break']
import pyvona import sys filename = "test_ivona.mp3" ivona = pyvona.Voice('GDNAJCB7IGSUWGJE5EWQ', 'tLd1c3R1+3YbXscd6ILnuamY87uTycP2ngeer0S/') ivona.codec = "mp3" ivona.region = 'eu-west' ivona.voice_name = 'Maja' ivona.language = 'pl-PL' ivona.speech_rate = 'medium' ivona.sentence_break = 400 #res = ivona.list_voices() #print res ivona.fetch_voice(sys.argv[1], filename) #ivona.speak(args[1]) #os.system("aplay -D %s %s" % ("plughw:1,0", filename)) #os.system("mpg123 -q --audiodevice= %s %s" % ("plughw:1,0", filename))