def say(self, phrase): #OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav" # alter phrase before speaking self.logger.info(">>>>>>>>>>>>>>>>>>>") self.logger.info("JASPER: " + phrase ) self.logger.info(">>>>>>>>>>>>>>>>>>>") phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) os.system("espeak " + json.dumps(phrase) + OPTIONS) #os.system("aplay -D hw:0,0 say.wav") os.system("aplay say.wav")
def say(self, phrase, translate=False, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): if translate: if langCode != None and langCode != "en-US": self.langCode = "en-US" else: self.langCode = profile["langCode"] else: self.langCode = langCode if self.langCode != None and self.langCode != "en-US": content = phrase.split(" ") result = "" count = 0 length = len(content) try: for word in content: count += 1 if len(result) < 90: result = result + " " + word else: self.googleSpeak(self.langCode, result) result = word if count == length: self.googleSpeak(self.langCode, result) return except: pass # alter phrase before speaking phrase = alteration.clean(phrase) os.system("espeak " + json.dumps(phrase) + OPTIONS ) os.system("aplay say.wav")
def say(self, phrase): #OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav" # alter phrase before speaking self.logger.info(">>>>>>>>>>>>>>>>>>>") self.logger.info("JASPER: " + phrase) self.logger.info(">>>>>>>>>>>>>>>>>>>") phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=None): #phrase = phrase.decode('utf8') #print "JAN: " + phrase self.logger.info(">>>>>>>>>>>>>>>>>>>") self.logger.info("JAN: " + phrase ) self.logger.info(">>>>>>>>>>>>>>>>>>>") phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) os.system("espeak " + json.dumps(phrase) + OPTIONS) os.system("aplay -D hw:1,0 say.wav")
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) os.system("espeak " + json.dumps(phrase) + OPTIONS) os.system(PLAY_CMD.format('say.wav'))
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) if self.wxbot is not None: wechatUser(self.profile, self.wxbot, "%s: %s" % (self.robot_name, phrase), "") self.speaker.say(phrase)
def say(self, phrase, OPTIONS=None): #phrase = phrase.decode('utf8') #print "JAN: " + phrase self.logger.info(">>>>>>>>>>>>>>>>>>>") self.logger.info("JAN: " + phrase) self.logger.info(">>>>>>>>>>>>>>>>>>>") phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking print(phrase) signphrase = phrase.encode('ascii', errors='backslashreplace') self.signs.display(signphrase) phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav", language=None): # alter phrase before speaking phrase = alteration.clean(phrase) if language: self.speaker.say(phrase, language) else: self.speaker.say(phrase)
def generate_audio(self, phrase): # alter phrase before speaking phrase = alteration.clean(phrase) if self.engine == 'espeak': output_file = temp_dir + str(uuid.uuid4()) + ".wav" OPTIONS = self.config.get('Speech', 'espeak_options') + " --stdout > " + output_file os.system("espeak " + json.dumps(phrase) + OPTIONS) return output_file elif self.engine == 'googletranslate': # choose the base uri base_uri = 'http://translate.google.com/translate_tts?tl=en&q=' if self.google_use_uk == True: base_uri = 'http://translate.google.co.uk/translate_tts?tl=en&q=' # split into sub-100 character chunks chunks = textwrap.wrap(phrase, 100) # Make the temp directory (in case it doesn't exist) temp_dir = "../media/temp/" os.system("mkdir -p " + temp_dir) if len(chunks) > 1: # if more than 4 chunks, ask the user for a moment... if len(chunks) > 4: self.say("One moment please") # download each chunk chunk_files = [] for chunk in chunks: download_uri = base_uri + urllib.quote(chunk) output_file = temp_dir + str(uuid.uuid4()) + ".mp3" os.system("wget -U 'Mozilla/5.0' -O " + output_file + " '" + download_uri + "'") chunk_files.append(output_file) # merge and delete each chunk, then fix the tags merged_chunk_file = temp_dir + str(uuid.uuid4()) + ".mp3" for chunk_file in chunk_files: os.system("cat " + chunk_file + " >> " + merged_chunk_file) os.remove(chunk_file) os.system("mp3val -f -nb " + merged_chunk_file) return merged_chunk_file else: # download file download_uri = base_uri + urllib.quote(phrase) output_file = temp_dir + str(uuid.uuid4()) + ".mp3" os.system("wget -U 'Mozilla/5.0' -O " + output_file + " '" + download_uri + "'") return output_file else: # default to espeak output_file = temp_dir + str(uuid.uuid4()) + ".wav" OPTIONS = " -vdefault+m3 -p 40 -s 160 --stdout > " + output_file os.system("espeak " + json.dumps(phrase) + OPTIONS) return output_file
def say(self, phrase, OPTIONS=" -vdefault+f3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) os.system("espeak " + json.dumps(phrase) + OPTIONS) # send phrase to google and it retuns an MP3. we use mpg123 to conver to wav # outfile = open ("say.mp3","w") # GoogleTTSFork.GoogleTTS(phrase,outfile) os.system("aplay -D hw:1,0 say.wav")
def say(self, phrase, OPTIONS=None): #phrase = phrase.decode('utf8') #print "JAN: " + phrase self.logger.info(">>>>>>>>>>>>>>>>>>>") self.logger.info("JASPER: " + phrase) self.logger.info(">>>>>>>>>>>>>>>>>>>") phrase = alteration.clean(phrase) #self.speaker.say(phrase) if self.connection: self.logger.debug('got connection, sending phrase') self.connection.send(chr(len(phrase))) self.connection.sendall(phrase)
def say(self, phrase, OPTIONS=None): #phrase = phrase.decode('utf8') #print "JAN: " + phrase self.logger.info(">>>>>>>>>>>>>>>>>>>") self.logger.info("JASPER: " + phrase ) self.logger.info(">>>>>>>>>>>>>>>>>>>") phrase = alteration.clean(phrase) #self.speaker.say(phrase) if self.connection: self.logger.debug('got connection, sending phrase') self.connection.send(chr(len(phrase))) self.connection.sendall(phrase)
def say(self, phrase, OPTIONS=None): # phrase = phrase.decode('utf8') # print "JAN: " + phrase self.logger.info(">>>>>>>>>>>>>>>>>>>") self.logger.info("JASPER: " + phrase) self.logger.info(">>>>>>>>>>>>>>>>>>>") phrase = alteration.clean(phrase) #self.speaker.say(phrase) self.logger.debug('socket:: sending phrase') self.broadcast_message(phrase) #self.process_writable() self.last_msg = self.process_communication(self.timeout_active)
def say(self, speechType, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) self._logger.transcript('Returned: %r|%r', speechType, phrase) self.speaker.say(phrase) if speechType == 'I': self.db_cursor.execute("INSERT INTO transcript (nikita_id, \ create_timestamp, speech_type, \ speech_text) VALUES (%s, now(), \ %s, %s)", (self.profile['nikita_id'], speechType, phrase)) self.db.commit()
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): cls = self.__class__ # alter phrase before speaking phrase = alteration.clean(phrase) cls.lock.acquire() try: self.speaker.say(phrase) finally: cls.lock.release() if self.phone.on_hook(): raise phone.Hangup()
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) auth_token = get_att_auth_token(profile.get('att_api_client_id'), profile.get('att_api_client_secret')) with open('say.wav', 'wb') as handle: response = requests.post('https://api.att.com/speech/v3/textToSpeech', headers={'Accept': 'audio/x-wav', 'Content-Length': sys.getsizeof(phrase), 'Content-Type': 'text/plain', 'Authorization': 'Bearer %s' % auth_token.get('access_token')}, data=phrase, stream=True) if not response.ok: # fall back onto espeak print(response.text) os.system("espeak " + json.dumps(phrase) + OPTIONS) else: for block in response.iter_content(1024): if not block: break handle.write(block) # os.system("aplay -D hw:1,0 say.wav") play('say.wav')
def say(self, phrase, OPTIONS=None): phrase = alteration.clean(phrase) print("JASPER: %s" % phrase) self.speaker.say(phrase)
def say(self, phrase): # alter phrase before speaking phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=None): print("JASPER: %s" % phrase) phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) self.speaker.say(phrase)
def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 120 --stdout > say.wav"): # alter phrase before speaking phrase = alteration.clean(phrase) os.system("tts " + json.dumps(phrase))