Пример #1
0
    def show(self):
        print "Module Colors"
        colors = ["Black", "White", "Red", "Blue", "Yellow", "Gray", "Green", "Purple"]

        lcdrgb = xLcdRgb()

        if getrandbits(1):
            colorlcd = random.choice(colors)
            colortext = random.choice(colors)
            anstemp = False
        else:
            colorlcd = random.choice(colors)
            colortext = colorlcd
            anstemp = True

        lcdrgb.clear()
        lcdrgb.setColor(colorlcd)
        xtalk("en-us", "Press Button if color is " + colortext)
        time.sleep(0.5)
        ansfin = nonBlockingRawInput()

        if anstemp is not ansfin:
            message = "This is a wrong answer! This color is not " + colortext + "This color is " + colorlcd
        else:
            message = "This is a good answer! This color is " + colorlcd

        try:
            xtalk("en-us", message)
        except:
            pass
Пример #2
0
    def report(self):

        result = pywapi.get_weather_from_yahoo('MXJO0043', 'metric')

        message = "Reporte del Clima en " + result['location']['city']
        message = message + ", Temperatura " + result['condition']['temp'] + " grados centigrados"
        message = message + ", Presion Atmosferica " + result['atmosphere']['pressure'] + " milibares"
        message = message + ", Visibilidad " + result['atmosphere']['visibility'] + " kilometros"
        message = message + ", Humedad " + result['atmosphere']['humidity'] + " por ciento"
        message = message + ", El Sol se oculta a las " + result['astronomy']['sunset']

        xtalk("es-mx", message)
Пример #3
0
    def ask(self):

        xtalk('en-us', 'Yes! What is your question for Wolfram Alpha?')
        self.xvoice.record()

        question = self.xspeechr.recognize()
        questionmessage = 'Question? ' + question
        xtalk('en-us', questionmessage)

        answer = self.xwolfram.question(question)

        if answer != None:
            answermessage = 'Answer? ' + answer
            xtalk('en-us', answermessage)
        else:
            answermessage = 'Answer? Sorry! Something went wrong!'
            xtalk('en-us', answermessage)
 def decode(self):
     self.presentation()
     self.xv.record()
     output = self.xs.recognize()
     xtalk('en-us', "Thanks! I think you said " + output)
 def presentation(self):
     xtalk('en-us', "Hi IoT Python Learners! Please say something!?")