示例#1
0
    def __init__(self, voicesynthetizer):

        self.modulename = 'VoiceCommand'
        self.output = ""
        self.voicesynthetizer = voicesynthetizer
        self.voicerecognition = VoiceRecognition(self.voicesynthetizer)

        self.clock = Clock(voicesynthetizer)
        self.identification = Identification(voicesynthetizer)
        self.weather = Weather(self.voicesynthetizer)
示例#2
0
文件: config.py 项目: chirtz/i3stuff
class Config:
    """
    User configuration
    Here, the status bar items and update intervals are defined
    """
    UPDATE_INTERVAL = 1
    bar_items = [
        Network("eno1", interval=30),
        Volume(),
        Clock(interval=5),
        SimpleText(Tools.sym(""), on_clicked=logout),
    ]
示例#3
0
def main(fullscreen, resolution):
    logging.info('Started the mirror')
    logging.info('Loading modules')

    pygame.init()
    mode = 0
    if fullscreen:
        logging.info('Launching in full screen mode')
        mode = pygame.FULLSCREEN
        resolution = [0, 0]
    screen = pygame.display.set_mode(resolution, mode)
    screen.fill(COLORS['black'])

    modules = [
        Weather(),
        Clock(),
        Birthday(),
        Calendar(),
        Vasttrafik(),
        SystemInfo(),
    ]
    try:
        # Check if vcgencmd is installed, to see if it is running on a
        # raspberry pi with the requires software installed
        call("vcgencmd")
        # modules.append(DisplayOnOff())
    except FileNotFoundError:
        pass

    for module in modules:
        module.start()

    pygame.mouse.set_visible(MOUSE_VISIBLE)
    try:
        while True:
            screen.fill(COLORS['black'])
            for module in modules:
                data = module.data
                for surface, position in data:
                    screen.blit(surface, position)
            pygame.display.flip()
            # pygame.image.save(screen, 'screen_shot.jpg')
            sleep(1)
            if check_if_exit():
                return
    finally:
        logging.info('Stopping all threads')
        for module in modules:
            module.stop()
        logging.info('Stopped all threads')
示例#4
0
    def __init__(self, voicesynthetizer):

        self.modulename = 'Assistant'
        self.running = True
	self.introduced = False
        self.threads = []
	self.voicesynthetizer = voicesynthetizer

	self.voicerecognition = VoiceRecognition(self.voicesynthetizer)
	self.voicemail = VoiceMail(self.voicesynthetizer)
        self.clock = Clock(voicesynthetizer)
        self.identification = Identification(voicesynthetizer)
        self.weather = Weather(self.voicesynthetizer)
        self.messages = Messages(self.voicesynthetizer)
        self.seismology = Seismology(self.voicesynthetizer)
示例#5
0
文件: cycle.py 项目: derblub/pixelpi
    def __init__(self, screen, gamepad, location, interval=int(S.get('animations', 'show'))):
        super(Cycle, self).__init__(screen)

        self.gamepad = gamepad
        if gamepad is not None:
            self.gamepad.on_press.append(self.key_press)
        self.paused = False

        self.subfolders = self.load_subfolders(location)

        self.animations = [None for i in range(len(self.subfolders))]

        self.show_clock = True if S.get('others', 'clock_while_cycle').lower() == 'true' else False
        self.play_count = 1
        if self.show_clock:
            self.clock = Clock(screen)

        self.interval = interval

        self.history = []
        self.history_position = -1
        self.next_animation = time.time()
