def say(self, text): phrases = [text] filenames = [] if len(text) > self.PHRASE_LENGTH: phrases = split_text(text, self.PHRASE_LENGTH) voice = self._voice debiase = False if 'debias' in text.lower() or 'debiac' in text.lower(): debiase = True voice = 'it-IT_FrancescaVoice' voice_prefix = '<voice-transformation type="Custom" glottal_tension="{gt}%" breathiness="{b}%" pitch="{p}%" pitch_range="{pr}%" rate="{r}%" strength="{s}%">'\ .format(gt=random.randint(-99, 99), b=random.randint(-99, 99), p=random.randint(-99, 99), pr=random.randint(-99, 99), r=random.randint(-99, 99), s=random.randint(-99, 99)) for phrase in phrases: hsh = sha256() hsh.update(phrase.lower() + voice) filename = 'speech/%s.wav' % hsh.hexdigest() if not debiase: phrase = voice_prefix + phrase + '</voice-transformation>' self.create_sound_file(filename, phrase, voice) filenames.append(filename) for filename in filenames: SoundPlayer(config['wav_player']).play_sound(filename)
def say(self, text): phrases = [text] filenames = [] if len(text) > 100: phrases = split_text(text, 100) for phrase in phrases: hsh = sha256() hsh.update(phrase.lower() + self.TTS_VOICE + self.TTS_TEMPO) filename = 'speech/%s.wav' % hsh.hexdigest() self.create_sound_file(filename, phrase) filenames.append(filename) for filename in filenames: SoundPlayer(config['wav_player']).play_sound(filename)
def say(self, text): phrases = [text] filenames = [] text = text.lower() if len(text) > self.PHRASE_LENGTH: phrases = split_text(text, self.PHRASE_LENGTH) voice = self._voice voice_prefix = self._voice_prefix if 'kyle' in text: phrases = [r'Kyle is a programmer god.'] voice_prefix = '<voice-transformation type="Custom" strength="100%" breathiness="-100%" glottal_tension="100%" rate="-100%">' elif re.search(r'debia(s|cc)e', text): voice = 'it-IT_FrancescaVoice' voice_prefix = '' elif re.search(r'(volkswagen|audi|porsche|bmw|mercedes|benz)', text): voice = 'de-DE_DieterVoice' voice_prefix = '' elif 'godzilla' in text: voice = 'ja-JP_EmiVoice' voice_prefix = '' elif re.search(r'(hola|gracias|amigo)', text): voice = 'es-US_SofiaVoice' voice_prefix = '' elif re.search(r'ja(ke|cob)', text): voice = 'en-US_LisaVoice' voice_prefix = '<voice-transformation type="Custom" glottal_tension="60%" breathiness="-30%" pitch="-50%" pitch_range="35%" rate="-30%">' elif 'dan' in text: voice_prefix = '<voice-transformation type="Custom" strength="100%" pitch="-100%" pitch_range="20%" breathiness="20%" glottal_tension="-100%" rate="-100%">' elif 'johnny' in text: voice_prefix = '<voice-transformation type="Custom" strength="-30%" pitch="100%" pitch_range="100%" breathiness="-30%" glottal_tension="70%" rate="-30%" timbre="Breeze" timbre_extent="50%">' elif 'accounts payable' in text: voice_prefix = '<voice-transformation type="Custom" pitch="65%" pitch_range="99%" rate="20%">' for phrase in phrases: hsh = sha256('{}{}{}'.format(phrase.lower(), voice, voice_prefix)).hexdigest() filename = 'speech/%s.wav' % hsh if voice_prefix: phrase = '{}{}</voice-transformation>'.format( voice_prefix, phrase) self.create_sound_file(filename, phrase, voice) filenames.append(filename) for filename in filenames: SoundPlayer(config['wav_player']).play_sound(filename)
def say(self, text): phrases = [text] filenames = [] text = text.lower() if len(text) > self.PHRASE_LENGTH: phrases = split_text(text, self.PHRASE_LENGTH) voice = self._voice voice_prefix = self._voice_prefix if 'kyle' in text: phrases = [r'Kyle is a programmer god.'] voice_prefix = '<voice-transformation type="Custom" strength="100%" breathiness="-100%" glottal_tension="100%" rate="-100%">' elif re.search(r'debia(s|cc)e', text): voice = 'it-IT_FrancescaVoice' voice_prefix = '' elif re.search(r'(volkswagen|audi|porsche|bmw|mercedes|benz)', text): voice = 'de-DE_DieterVoice' voice_prefix = '' elif 'godzilla' in text: voice = 'ja-JP_EmiVoice' voice_prefix = '' elif re.search(r'(hola|gracias|amigo)', text): voice = 'es-US_SofiaVoice' voice_prefix = '' elif re.search(r'ja(ke|cob)', text): voice = 'en-US_LisaVoice' voice_prefix = '<voice-transformation type="Custom" glottal_tension="60%" breathiness="-30%" pitch="-50%" pitch_range="35%" rate="-30%">' elif 'dan' in text: voice_prefix = '<voice-transformation type="Custom" strength="100%" pitch="-100%" pitch_range="20%" breathiness="20%" glottal_tension="-100%" rate="-100%">' elif 'johnny' in text: voice_prefix = '<voice-transformation type="Custom" strength="-30%" pitch="100%" pitch_range="100%" breathiness="-30%" glottal_tension="70%" rate="-30%" timbre="Breeze" timbre_extent="50%">' elif 'accounts payable' in text: voice_prefix = '<voice-transformation type="Custom" pitch="65%" pitch_range="99%" rate="20%">' for phrase in phrases: hsh = sha256('{}{}{}'.format(phrase.lower(), voice, voice_prefix)).hexdigest() filename = 'speech/%s.wav' % hsh if voice_prefix: phrase = '{}{}</voice-transformation>'.format(voice_prefix, phrase) self.create_sound_file(filename, phrase, voice) filenames.append(filename) for filename in filenames: SoundPlayer(config['wav_player']).play_sound(filename)
def say(self, text): if len(text) > 100: phrases = split_text(text, 100) for phrase in phrases: self.say(phrase) return text = quote_plus(text.encode("utf-8")) hsh = sha256() hsh.update(text.lower()) filename = "speech/%s.mp3" % hsh.hexdigest() self.get_file(filename, self.url_string % (text)) s = SoundPlayer() s.play_sound(filename)
def say(self, text): if len(text) > 100: phrases = split_text(text, 100) for phrase in phrases: self.say(phrase) return text = quote_plus(text.encode("utf-8")) filename = "speech/%s.mp3" % text if not os.path.isfile(filename): f = open(filename, "w") subprocess.call( ['curl','-A Mozilla', self.url_string % (text)], stdout=f) s = SoundEffect() s.play_sound(filename)