def btnpress(self, show, happ=""): try: saythis = { "X": "multiply by", "/": "divide by", "(": "opening bracket", ")": "closing bracket", "00": "double zero", "-": "minus", "+": "plus", "^": "raised to", ".": "point" } say = saythis[show] if show in saythis.keys() else show say = "" if self.ids.sound.text == "Sound : Off" else say tts.speak(say) chk = self.dstack[-1][-1] nums = "1234567890.^-+*X)" print("check : ", chk, "show : ", show[0]) if chk in nums and show[0] not in nums: print("*" + str(show)) self.ids.deqn.text += ("*" + show) if happ == "" else ("*" + happ) print(self.ids.deqn.text) else: self.ids.deqn.text += show if happ == "" else happ except: self.ids.deqn.text += show if happ == "" else happ self.ids.eqn.text += show self.stack.append(self.ids.eqn.text) self.dstack.append(self.ids.deqn.text)
def check_user(self, user, pwd): if pwd.lower() == 'pyconindia': tts.speak('Hello {}. Welcome to Pycon India!'.format(user)) if pwd.lower() == 'funny': tts.speak('Lalu ji ko rabri achi lagti hai') # load screen 2 self.root.current = 'screen 2'
def voz_boton(self, texto): hoy = datetime.date.today() print(hoy) self.ids.txt_Fecha.text = str(hoy) r= sr.Recognizer() #leyenda= self.ids.btn_Producto.text print(texto) try: tts.speak("Ingrese "+texto) #print ("Escuchando") with sr.Microphone() as source: #r.adjust_for_ambient_noise(source) #print("Hable ahora...") audio = r.listen(source) entrada = r.recognize_google(audio, language='es-ES') if (texto=='Nombre'): self.ids.txt_Producto.text = entrada elif(texto=='Precio'): self.ids.txt_Precio.text = entrada elif(texto=='Cantidad'): self.ids.txt_Cantidad.text = entrada except NotImplementedError: popup = ErrorPopup() popup.open() except: print("No entendí o tardó demasiado")
def style(self, style=None, A=None): """Display the aphorism text in a given style""" if int(app.config.get('display', 'bg_enabled')) == 1: app.background_set(app.background_get_random()) if isinstance(A, Aphorism): self.aphorism = A else: A = self.aphorism if style is None: tpl = """\"[b]{aphorism}[/b]\"\n\n -- [i]{author}[/i]""" formatted = tpl.format(aphorism=A.aphorism, author=A.author) self.ids.quote.text = formatted elif style == 'full': tpl = """\"[b]{aphorism}[/b]\"\n\n -- [i]{author}[/i]\n\n{source}""" formatted = tpl.format( aphorism=A.aphorism, author=A.author, source=A.source) self.ids.quote.text = formatted if int(app.config.get('accessibility', 'tts')) == 1 and str(platform) != 'linux': tts.speak("New aphorism.") tts.speak(A.aphorism) tts.speak('spoken by') tts.speak(A.author) tts.speak("End of new aphorism.")
def style(self, style=None, A=None): """Display the aphorism text in a given style""" if int(app.config.get('display', 'bg_enabled')) == 1: app.background_set(app.background_get_random()) if isinstance(A, Aphorism): self.aphorism = A else: A = self.aphorism if style is None: tpl = """\"[b]{aphorism}[/b]\"\n\n -- [i]{author}[/i]""" formatted = tpl.format(aphorism=A.aphorism, author=A.author) self.ids.quote.text = formatted elif style == 'full': tpl = """\"[b]{aphorism}[/b]\"\n\n -- [i]{author}[/i]\n\n{source}""" formatted = tpl.format(aphorism=A.aphorism, author=A.author, source=A.source) self.ids.quote.text = formatted if int(app.config.get('accessibility', 'tts')) == 1 and str(platform) != 'linux': tts.speak("New aphorism.") tts.speak(A.aphorism) tts.speak('spoken by') tts.speak(A.author) tts.speak("End of new aphorism.")
def calculate(self, speak_ans=False): try: eqnn = self.ids.deqn.text eqnn = eqnn.replace("^", "**").replace("/", "*1.0/") while eqnn.count("(") > eqnn.count(")"): eqnn += ")" print(eqnn) Ans = eval(eqnn) print(Ans) self.ids.ans.text = "0" if Ans > 0.000000001 and Ans < -0.000000001 else str( Ans) Ans = str(Ans) Ans = Ans.replace("-", "negative") if Ans[0] == '-' else Ans speak_ans = False if self.ids.sound.text == "Sound : Off" or speak_ans == False else True if speak_ans == True: tts.speak(str(Ans)) except ZeroDivisionError: self.clr_btn() popup = Popup(title='Error !!!', content=Label(text="Dividing by zero Error !!!"), size=(200, 100), size_hint=(None, None)) popup.open() except: self.clr_btn() popup = Popup(title='Error !!!', content=Label(text="Syntax Error !!!"), size=(200, 100), size_hint=(None, None)) popup.open()
def readactivity(self, activity): activity = activity.split("*****") activity = activity[0] msg = str("You are " + activity) try: tts.speak(msg) except NotImplementedError: print "Error!"
def speak(self): print("speech: ", self.text) if (is_debug_mode): lang = "zh-cn" self.speech = Speech(self.text, lang) self.speech.play() else: tts.speak(self.text)
def com_sound_text_to_speech(message_to_speak): """ # text to speech """ try: tts.speak(message_to_speak) except NotImplementedError: pass
def read_intro(self, sb_button): sb_button.disabled = True if self.speak_flag == 0: tts.speak(self.text_label_1) self.speak_flag = 1 self.animation_count = 0 Clock.schedule_once(self.reset_speak_flag, 5) sb_button.disabled = False
def say_something(self, text): try: tts.speak(text) except NotImplementedError: popup = Popup(title='TTS Not Implemented', content=Label(text='Sorry. TTS is not available.'), size_hint=(None, None), size=(300, 300)) popup.open()
def speak(the_text): for txt in the_text: if the_tts is 'pyttsx': TTS.engine.say(txt) if the_tts is 'plyer': tts.speak(txt) time.sleep(float(len(txt)) * 0.05) if the_tts is 'pyttsx': TTS.engine.runAndWait() time.sleep(1)
def say_something(self, text): #subprocess.call(["espeak", text]) try: tts.speak(text) except NotImplementedError: popup = Popup(title='Text-to-Speech not implemented', content=Label(text='Sorry, TTS is not available.'), size_hint=(None, None), size=(300, 300)) popup.open()
def LogInVk(*args): LOGIN, PASSWORD = args global api api = vk.API(vk.AuthSession(app_id = "5649665", user_login = LOGIN, user_password = PASSWORD, scope = '74752'), v = '5.59') #9216 try: tts.speak(u'Добрый день, ' + api.users.get()[0]['first_name']) except: notification.notify(title=u'Error',message=u'Greetings failed!',timeout=2) txt = re.split(r'\n', decode('code')) encode('code', '%s\n%s\n%s\n' %(txt[0], LOGIN, PASSWORD)) return True
def talk(self, words_widget): try: tts.speak(self.text_output.text.encode("utf8") + ".") except NotImplementedError: pass self.text_output.text = "" # update word list if it not in other view if words_widget.__class__.__name__ == "WordList": words = self.word_predictor.getWordList() words_widget.build_list(words)
def speak(the_text, finished=None): for txt in the_text: if the_tts is 'pyttsx': TTS.engine.say(txt) if the_tts is 'plyer': tts.speak(txt) time.sleep(float(len(txt)) * 0.05) if finished: Clock.schedule_once(finished, 0) if the_tts is 'pyttsx': TTS.engine.runAndWait() time.sleep(1) if finished: finished(0.0)
def message(self, msg_type, msg): """Show the message using an icon named after the given type""" self.msg_type = msg_type self.msg = msg if int(app.config.get('accessibility', 'tts')) == 1 and str(platform) != 'linux': tts.speak("New notification. Notification type is " + msg_type) tts.speak('Notification message follows.') tts.speak(msg) tts.speak('End of notification message.') self.icon = 'assets/img/icons/notify/' + msg_type + '.png'
def speak(self, text): """Calls the speech synthesizer. Parameters: text (str): The text to be spoken. Returns: none """ try: tts.speak(text) except NotImplementedError: popup = Popup(title='TTS Not Implemented', content=Label(text='Sorry. TTS is not available.'), size_hint=(None, None), size=(300, 300)) popup.open()
def calspeak(self): saythis, say = { "X": " multiply by ", "/": " divide by ", "(": " opening bracket ", ")": " closing bracket ", "-": " minus ", "+": " plus ", "^": " raised to ", ".": " point " }, "" msg = "value of " + self.ids.eqn.text + " is " + self.ids.ans.text for x in saythis.keys(): msg = msg.replace(x, saythis[x]) for show in msg.split(): say += " " + saythis[show] if show in saythis.keys( ) else " " + show say = "" if self.ids.sound.text == "Sound : Off" else say print(say) tts.speak(say)
def on_touch_down(self, touch): ret, img = self.capture.read() self.capture.release() tts.speak(message="El pastel es una mentira. The cake is a lie")
import json from random import choice import time the_tts = None try: from plyer import tts tts.speak('hello') the_tts = 'plyer' except: pass try: import pyttsx the_tts = 'pyttsx' except: pass class TTS: engine = None what = '' @staticmethod def start(): TTS.engine = None if the_tts is 'pyttsx': TTS.engine = pyttsx.init() TTS.engine.setProperty('voice', 'HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Speech/Voices/Tokens/TTS_MS_EN-US_ZIRA_11.0') TTS.engine.connect(topic='finished-utterance', cb=TTS.finished) @staticmethod
def ola(self, *args): notification.notify('Olá Python Brasil :)') tts.speak( "Hello Python Brazil, " "I'm Plyer's Text to Speech Module. Have fun!")
def _do_speak(self, saythis): try: tts.speak(saythis) except NotImplementedError: Logger.info("Text to Speech is not implemented on this platform.")
import json from random import choice import time from kivy.clock import Clock the_tts = None try: from plyer import tts tts.speak('') the_tts = 'plyer' except: pass try: import pyttsx the_tts = 'pyttsx' except: pass class TTS: engine = None what = '' @staticmethod def start(): TTS.engine = None if the_tts is 'pyttsx': TTS.engine = pyttsx.init() TTS.engine.setProperty( 'voice',
import json from random import choice import time from kivy.clock import Clock the_tts = None try: from plyer import tts tts.speak(message='hello') the_tts = 'plyer' except: pass try: import pyttsx the_tts = 'pyttsx' except: pass class TTS: engine = None what = '' @staticmethod def start(): TTS.engine = None if the_tts is 'pyttsx': TTS.engine = pyttsx.init() TTS.engine.setProperty('voice', 'HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Speech/Voices/Tokens/TTS_MS_EN-US_ZIRA_11.0') TTS.engine.connect(topic='finished-utterance', cb=TTS.finished)
def speak(self, item): tts.speak(item)
def do_speak(event_voice): global text_voice while True: event_voice.wait() tts.speak(text_voice) event_voice.clear()
def talk_back(self,words,*args): tts.speak(str(words))
def run(): try: tts.speak(word) except NotImplementedError: print("error")
def do_read(self): try: tts.speak(self.ids.notification_text.text) except NotImplementedError: popup = ErrorPopup() popup.open()
def beep(data): tts.speak(data)
def check_user(self, user, pwd): if pwd.lower() == 'pyconindia': tts.speak('Hello {}. Welcome to Pycon India!'.format(user)) if pwd.lower() == 'funny': tts.speak('Lalu ji ko rabbri, bahoot pasand hai!')
def speak(self, text): tts.speak(text)
def talk(self, file_path): try: tts.speak(message=self.convert_pdf_to_txt(file_path[0])) except: print 'cant talk'
def read_aloud(self, text, button): button.disabled = True button.state = "down" tts.speak(text) button.disabled = False button.state = "normal"
def talk(self,file_path): try: tts.speak(message=self.convert_pdf_to_txt(file_path[0])) except: print 'cant talk'
def responder(self, *args): self.respWidget.text = self.resp tts.speak(self.resp)
def ler(self, *args): tts.speak(self.txt_entrada.text)