示例#6
0
    def modules_setup(self):

        # Production Modules
        self.aprstracker = AprsTracker(self.voicesynthetizer)
        self.aprstt = Aprstt(self.voicesynthetizer)
        self.clock = Clock(self.voicesynthetizer)
        self.identification = Identification(self.voicesynthetizer)
        self.meteorology = Meteorology(self.voicesynthetizer)
        self.news = News(self.voicesynthetizer)
        self.selfie = Selfie(self.voicesynthetizer)
        self.voicecommand = VoiceCommand(self.voicesynthetizer)
        self.voicemail = VoiceMail(self.voicesynthetizer)
        self.weather = Weather(self.voicesynthetizer)
        self.wolframalpha = WolframAlpha(self.voicesynthetizer)

        # Experimental Modules
        self.assistant = Assistant(self.voicesynthetizer)
        self.messages = Messages(self.voicesynthetizer)
        self.morseteacher = MorseTeacher(self.voicesynthetizer)
        self.seismology = Seismology(self.voicesynthetizer)
        self.sstv = SSTV(self.voicesynthetizer)
        self.voiceapp = VoiceApp(self.voicesynthetizer)
        self.voiceexperimental = VoiceExperimental(self.voicesynthetizer)
        self.voicemailer = VoiceMailer(self.voicesynthetizer)
示例#7
0
class Assistant(object):

    def __init__(self, voicesynthetizer):

        self.modulename = 'Assistant'
        self.running = True
	self.introduced = False
        self.threads = []
	self.voicesynthetizer = voicesynthetizer

	self.voicerecognition = VoiceRecognition(self.voicesynthetizer)
	self.voicemail = VoiceMail(self.voicesynthetizer)
        self.clock = Clock(voicesynthetizer)
        self.identification = Identification(voicesynthetizer)
        self.weather = Weather(self.voicesynthetizer)
        self.messages = Messages(self.voicesynthetizer)
        self.seismology = Seismology(self.voicesynthetizer)

    def demo1(self):
	self.introduction1()
	self.command()

    def demo2(self):
	self.introduction2()
	self.command()

    def introduction1(self):
        self.voicesynthetizer.speechit("Hola! Dime como puedo ayudarte?")
        self.introduced = True

    def introduction2(self):
	while True:
	        self.voicerecognition.record('5')
	        output = self.voicerecognition.recognize('False')
	        if re.search(r'hola', output, re.M|re.I) or re.search(r'nu', output, re.M|re.I):
	            self.voicesynthetizer.speechit("Hola! Dime como puedo ayudarte?")
		    self.introduced = True
		    break

    def command(self):
	while self.introduced:
		self.voicerecognition.record()
	        output = self.voicerecognition.recognize('False')
 	        if re.search(r'identif', output, re.M|re.I):
		    print '[NuupXe] Assistant Identification'
	            self.identification.identify()
	        elif re.search(r'hora', output, re.M|re.I) or re.search(r'ora', output, re.M|re.I) :
	            print '[NuupXe] Assistant Hour'
	            self.clock.hour()
	        elif re.search(r'fecha', output, re.M|re.I):
	            print '[NuupXe] Assistant Date'
	            self.clock.date()
	        elif re.search(r'reporte', output, re.M|re.I) or re.search(r'clima', output, re.M|re.I):
	            print '[NuupXe] Assistant Weather'
	            self.weather.report()
	        elif re.search(r'estaciones', output, re.M|re.I) or re.search(r'repetidores', output, re.M|re.I):
	            print '[NuupXe] Assistant Stations'
	            self.messages.stations()
	        elif re.search(r'sismo', output, re.M|re.I):
	            print '[NuupXe] Assistant Seismic'
	            self.seismology.SismologicoMX()
	        elif re.search(r'mensaje', output, re.M|re.I) or re.search(r'avis', output, re.M|re.I):
	            print '[NuupXe] Assistant Message'
		    if self.voicemail.status:
			    self.voicesynthetizer.speechit("Mensaje existente!")
			    while True:
				    self.voicesynthetizer.speechit("Quieres escucharlo, borrarlo o salir de esta opcion")
			            self.voicerecognition.record()
		        	    output = self.voicerecognition.recognize('False')
				    if re.search(r'escuchar', output, re.M|re.I):
					    print '[NuupXe] Assistant Message Play'
					    self.voicemail.play()
				    elif re.search(r'borrar', output, re.M|re.I):
					    print '[NuupXe] Assistant Message Erase'
					    self.voicemail.erase()
				    elif re.search(r'salir', output, re.M|re.I):
					    print '[NuupXe] Assistant Message Quit'
					    self.voicesynthetizer.speechit("Saliendo de Opcion Mensaje")
					    break
		    else:
		            self.voicemail.record()
		            self.voicemail.play()
	        elif re.search(r'dormir', output, re.M|re.I):
	            print '[NuupXe] Assistant Sleep'
		    self.voicesynthetizer.speechit("Perfecto! Gracias! Dormire por los proximos 30 segundos")
		    sleep(30)
		    self.voicesynthetizer.speechit("Ya desperte! Que rica siesta!")
		elif re.search(r'eventos', output, re.M|re.I):
		    print '[NuupXe] Assistant Bye'
		    self.voicesynthetizer.speechit("El radioclub tiene 2 eventos proximos")
		    self.voicesynthetizer.speechit("Boletin Tecnologico, Miercoles, 8:00 pm")
		    self.voicesynthetizer.speechit("Junta Mensual, Jueves 8:00 pm, recuerda traer galletas")
		elif re.search(r'nada', output, re.M|re.I) or re.search(r'dios', output, re.M|re.I) or re.search(r'ativo', output, re.M|re.I):
		    print '[NuupXe] Assistant Bye'
		    self.voicesynthetizer.speechit("Hasta pronto!")
	            self.running = False
		    break
        	else:
	            print '[NuupXe] Assistant? Unknown!'

		self.voicesynthetizer.speechit("Se ofrece algo mas?")

    def foo(self):
        while(self.running):
            print '[NuupXe] Assistante | Foo Hello'
            sleep(5)

    def get_user_input(self):
        while True:
            x = raw_input("Tupe any text, Enter 'e' for exit: ")
            if x.lower() == 'e':
               self.running = False
               break
	    else:
	       self.voicesynthetizer.speechit(x)

    def twitter(self):
	return
	self.twitterc = TwitterC('twython')
	self.oldstatus = ''
	self.newstatus = ''
	
	while (self.running):
            print '[NuupXe] Assistante | Twitter Hello'
	    #self.voicesynthetizer.speechit("Veamos")
	    tstatus = self.twitterc.timeline_get('xe1gyq', 1)
	    for status in tstatus:
	        self.newstatus = status['text']
		if self.newstatus != self.oldstatus:
			self.oldstatus = self.newstatus
			self.voicesynthetizer.speechit("Nuevo mensaje en cuenta de Twitter!")
			self.voicesynthetizer.speechit(self.newstatus)
	    sleep(5)

    def go(self):
        t1 = threading.Thread(target=self.foo)
        t2 = threading.Thread(target=self.get_user_input)
	t3 = threading.Thread(target=self.twitter)
	t4 = threading.Thread(target=self.demo1)
        # Make threads daemonic, i.e. terminate them when main thread
        # terminates. From: http://stackoverflow.com/a/3788243/145400
        t1.daemon = True
        t2.daemon = True
	t3.daemon = True
	t4.daemon = True
        t1.start()
        t2.start()
	t3.start()
	t4.start()
        self.threads.append(t1)
        self.threads.append(t2)
	self.threads.append(t3)
	self.threads.append(t4)
