def brain(phrase, ascii_phrase): phrase=phrase ascii_phrase=ascii_phrase if "como se dice" in phrase: text= ' '.join(phrase.split()[3:-2]) language= ascii_phrase.split()[-1] tts.tts_translator(translator.translate(text, language), language) #Después de las 3 primeras palabras (como se dice) hasta la última, el idioma elif "eres" in phrase: return "Mi nombre es VAOS, soy un asistente personal de codigo abierto capaz de reproducir canciones, hacer twits, deletrear palabras, contar chistes, buscar informacion sobre cualquier famoso, hacer operaciones matematicas y mucho mas." elif "musica" in ascii_phrase or "escuchar" in ascii_phrase: music.music(phrase) elif "canta" in ascii_phrase or "cantame" in ascii_phrase or "estoy" in ascii_phrase or "chiste" in ascii_phrase: return profile.tts, gag.gag(phrase) elif "twitter" in phrase or "twittear" in phrase: return twitter.status(phrase) elif "apagar" in ascii_phrase: auto_recognition=False elif "Gloria" in ascii_phrase or "gloria" in ascii_phrase: music.play("gloria.mp3") elif "deletrear" in phrase: print list(ascii_phrase.split()[-1]) return list(ascii_phrase.split()[-1]) elif phrase == "Error": return "La voz no se ha podido reconocer correctamente" else: return knowledge.knowledge(profile.language, profile.wolfram_api, phrase, ascii_phrase)
def brain(phrase, ascii_phrase): phrase = phrase ascii_phrase = ascii_phrase if "como se dice" in phrase: text = ' '.join(phrase.split()[3:-2]) language = ascii_phrase.split()[-1] tts.tts_translator( translator.translate(text, language), language ) #Después de las 3 primeras palabras (como se dice) hasta la última, el idioma elif "eres" in phrase: return "Mi nombre es VAOS, soy un asistente personal de codigo abierto capaz de reproducir canciones, hacer twits, deletrear palabras, contar chistes, buscar informacion sobre cualquier famoso, hacer operaciones matematicas y mucho mas." elif "musica" in ascii_phrase or "escuchar" in ascii_phrase: music.music(phrase) elif "canta" in ascii_phrase or "cantame" in ascii_phrase or "estoy" in ascii_phrase or "chiste" in ascii_phrase: return profile.tts, gag.gag(phrase) elif "twitter" in phrase or "twittear" in phrase: return twitter.status(phrase) elif "apagar" in ascii_phrase: auto_recognition = False elif "Gloria" in ascii_phrase or "gloria" in ascii_phrase: music.play("gloria.mp3") elif "deletrear" in phrase: print list(ascii_phrase.split()[-1]) return list(ascii_phrase.split()[-1]) elif phrase == "Error": return "La voz no se ha podido reconocer correctamente" else: return knowledge.knowledge(profile.language, profile.wolfram_api, phrase, ascii_phrase)
def onPress( self, event ): if self.pressSound.lower( ) != 'off': self.pressingSound.play( ) # if self.pressSound.lower( ) == 'voice': # os.system("milena_say Wybrałeś") # self.pressingSound.play( ) if self.control == 'tracker': if self.pressFlag == False: self.button = event.GetEventObject( ) self.button.SetBackgroundColour( self.selectionColour ) self.pressFlag = True self.Update() self.label = event.GetEventObject( ).GetName( ).encode( 'utf-8' ) self.stoper.Start( 0.15 * self.timeGap ) if self.label == 'PISAK': if self.pressSound.lower() == 'voice': self.pisakSound.play() self.stoper.Stop( ) time.sleep( 1 ) self.Hide( ) self.Update( ) self.mousePosition = self.winWidth - self.xBorder/2., self.winHeight - self.yBorder/2. self.mouseCursor.move( *self.mousePosition ) os.system("pisak") self.mousePosition = self.winWidth - 100 - self.xBorder, self.winHeight - 100 - self.yBorder self.mouseCursor.move( *self.mousePosition ) self.Show() self.SetFocus() self.stoper.Start( 0.15 * self.timeGap ) elif self.label == 'EXERCISES': if self.pressSound.lower() == 'voice': self.zadanieSound.play() exercise.exercise( self, id = -1 ).Show( True ) self.Hide( ) elif self.label == 'AKTUALIZACJE': if self.pressSound.lower() == 'voice': self.aktualizujSound.play() # cmd = "cd " + self.home + ".pisak && git pull --dry-run | grep -q -v 'Already up-to-date.' && changed=1" # p = Popen( cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True ) # output = p.stdout.read( ) # if output[:5] == "fatal": # os.system("milena_say Brak połączenia z repozytorium zewnętrznym") # elif len(output) == 0: # os.system("milena_say Brak aktualizacji") # else: # os.system("cd " + self.home + ".pisak && git pull") # os.system("milena_say Zaktualizowano pisaka") # with open( self.home + ".pisak/message", 'r' ) as f: # for line in f: # if line.strip(): # os.system( "milena_say %s " % line ) # # blog.blog( parent = self, id = -1 ).Show( True ) # # self.Hide( ) os.system("milena_say Do poprawienia") pass elif self.label == 'MUSIC': if self.pressSound.lower() == 'voice': self.muzykaSound.play() music.music( self, id = -1 ).Show( True ) self.Hide( ) elif self.label == 'AUDIOBOOK': if self.pressSound.lower() == 'voice': self.audiobookSound.play() audiobook.audiobook( self, id = -1 ).Show( True ) self.Hide( ) elif self.label == 'MOVIES': if self.pressSound.lower() == 'voice': self.filmSound.play() movie.movie( self, id = -1 ).Show( True ) self.Hide( ) elif self.label == 'RADIO': if self.pressSound.lower() == 'voice': self.radioSound.play() if self.internet_on(): radio.radio( parent = self, id = -1 ).Show( True ) self.Hide( ) else: os.system("milena_say Brak połączenia z internetem. Proszę podłączyć komputer do sieci.") elif (self.label == 'NOWE'): if self.pressSound.lower() == 'voice': self.noweSound.play() nowe.nowe( parent = self, id = -1).Show( True ) self.Hide( ) elif (self.label == 'PUSTE'): if self.pressSound.lower() == 'voice': self.pusteSound.play() pass else: self.numberOfPresses += 1 self.countRows = 0 if self.numberOfPresses == 1: if self.flag == 'rest': self.flag = 'row' self.rowIteration = 0 self.colIteration = 0 self.countRows = 0 elif self.flag == 'row': if self.pressSound == "voice": if (self.rowIteration == 1): self.oneSound.play() if (self.rowIteration == 2): self.twoSound.play() if (self.rowIteration == 3): self.threeSound.play() buttonsToHighlight = range( ( self.rowIteration - 1 ) * self.numberOfColumns[ 0 ], ( self.rowIteration - 1 ) * self.numberOfColumns[ 0 ] + self.numberOfColumns[ 0 ] ) for button in buttonsToHighlight: item = self.sizer.GetItem( button ) b = item.GetWindow( ) b.SetBackgroundColour( self.selectionColour ) b.SetFocus( ) self.Update() self.stoper.Stop( ) time.sleep( self.selectionTime/1000. ) self.stoper.Start( self.timeGap ) self.flag = 'columns' self.colIteration = 0 elif self.flag == 'columns': self.position = ( self.rowIteration - 1 ) * self.numberOfColumns[ 0 ] + self.colIteration - 1 item = self.sizer.GetItem( self.position ) selectedButton = item.GetWindow( ) selectedButton.SetBackgroundColour( self.selectionColour ) selectedButton.SetFocus( ) self.Update( ) label = self.labels[ self.position ] if label == 'PISAK': if self.pressSound.lower() == 'voice': self.pisakSound.play() # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.pisakSound.play( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.stoper.Start( self.timeGap ) self.stoper.Stop() self.Hide() self.Update() self.mousePosition = self.winWidth - self.xBorder/2., self.winHeight - self.yBorder/2. self.mouseCursor.move( *self.mousePosition ) os.system("pisak") self.mousePosition = self.winWidth - 4 - self.xBorder, self.winHeight - 30 - self.yBorder self.mouseCursor.move( *self.mousePosition ) self.Show() self.SetFocus() self.stoper.Start( self.timeGap ) elif label == 'EXERCISES': if self.pressSound.lower() == 'voice': self.zadanieSound.play() # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.zadanieSound.play( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.stoper.Start( self.timeGap ) self.stoper.Stop( ) exercise.exercise( self, id = -1 ).Show( True ) self.Hide( ) elif label == 'AKTUALIZACJE': if self.pressSound.lower() == 'voice': self.aktualizujSound.play() if self.output[:5] == "fatal": os.system("milena_say Brak połączenia z repozytorium zewnętrznym. Prawdopodbnie nie jesteś połączony z internetem.") elif len(self.output) == 0: os.system("milena_say Brak aktualizacji") else: os.system("cd " + self.home + "ap-dist && git pull") os.system("milena_say Zaktualizowano pisaka") with open(self.path + "read", 'a+') as f: readMessages = f.read() readMessages = readMessages.replace("\n", " ") messages = [] for item in os.listdir( self.configurationPath+"messages/"): if ("message" in item) and (item not in readMessages): with open(self.configurationPath+"messages/"+item, 'r') as f: messages.append( f.read().replace("\n", " ") ) with open(self.path + "read", 'a+') as f: f.write(item+'\n') lenght = len(messages) if lenght == 0: os.system("milena_say Nie masz żadnych wiadomości.") if lenght == 1: os.system("milena_say Masz jedną wiadomość.") os. system("milena_say %s" % messages[0]) else: os.system("milena_say Masz %i wiadomości" % lenght) for (i, j) in enumerate(messages, start=1): os.system("milena_say Wiadomość numer %i." % i) os.system("milena_say %s" % j) cmd = "cd " + self.home + "ap-dist && git pull --dry-run | grep -q -v 'Already up-to-date.' && changed=1" p = Popen( cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True ) self.output = p.stdout.read( ) self.color = self.backgroundColour self.Update( ) # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.blogSound.play( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000*2) ) # self.stoper.Start( self.timeGap ) # self.stoper.Stop( ) # blog.blog( parent = self, id = -1 ).Show( True ) # self.Hide( ) elif label == 'MUSIC': if self.pressSound.lower() == 'voice': self.muzykaSound.play() # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.muzykaSound.play( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.stoper.Start( self.timeGap ) self.stoper.Stop( ) music.music( self, id = -1 ).Show( True ) self.Hide( ) elif label == 'AUDIOBOOK': if self.pressSound.lower() == 'voice': self.audiobookSound.play() # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.stoper.Start( self.timeGap ) self.stoper.Stop( ) audiobook.audiobook( self, id = -1 ).Show( True ) self.Hide( ) elif label == 'MOVIES': if self.pressSound.lower() == 'voice': self.flimSound.play() # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.filmSound.play( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.stoper.Start( self.timeGap ) self.stoper.Stop( ) movie.movie( self, id = -1 ).Show( True ) self.Hide( ) elif label == 'RADIO': if self.pressSound.lower() == 'voice': self.radioSound.play() # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.radioSound.play( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.stoper.Start( self.timeGap ) if self.internet_on(): self.stoper.Stop( ) radio.radio( parent = self, id = -1 ).Show( True ) self.Hide( ) else: os.system("milena_say Brak połączenia z internetem. Proszę podłączyć komputer do sieci.") elif label == 'NOWE': if self.pressSound.lower() == 'voice': self.noweSound.play() # self.stoper.Stop( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # # self.filmSound.play( ) # time.sleep( ( self.selectionTime + self.timeGap )/(1000.*2) ) # self.stoper.Start( self.timeGap ) self.stoper.Stop( ) nowe.nowe( self, id = -1 ).Show( True ) self.Hide( ) elif (label == 'PUSTE'): if self.pressSound.lower() == 'voice': self.pusteSound.play() pass self.flag = 'row' self.rowIteration = 0 self.colIteration = 0 self.countColumns = 0 self.countRows = 0 else: pass
def onPress(self, event): self.numberOfPresses += 1 self.countRows = 0 if self.numberOfPresses == 1: if self.flag == 'rest': self.flag = 'row' self.rowIteration = 0 self.colIteration = 0 self.countRows = 0 elif self.flag == 'row': buttonsToHighlight = range( ( self.rowIteration - 1 ) * self.numberOfColumns[ 0 ], ( self.rowIteration - 1 ) * self.numberOfColumns[ 0 ] + self.numberOfColumns[ 0 ] ) for button in buttonsToHighlight: item = self.sizer.GetItem( button ) b = item.GetWindow( ) b.SetBackgroundColour( self.selectionColour ) b.SetFocus( ) self.flag = 'columns' self.colIteration = 0 elif self.flag == 'columns': self.position = ( self.rowIteration - 1 ) * self.numberOfColumns[ 0 ] + self.colIteration - 1 item = self.sizer.GetItem( self.position ) selectedButton = item.GetWindow( ) selectedButton.SetBackgroundColour( self.selectionColour ) selectedButton.SetFocus( ) self.Update( ) label = self.labels[ self.position ] if label == 'SPELLER': self.stoper.Stop( ) speller.speller( parent = self, id = -1 ).Show( True ) self.Hide( ) elif label == 'BOOKS': self.stoper.Stop( ) book.book( self, id = -1 ).Show( True ) self.Hide( ) elif label == 'AUDIOBOOKS': self.stoper.Stop( ) audiobook.audiobook( parent = self, id = -1 ).Show( True ) self.Hide( ) elif label == 'MUSIC': self.stoper.Stop( ) music.music( self, id = -1 ).Show( True ) self.Hide( ) elif label == 'MOVIES': self.stoper.Stop( ) movie.movie( self, id = -1 ).Show( True ) self.Hide( ) elif label == 'RADIO': self.stoper.Stop( ) radio.radio( parent = self, id = -1 ).Show( True ) self.Hide( ) self.flag = 'row' self.rowIteration = 0 self.colIteration = 0 self.countColumns = 0 self.countRows = 0 else: pass
def onPress(self, event): self.numberOfPresses += 1 self.countRows = 0 if self.numberOfPresses == 1: if self.flag == 'rest': self.flag = 'row' self.rowIteration = 0 self.colIteration = 0 self.countRows = 0 elif self.flag == 'row': buttonsToHighlight = range( (self.rowIteration - 1) * self.numberOfColumns[0], (self.rowIteration - 1) * self.numberOfColumns[0] + self.numberOfColumns[0]) for button in buttonsToHighlight: item = self.sizer.GetItem(button) b = item.GetWindow() b.SetBackgroundColour(self.selectionColour) b.SetFocus() self.flag = 'columns' self.colIteration = 0 elif self.flag == 'columns': self.position = ( self.rowIteration - 1) * self.numberOfColumns[0] + self.colIteration - 1 item = self.sizer.GetItem(self.position) selectedButton = item.GetWindow() selectedButton.SetBackgroundColour(self.selectionColour) selectedButton.SetFocus() self.Update() label = self.labels[self.position] if label == 'SPELLER': self.stoper.Stop() speller.speller(parent=self, id=-1).Show(True) self.Hide() elif label == 'BOOKS': self.stoper.Stop() book.book(self, id=-1).Show(True) self.Hide() elif label == 'AUDIOBOOKS': self.stoper.Stop() audiobook.audiobook(parent=self, id=-1).Show(True) self.Hide() elif label == 'MUSIC': self.stoper.Stop() music.music(self, id=-1).Show(True) self.Hide() elif label == 'MOVIES': self.stoper.Stop() movie.movie(self, id=-1).Show(True) self.Hide() elif label == 'RADIO': self.stoper.Stop() radio.radio(parent=self, id=-1).Show(True) self.Hide() self.flag = 'row' self.rowIteration = 0 self.colIteration = 0 self.countColumns = 0 self.countRows = 0 else: pass