Exemplo n.º 1
0
    def takeNote(self, text):
        '''
        Funció per apuntar una recordatori.
        '''
        n = ""
        y = str(datetime.datetime.now().year)
        m = str(datetime.datetime.now().month)
        d = str(datetime.datetime.now().day)

        for wd in text.split(' '):  # h
            if wd.isdigit():
                d = wd
            elif wd in MONTHS:
                m = str(MONTHS.index(wd) + 1)
        n = text.split("apuntar", 1)[1]
        if "mañana" in text:
            n = text.split("mañana", 1)[1]
            d = str(datetime.datetime.today() +
                    datetime.timedelta(days=1)).split(' ')[0].split('-')[2]
        elif d in text:
            n = text.split(MONTHS[int(m) - 1], 1)[1]
        else:
            n = text.split("apuntar", 1)[1]

        if n != "":
            CN.append(("{}-{}-{}".format(y, m, d), n))
            Ttos().say("Apuntado para el dia {} de {}: {}".format(
                d, MONTHS[int(m) - 1], n))
        else:
            Ttos().say("Lo siento, no te he entendido.")
Exemplo n.º 2
0
 def goodm(self):
     '''
     Funció per saber els recordatoris del dia
     '''
     Ttos().say("Buenos días")
     if CN != []:
         currentdate = str(datetime.datetime.today()).split(' ')[0]
         f = 0
         for n in CN:
             if n[0] == currentdate:
                 if f == 0:
                     Ttos().say("hoy tienes")
                     f = 1
                 Ttos().say(n[1])
     else:
         Ttos().say("hoy no tienes nada pendiente")
Exemplo n.º 3
0
 def currentTime(self):
     '''
     Retorna la hora actual.
     '''
     hms = str(datetime.datetime.today()).split(' ')[1].split(
         ':')  # Llista amb la hora, els minuts i els segons actuals
     return (Ttos().say("Són las {} y {}.".format(hms[0], hms[1])))
Exemplo n.º 4
0
 def cero(self):
     '''
     Funció simulant una de les mítiques respostes de Siri, a la pregunta ¿Cero entre cero?.
     '''
     Ttos().say(
         "Imagínate que tiene cero galletas y las repartes entre cero amigos. ¿Cuántas galletas le tocan a cada amigo? No tiene sentido. ¿Lo ves? Así que el monstruo de las galletas está triste porque no tiene galletas y tú estás triste porque no tienes amigos."
     )
Exemplo n.º 5
0
 def currentDate(self):
     '''
     Retorna la data actual.
     '''
     ydmtd = str(datetime.datetime.today()).split(' ')[0].split(
         '-')  # Llista amb l'any, el mes i el dia d'avuí
     return (Ttos().say("Hoy es {} de {} de {}.".format(
         ydmtd[2], MONTHS[int(ydmtd[1]) - 1], ydmtd[0])))
Exemplo n.º 6
0
 def tomorrowDate(self):
     '''
     Retorna la data de demà
     '''
     ydmtw = str(datetime.datetime.today() +
                 datetime.timedelta(days=1)).split(' ')[0].split(
                     '-')  # Llista amb l'any, el mes i el dia de demà
     return (Ttos().say("Mañana será {} de {} de {}.".format(
         ydmtw[2], MONTHS[int(ydmtw[1]) - 1], ydmtw[0])))
Exemplo n.º 7
0
 def options(self, rec, mic, text):
     '''
     Funció d'anàlisis i filtratge.
     '''
     if "hora" in text:
         Timeop().currentTime()
     elif "buenos días" in text:
         Calendarop().goodm()
     elif ("día" in text) and ("mañana" in text):
         Timeop().tomorrowDate()
     elif "día" in text:
         Timeop().currentDate()
     elif "alarma" in text:
         Timeop().alarm(text)
     elif "apuntar" in text:
         Calendarop().takeNote(text)
     elif "edad" in text:
         Fun().age()
     elif ("cero entre cero" or "cero dividido por cero") in text:
         Fun().cero()
     else:
         Ttos().error()
Exemplo n.º 8
0
#coding=UTF-8
#!/usr/bin/python
from filterop import Filterop
from ttos import Ttos
from repo import ALARM_F, CN
from timeop import Timeop

import speech_recognition as sr

rec = sr.Recognizer()  # Creació instància reconeixedor.
mic = sr.Microphone()  # Creació instància micròfon.

rec.energy_threshold = 90  # Llindar del nivell de so. Valors per sota del llindar es consideren silenci.
rec.pause_threshold = 1  # Llindar de pausa. Minim temps (sec) de silenci per registrar el final d'una frase.

Ttos().intro()  # Introducció de Lima.

while True:  # Inici bucle principal.
    # Detecció de l'hora per fer sonar l'alarma.
    if (ALARM_F[0] == True):
        Ttos().clockalarm()
    elif Timeop().check_alarm():
        ALARM_F[0] = True
        ALARM_F[1] = ""

    try:
        with mic as source:
            print("Ajustant soroll...")
            rec.adjust_for_ambient_noise(
                source,
                duration=0.8)  # Reajustament del soroll. duration (sec)
Exemplo n.º 9
0
 def set_alarm(self, ymd, hour, minute):
     '''
     Activar alarma.
     '''
     ALARM_F[1] = "{} {}:{}".format(ymd, hour, minute)
     Ttos().say("Alarma programada para las {} {}.".format(hour, minute))
Exemplo n.º 10
0
 def age(self):
     '''
     Funció que respon l'edad de Lima
     '''
     Ttos().say("Eso no se le pregunta a una señorita.")