示例#8
0
文件: cycle.py 项目: derblub/pixelpi
class Cycle(Module):
    def __init__(self, screen, gamepad, location, interval=int(S.get('animations', 'show'))):
        super(Cycle, self).__init__(screen)

        self.gamepad = gamepad
        if gamepad is not None:
            self.gamepad.on_press.append(self.key_press)
        self.paused = False

        self.subfolders = self.load_subfolders(location)

        self.animations = [None for i in range(len(self.subfolders))]

        self.show_clock = True if S.get('others', 'clock_while_cycle').lower() == 'true' else False
        self.play_count = 1
        if self.show_clock:
            self.clock = Clock(screen)

        self.interval = interval

        self.history = []
        self.history_position = -1
        self.next_animation = time.time()

    @staticmethod
    def load_subfolders(location):
        if not location.endswith('/'):
            location += '/'

        if not os.path.exists(location):
            raise Exception("Path " + location + " not found")
        subfolders = [x[0] for x in os.walk(location)]

        subfolders = subfolders[1:]

        if len(subfolders) == 0:
            raise Exception("No animations found in " + location)

        return subfolders

    def get_current_animation(self):
        if self.history_position < 0:
            return None

        index = self.history[self.history_position]
        if self.animations[index] is None:
            self.animations[index] = Animation(self.screen, self.subfolders[index])
        return self.animations[index]

    def next(self, pick_random):
        if self.get_current_animation() is not None:
            self.get_current_animation().stop()

        if self.show_clock and self.play_count == int(S.get('others', 'clock_every')):
            self.play_count = 0
            start_new_thread(self.clock.start, ())
            print "showing clock"
            time.sleep(1)
            self.clock.stop()
        else:

            if self.history_position < len(self.history) - 1:
                self.history_position += 1
                # index = self.history[self.history_position]
            else:
                if pick_random:
                    index = random.randint(0, len(self.animations) - 1)
                    self.history_position += 1
                else:
                    index = (self.history[self.history_position] + 1) % len(self.animations)
                    self.history_position += 1
                self.history.append(index)

            self.get_current_animation().start()

    def tick(self):
        if not self.paused and time.time() > self.next_animation:
            self.next(pick_random=True)
            self.next_animation += self.interval
            self.play_count += 1
        time.sleep(0.1)

    def on_stop(self):
        if self.get_current_animation() is not None:
            self.get_current_animation().stop()

    def key_press(self, key):
        if key == self.gamepad.RIGHT:
            self.next(pick_random=False)
        if key == self.gamepad.LEFT:
            if self.history_position > 0:
                self.get_current_animation().stop()
                self.history_position -= 1
                self.get_current_animation().start()
        if key == self.gamepad.START:
            self.paused = not self.paused
            if not self.paused:
                self.next_animation = time.time() + self.interval
                self.next(pick_random=False)
            self.get_current_animation().stop()
            icon = Animation(self.screen, "icons/pause" if self.paused else "icons/play", interval=800, autoplay=False)
            icon.play_once()
            self.get_current_animation().start()
示例#9
0
from screenfactory import create_screen
from modules.clock import Clock
import config
import time
import pygame

screen = create_screen()

clock = Clock(screen)
clock.start()

while True:
    if config.virtual_hardware:
        pygame.time.wait(10)
        for event in pygame.event.get():
            pass
    else:
        time.sleep(0.01)
示例#10
0
class VoiceCommand(object):

    def __init__(self, voicesynthetizer):

        self.modulename = 'VoiceCommand'
        self.output = ""
        self.voicesynthetizer = voicesynthetizer
        self.voicerecognition = VoiceRecognition(self.voicesynthetizer)

        self.clock = Clock(voicesynthetizer)
        self.identification = Identification(voicesynthetizer)
        self.weather = Weather(self.voicesynthetizer)

    def presentation(self):

        logging.info('Voice Command Presentation')
        self.voicesynthetizer.speechit("Hola! Como puedo ayudarte?")

    def decode(self, output):

        logging.info('Voice Command Decode')

        if re.search(r'coman', output, re.M|re.I) or re.search(r'disponi', output, re.M|re.I):
            logging.info('Voice Command Decode Available Commands')
            self.voicesynthetizer.speechit("Comandos Disponibles? Identificacion, Hora, Fecha, Clima")
        elif re.search(r'identif', output, re.M|re.I):
            logging.info('Voice Command Decode Identification')
            self.identification.identify()
        elif re.search(r'hora', output, re.M|re.I):
            logging.info('Voice Command Decode Hour')
            self.clock.hour()
        elif re.search(r'fecha', output, re.M|re.I):
            logging.info('Voice Command Decode Date')
            self.clock.date()
        elif re.search(r'clima', output, re.M|re.I):
            logging.info('Voice Command Decode Weather')
            self.weather.report()
        elif re.search(r'tempe', output, re.M|re.I) or re.search(r'tura', output, re.M|re.I):
            logging.info('Voice Command Decode Temperature')
            self.weather.temperature()
        else:
            logging.error('Voice Command Unknown!')
            self.voicesynthetizer.speechit("No entendimos tu comando!")

    def listen(self):

        logging.info('Voice Command Listen')
        self.presentation()
        self.voicerecognition.record()
        output = self.voicerecognition.recognize('False')
        self.decode(output)
        alive(modulename=self.modulename, modulemessage=' Command ' + output.capitalize())

    def background(self):

        logging.info('Voice Command Background')
	while True:
	        self.voicerecognition.record()
        	output = self.voicerecognition.recognize('False')
                if re.search(r'canc', output, re.M|re.I):
                    self.voicesynthetizer.speechit("Alguien me hablo?. Soy NuupXe... Hasta pronto!")
                    break
                print output
示例#11
0
	def get_module(self, screen):
		from modules.clock import Clock
		return Clock(screen)
示例#12
0
from logger import Logger

# Initializing
env = simpy.Environment()

logger = Logger(env)

production_line = ProductionLine(env, logger)


# First running through with one item for debugging reasons, to make sure the
# event indices follow this order.

fas_instance = FASInstance(env, production_line, logger)
clock = Clock(logger, env)
done = fas_instance.spawn()
clock.spawn()
env.run(done)

# Putting in 20 items, waiting for them to be done, and then putting in 50 more,
# waiting them to be done also.

for i in range(0, 20):
    fas_instance = FASInstance(env, production_line, logger)
    done = fas_instance.spawn()

clock.spawn()
env.run(done)

for j in range(0, 50):
示例#13
0
class ServiceManager(object):

    def __init__(self, irlp):

        self.irlp = irlp
        self.pidfile = None
        self.scheduler_status = False
        self.pidfile = "/tmp/nuupxe.pid"

    def __del__(self):
        pass

    def voicesynthetizer(self):
        self.voicesynthetizer = VoiceSynthetizer("google", "spanish")

    def voicesynthetizerget(self):
        return self.voicesynthetizer

    def modules_setup(self):

        # Production Modules
        self.aprstracker = AprsTracker(self.voicesynthetizer)
        self.aprstt = Aprstt(self.voicesynthetizer)
        self.clock = Clock(self.voicesynthetizer)
        self.identification = Identification(self.voicesynthetizer)
        self.meteorology = Meteorology(self.voicesynthetizer)
        self.news = News(self.voicesynthetizer)
        self.selfie = Selfie(self.voicesynthetizer)
        self.voicecommand = VoiceCommand(self.voicesynthetizer)
        self.voicemail = VoiceMail(self.voicesynthetizer)
        self.weather = Weather(self.voicesynthetizer)
        self.wolframalpha = WolframAlpha(self.voicesynthetizer)

        # Experimental Modules
        self.assistant = Assistant(self.voicesynthetizer)
        self.messages = Messages(self.voicesynthetizer)
        self.morseteacher = MorseTeacher(self.voicesynthetizer)
        self.seismology = Seismology(self.voicesynthetizer)
        self.sstv = SSTV(self.voicesynthetizer)
        self.voiceapp = VoiceApp(self.voicesynthetizer)
        self.voiceexperimental = VoiceExperimental(self.voicesynthetizer)
        self.voicemailer = VoiceMailer(self.voicesynthetizer)

    def dtmf_setup(self,dtmf):
        dtmf_codes = {
        'PS0'  : 'alive',
        'PS1'  : 'aprstracker',
        'PS2'  : 'news',
        'PS3'  : 'meteorology',
        'PS4'  : 'seismology',
        'PS5'  : 'selfie',
        'PS6'  : 'voicecommand',
        'PS7'  : 'voiceexperimental',
        'PS8'  : 'wolframalpha',
        'PS9'  : 'voicemail',
        'PS10' : 'sstv',
        'PS11' : 'voiceapp',
        }
        return dtmf_codes.get(dtmf)

    def enabled(self):
        return os.path.isfile(self.pidfile)

    def enable(self):

        pid = str(os.getpid())
        logging.info('Process Id' + pid)
        file(self.pidfile, 'w').write(pid)

    def disable(self):

        if self.enabled():
            os.unlink(self.pidfile)
        if self.scheduler_status:
            self.scheduler.shutdown()

    def bing_mode(self):

        logging.info('Mode Bing')
        self.sstv = SSTV(self.voicesynthetizer)
        self.sstv.download()

    def observer_mode(self):

        logging.info('Mode Observer')
        pub = Publisher(['text', 'voice'])

        # Radio, Twitter, Email, Telegram, Whatsapp

        radio = Subscriber('radio')
        twitter = Subscriber('twitter')
        email = Subscriber('email')
        telegram = Subscriber('telegram')

        pub.register("text", radio)
        pub.register("voice", radio)
        pub.register("text", twitter)
        pub.register("text", email)
        pub.register("text", telegram)
        pub.register("voice", telegram)

        pub.dispatch("text", "this is text")
        pub.dispatch("voice", "this is voice")

    def scheduler_mode(self):

        logging.info('Mode Scheduler')
        self.voicesynthetizer.speechit("Modo Planificador")
        self.scheduler = Scheduler(misfire_grace_time=900, coalesce=True, threadpool=ThreadPool(max_threads=1))
        self.schedule()
        self.scheduler.start()
        self.schedule_print()
        self.scheduler_status = True

        while True:
            time.sleep(5)
            if self.irlp.active():
                time.sleep(5)
                self.irlp.busy()
                self.voicesynthetizer.speechit("Se ha activado el nodo, Proyecto NuupXe dice hasta pronto!")
                break

        self.disable()

    def writing_mode(self):

        logging.info('Mode Writing')
        # self.voicesynthetizer.speechit("Modo Escritura")

        while True:
            print " Type any text to make use of Text to Speech infraestructure"
            x = raw_input(" Type 'e' for exit: ")
            if x.lower() == 'e':
                self.disable()
                break;
            else:
                self.voicesynthetizer.speechit(x)
            time.sleep(1)

    def module_mode(self, module, dtmf=None):

        logging.info('Mode Module ' + module)

        # Custom Decode Activated Modules

        if module == 'identification':
            self.identification = Identification(self.voicesynthetizer)
            self.identification.identify()
        elif module == 'date':
            self.clock = Clock(self.voicesynthetizer)
            self.clock.date()
        elif module == 'hour':
            self.clock = Clock(self.voicesynthetizer)
            self.clock.hour()
        elif module == 'temperature':
            self.weather = Weather(self.voicesynthetizer)
            self.weather.temperature()
        elif module == 'weather':
            self.weather = Weather(self.voicesynthetizer)
            self.weather.report()

        # PS Activated Modules

        elif module == 'alive':
            alive()
        elif module == 'aprstracker':
            self.aprstracker = AprsTracker(self.voicesynthetizer)
            self.aprstracker.localize()
        elif module == 'news':
            self.news = News(self.voicesynthetizer)
            self.news.getitems()
        elif module == 'meteorology':
            self.meteorology = Meteorology(self.voicesynthetizer)
            self.meteorology.conagua_clima()
        elif module == 'selfie':
            self.selfie = Selfie(self.voicesynthetizer)
            self.selfie.get()
        elif module == 'voicecommand':
            self.voicecommand = VoiceCommand(self.voicesynthetizer)
            self.voicecommand.listen()
        elif module == 'voiceapp':
            self.voiceapp = VoiceApp(self.voicesynthetizer)
            self.voiceapp.application()
        elif module == 'voicemail':
            self.voicemail = VoiceMail(self.voicesynthetizer)
            self.voicemail.run(dtmf)
        elif module == 'wolframalpha':
            self.wolframalpha = WolframAlpha(self.voicesynthetizer)
            self.wolframalpha.ask()

        # SS Activated Modules

        # Experimental Modules

        elif module == 'aprstt':
            self.aprstt = Aprstt(self.voicesynthetizer)
            self.aprstt.query(dtmf)
        elif module == 'seismology':
            self.seismology = Seismology(self.voicesynthetizer)
            self.seismology.SismologicoMX()
        elif module == 'morselearn':
            self.morseteacher = MorseTeacher(self.voicesynthetizer)
            self.morseteacher.learn()
        elif module == 'morsecontest'	:
            self.morseteacher = MorseTeacher(self.voicesynthetizer)
            self.morseteacher.contest()
	elif module == 'regulations':
            self.messages = Messages(self.voicesynthetizer)
            self.messages.readfile('learning/reglamentos.1')
	elif module == 'radioclub':
            self.messages = Messages(self.voicesynthetizer)
            self.messages.readfile('learning/arej.radioclubs')
        elif module == 'stations':
            self.messages = Messages(self.voicesynthetizer)
            self.messages.stations()
        elif module == 'sstv':
            self.sstv = SSTV(self.voicesynthetizer)
            self.sstv.decode()
        elif module == 'assistant':
            self.assistant = Assistant(self.voicesynthetizer)
            self.assistant.demo1()
        elif module == 'voicebackground':
            self.voicecommand = VoiceCommand(self.voicesynthetizer)
            self.voicecommand.background()
        elif module == 'voiceexperimental':
            self.voiceexperimental = VoiceExperimental(self.voicesynthetizer)
            self.voiceexperimental.listen()
        elif module == 'voicemailer':
            self.voicemailer = VoiceMailer(self.voicesynthetizer)
            self.voicemailer.attend(dtmf)
        else:
            self.voicesynthetizer.speechit("No hemos implementado tu comando! Lo siento!")

        self.disable()

    def voice_mode(self, text):
        logging.info('Voice Mode')
        try:
            self.voicesynthetizer.speechit(text)
        except (StopIteration, KeyboardInterrupt, SystemExit):
            pass

    def phonetic_mode(self, text):
        logging.info('Phonetic Mode')
        phonetic = Phonetic()
        try:
            text = ' '.join(phonetic.decode(text))
            self.voicesynthetizer.speechit(text)
        except (StopIteration, KeyboardInterrupt, SystemExit):
            pass

    def schedule_print(self):
        self.scheduler.print_jobs()

    def schedule(self):

        # Production Modules
        self.scheduler.add_cron_job(self.clock.date, month='*', day_of_week='*', hour='06,12,22', minute ='00', second='00')
        self.scheduler.add_cron_job(self.clock.hour, month='*', day_of_week='*', hour='*', minute ='*/15', second='00')
        self.scheduler.add_cron_job(self.identification.identify, month='*', day_of_week='*', hour='*', minute ='*/30', second='00')
        self.scheduler.add_cron_job(self.selfie.get, month='*', day_of_week='*', hour='00,04,08,14,19', minute ='00', second='00')
        self.scheduler.add_cron_job(self.weather.report, month='*', day_of_week='*', hour='*/2', minute ='00', second='00')

        # Experimental Modules
        self.scheduler.add_cron_job(self.seismology.SismologicoMX, month='*', day='*', hour='*/4', minute ='00', second='00')
        self.scheduler.add_cron_job(self.news.getitems, month='*', day='*', hour='*/4', minute ='00', second='00')
        self.scheduler.add_cron_job(self.meteorology.conagua_clima, month='*', day='*', hour='*', minute ='15', second='00')
        self.scheduler.add_cron_job(self.messages.stations, month='*', day='*', hour='*/4', minute ='00', second='00')
        self.scheduler.add_cron_job(self.sstv.decode, month='*', day='*', hour='00,04,08,14,19', minute ='00', second='00')

	# Learning Modules, AREJ
        self.scheduler.add_cron_job(self.messages.readfile,args=['learning/arej.radioclubs'],month='*',day_of_week='*',hour='7,12,17',minute ='00',second='00')

        # Learning Modules, Morse
        self.scheduler.add_cron_job(self.morseteacher.learn, month='*', day='*', hour='07,12,17', minute ='30', second='00')
        self.scheduler.add_cron_job(self.morseteacher.contest, month='*', day='*', hour='07,12,17', minute ='45', second='00')

        # Learning Modules, Reglamentos
        self.scheduler.add_cron_job(self.messages.readfile,args=['learning/reglamentos.1'], month='*', day_of_week='mon', hour='08,13,18', minute ='00', second='00')
        self.scheduler.add_cron_job(self.messages.readfile,args=['learning/reglamentos.2'], month='*', day_of_week='tue', hour='08,13,18', minute ='00', second='00')
        self.scheduler.add_cron_job(self.messages.readfile,args=['learning/reglamentos.3'], month='*', day_of_week='wed', hour='08,13,18', minute ='00', second='00')
        self.scheduler.add_cron_job(self.messages.readfile,args=['learning/reglamentos.4'], month='*', day_of_week='thu', hour='08,13,18', minute ='00', second='00')
        self.scheduler.add_cron_job(self.messages.readfile,args=['learning/reglamentos.5'], month='*', day_of_week='fri', hour='08,13,18', minute ='00', second='00')
示例#14
0
    def module_mode(self, module, dtmf=None):

        logging.info('Mode Module ' + module)

        # Custom Decode Activated Modules

        if module == 'identification':
            self.identification = Identification(self.voicesynthetizer)
            self.identification.identify()
        elif module == 'date':
            self.clock = Clock(self.voicesynthetizer)
            self.clock.date()
        elif module == 'hour':
            self.clock = Clock(self.voicesynthetizer)
            self.clock.hour()
        elif module == 'temperature':
            self.weather = Weather(self.voicesynthetizer)
            self.weather.temperature()
        elif module == 'weather':
            self.weather = Weather(self.voicesynthetizer)
            self.weather.report()

        # PS Activated Modules

        elif module == 'alive':
            alive()
        elif module == 'aprstracker':
            self.aprstracker = AprsTracker(self.voicesynthetizer)
            self.aprstracker.localize()
        elif module == 'news':
            self.news = News(self.voicesynthetizer)
            self.news.getitems()
        elif module == 'meteorology':
            self.meteorology = Meteorology(self.voicesynthetizer)
            self.meteorology.conagua_clima()
        elif module == 'selfie':
            self.selfie = Selfie(self.voicesynthetizer)
            self.selfie.get()
        elif module == 'voicecommand':
            self.voicecommand = VoiceCommand(self.voicesynthetizer)
            self.voicecommand.listen()
        elif module == 'voiceapp':
            self.voiceapp = VoiceApp(self.voicesynthetizer)
            self.voiceapp.application()
        elif module == 'voicemail':
            self.voicemail = VoiceMail(self.voicesynthetizer)
            self.voicemail.run(dtmf)
        elif module == 'wolframalpha':
            self.wolframalpha = WolframAlpha(self.voicesynthetizer)
            self.wolframalpha.ask()

        # SS Activated Modules

        # Experimental Modules

        elif module == 'aprstt':
            self.aprstt = Aprstt(self.voicesynthetizer)
            self.aprstt.query(dtmf)
        elif module == 'seismology':
            self.seismology = Seismology(self.voicesynthetizer)
            self.seismology.SismologicoMX()
        elif module == 'morselearn':
            self.morseteacher = MorseTeacher(self.voicesynthetizer)
            self.morseteacher.learn()
        elif module == 'morsecontest'	:
            self.morseteacher = MorseTeacher(self.voicesynthetizer)
            self.morseteacher.contest()
	elif module == 'regulations':
            self.messages = Messages(self.voicesynthetizer)
            self.messages.readfile('learning/reglamentos.1')
	elif module == 'radioclub':
            self.messages = Messages(self.voicesynthetizer)
            self.messages.readfile('learning/arej.radioclubs')
        elif module == 'stations':
            self.messages = Messages(self.voicesynthetizer)
            self.messages.stations()
        elif module == 'sstv':
            self.sstv = SSTV(self.voicesynthetizer)
            self.sstv.decode()
        elif module == 'assistant':
            self.assistant = Assistant(self.voicesynthetizer)
            self.assistant.demo1()
        elif module == 'voicebackground':
            self.voicecommand = VoiceCommand(self.voicesynthetizer)
            self.voicecommand.background()
        elif module == 'voiceexperimental':
            self.voiceexperimental = VoiceExperimental(self.voicesynthetizer)
            self.voiceexperimental.listen()
        elif module == 'voicemailer':
            self.voicemailer = VoiceMailer(self.voicesynthetizer)
            self.voicemailer.attend(dtmf)
        else:
            self.voicesynthetizer.speechit("No hemos implementado tu comando! Lo siento!")

        self.disable()