Exemple #1
0
def main():
    global tscount
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, event)
            time.sleep(0.5)
            print(tscount)
            if tscount >= 20:
                aiy.audio.say("FUN TIME!!")
                tscount -= 1
                thing = random.randint(1, 3)
                if thing == 1:
                    assistant.stop_conversation()
                    aiy.audio.say("Sammy was painting")
                elif thing == 2:
                    assistant.stop_conversation()
                    aiy.audio.say('Mr. Tom? Yes.')
                    aiy.audio.say('IM GROWING', volume=70)
                elif thing == 3:
                    assistant.stop_conversation()
                    aiy.audio.say("Don't you have to go to class")
Exemple #2
0
def main():
    global node_list
    logging.basicConfig(level=logging.INFO)
    credentials = auth_helpers.get_assistant_credentials()
    with Board() as board, Assistant(credentials) as assistant:
        schedule.every().day.at("00:59").do(schedule_wifiOff)
        schedule.every().day.at("01:00").do(schedule_waterMainOn)
        schedule.every().day.at("01:01").do(schedule_waterSideOn)
        schedule.every().day.at("01:15").do(schedule_waterSideOff)
        schedule.every().day.at("01:16").do(schedule_waterEastOn)
        schedule.every().day.at("01:30").do(schedule_waterEastOff)
        schedule.every().day.at("01:31").do(schedule_waterWestOn)
        schedule.every().day.at("01:45").do(schedule_waterWestOff)
        schedule.every().day.at("01:46").do(schedule_waterSouthOn)
        schedule.every().day.at("02:00").do(schedule_waterSouthOff)
        schedule.every().day.at("02:01").do(schedule_waterMainOff)
        #schedule.every().day.at("07:30").do(sayWeather, assistant)
        #schedule.every().day.at("07:45").do(sayWorkPath, assistant)
        schedule.every(15).minutes.do(checkSystem, assistant)
        schedule_thread_worker = threading.Thread(target=schedule_thread,
                                                  args=(schedule, ))
        schedule_thread_worker.start()
        http_thread_worker = threading.Thread(target=http_thread, args=())
        http_thread_worker.start()
        for key, value in node_list.items():
            value.start()
        checkSystem(assistant)
        for event in assistant.start():
            process_event(assistant, board.led, event)
Exemple #3
0
 def _run_task(self):
     print('Button press thread running...')
     credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
     with Assistant(credentials) as assistant:
         self._assistant = assistant
         for event in assistant.start():
             self._process_event(event)
def main():
    indoor_id = 'cffbf07c-4789-4762-9895-c23f0298a495'
    url1 = 'https://api.preview.oltd.de/v1/devices/'
    url2 = '/state'
    endpoint_indoor = url1 + indoor_id + url2
    headers = {
        "Authorization":
        "Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJNRWo4QkVEaWZnSnBfTzB3OEJCbEYxU05TNElmdlMyLWhERFBWTDRaTDYwIn0.eyJqdGkiOiIwMWUyMjgzMy1mZTdkLTQ0YjUtYTkzNS03YjE5YjE5ZjgwMzIiLCJleHAiOjE1MzAwMjMxMDEsIm5iZiI6MCwiaWF0IjoxNTI5MTU5MTAxLCJpc3MiOiJodHRwczovL2FwaS5wcmV2aWV3Lm9sdGQuZGUvYXV0aC9yZWFsbXMvb2x0IiwiYXVkIjoib2x0X3BvcnRhbCIsInN1YiI6ImMzZThhYjZmLTA3MDYtNDVhNC05Y2U1LWMyY2IwMDYyMmMzNyIsInR5cCI6IkJlYXJlciIsImF6cCI6Im9sdF9wb3J0YWwiLCJub25jZSI6IkUxWHFta0N4ZGd5ZGs3UGhFcmNZQ2VVQmd4ZmFGYXg4NVVwb3ZZT0giLCJhdXRoX3RpbWUiOjE1MjkxNTkxMDEsInNlc3Npb25fc3RhdGUiOiI2NDQ1MDVmMS04NTg2LTQyNjYtOWFmYy0yMDc4NDVlMGQ0OWUiLCJhY3IiOiIxIiwiYWxsb3dlZC1vcmlnaW5zIjpbXSwicmVzb3VyY2VfYWNjZXNzIjp7fSwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6Im9zci1vbHQtZ2F0ZXdheS1lazkxNjBAbWFpbGluYXRvci5jb20iLCJnaXZlbl9uYW1lIjoiT0xUIEdhdGV3YXkgIiwiZmFta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b25fc3RhdGUiOiJmZTFlYWJiMC1mMGVhLTQ5ZjEtYTNjNC1jODZhMThjNGIyNGEiLCJhY3IiOiIwIiwiYWxsb3dlZC1vcmlnaW5zIjpbXSwicmVzb3VyY2VfYWNjZXNzIjp7fSwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6ImJlcmdlci5tYXhpbWlsaWFuQGdteC5kZSIsImdpdmVuX25hbWUiOiJNYXhpbWlsaWFuIiwiZmFtaWx5X25hbWUiOiJCZXJnZXIiLCJlbWFpbCI6ImJlcmdlci5tYXhpbWlsaWFuQGdteC5kZSIsInRlbmFudCI6IjgwNWM0NDIwLTQxNjEtNGI0ZC1iZDI4LTNkMzNmNjkxZjI0MSJ9.jJqDQ4Y2srcJjUMY98F7u4EXVhBlTInLND6UFs5b1cF6iUczMedn_bK-hcNIzPnBAtEO8330vZ4pnYED5Kr5Whuwl6Z1_hVfa7d_zQ2I01prCpPZX7syQZqX-fvPqUDjpXITPUyAli03Eo6VVhZVI7HpHj5sh1qEa4Xr2qitRXAHqUgC5jw8WOPOL7Mwpmy9UmoKZVdTOrhYsuM1tIeShkQNOjBy2iYbi7OBHn2Gl74zPwqcqnL1jUgYeLjsYNKbTB-VB2VUtzIJXC_jeYraJLNWoqBQpgBUgr-YgkeXgG2kB9PmEHeXW2f6AeLtf3uHSLMqnFixK2SAhtej3-DQGA",
        "Content-Type": "application/json"
    }

    window_id = 'a2394935-749c-4783-b159-097a83a5a32b'

    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        r = requests.get(endpoint_indoor, headers=headers)
        humidity = round(
            r.json()['data']['attributes']['FTKPlus']['properties']
            ['Humidity'], 1)
        humidity2 = round(
            r.json()['data']['attributes']['FTKPlus2']['properties']
            ['Humidity'], 1)

        for event in assistant.start():
            process_event(assistant, event, humidity, humidity2, window_id,
                          url1, headers2)
Exemple #5
0
def main():
    # Authorize
    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            if process_event(assistant, event) is False:
                break
def main():
    logging.basicConfig(level=logging.INFO)

    credentials = auth_helpers.get_assistant_credentials()
    with Board() as board, Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(board.led, event)
Exemple #7
0
def aiy_main():
    """
    Yhdistää Google Assistant API:n.
    """
    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            aiy_process_event(assistant, event)
Exemple #8
0
 def gobabygo(self):
     self.logger.debug('secondary thread started')
     with Assistant(self.credentials) as assistant:
         for event in assistant.start():
             if not self._kill:
                 self.process_event(assistant, event)
             else:
                 break
Exemple #9
0
 def _run_task(self):
     credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
     with Assistant(credentials) as assistant:
         with Text_Assistant(credentials,
                             aiy.i18n.get_language_code()) as textassistant:
             self._assistant = assistant
             self._text_assistant = textassistant
             for event in assistant.start():
                 self._process_event(event)
Exemple #10
0
def main():
    # Turn Off Warning Flags
    GPIO.setwarnings(False)

    # Start Processing Google Assistant Events
    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, event)
Exemple #11
0
def main():
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(event)
Exemple #12
0
def main():
    if not os.path.exists('/run/user/0'):
        os.makedirs('/run/user/0')

    logging.basicConfig(level=logging.INFO)

    credentials = auth_helpers.get_assistant_credentials()
    with Board() as board, Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, board.led, event)
Exemple #13
0
    def _run_task(self):

        credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
        with Assistant(credentials) as assistant:
            self._assistant = assistant
            self.server.connect()
            try:
                for event in assistant.start():
                    self._process_event(event)
            finally:
                self.server.close()
Exemple #14
0
def main():

    logging.basicConfig(level=logging.INFO)

    #    button = aiy.voicehat.get_button()
    #    button.on_press(on_button_press)

    credentials = auth_helpers.get_assistant_credentials()
    with Board() as board, Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, board.led, event)
Exemple #15
0
def main():
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()

    aiy.audio.set_tts_volume(15)  # Set vol for local speech
    aiy.audio.set_tts_pitch(100)

    with Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, event)
def main():
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    dark_mode = False
    subprocess.call(
        'export GOOGLE_APPLICATION_CREDENTIALS="/home/pi/Desktop/Assistant-fe54628ef7ab.json"',
        shell=True)
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            dark_mode = process_event(assistant, event, dark_mode)
def main():

    global EV3  # THis is the pointer to the LEGO EV3.  This is a declared
    # as global so that during multiple calls to process_event,
    # the pointer in EV3 will have a persistant value

    EV3 = None

    logging.basicConfig(level=logging.INFO)

    credentials = auth_helpers.get_assistant_credentials()
    with Board() as board, Assistant(credentials) as assistant:
        for event in assistant.start():
            exit_conv = process_event(assistant, board.led, event)
            if exit_conv:
                break  # Stop this look if user requested it
Exemple #18
0
def main():
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)
    status_ui = aiy.voicehat.get_status_ui()
    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:

        for event in assistant.start():
            process_event(assistant, event)
    with aiy.audio.get_recorder() as recorder:
        while True:
            status_ui.status('ready')
            miaHot.waitForHotword(recorder, voice_only, seconds)
            status_ui.status('listening')
            print('Listening...')
            assistant.start_conversation()
Exemple #19
0
def main():
    listen_to_hotword = True
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    while listen_to_hotword:
        with aiy.audio.get_recorder() as recorder:
            miaHot.waitForHotword(recorder, voice_only, seconds)
            listen_to_hotword = True

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            #status_ui.status('ready')
            #print(type(assisant.start())
            process_event(assistant, event)
Exemple #20
0
def main():
    global config
    config = class_config()
    if fileexists(config.config_filename):
        print("will try to read Config File : ", config.config_filename)
        config.read_file()  # overwrites from file
    else:  # no file so file needs to be writen
        config.write_file()
        print(
            "New Config File Made with default values, you probably need to edit it"
        )

    logging.basicConfig(level=logging.INFO)

    credentials = auth_helpers.get_assistant_credentials()
    with Board() as board, Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, board.led, event)
def main():
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    recognizer = aiy.cloudspeech.get_recognizer()
    recognizer.expect_phrase('turn off the light')
    recognizer.expect_phrase('turn on the light')
    recognizer.expect_phrase('blink')
    button = aiy.voicehat.get_button()
    led = aiy.voicehat.get_led()
    aiy.audio.get_recorder().start()
    play_check = vlc.MediaPlayer('tmp.mp3')
    tts.en_play("AI Speaker Ready to Listen")
    mixer.init()

    with Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(event)
Exemple #22
0
def main():

    global EV3  # THis is the pointer to the LEGO EV3.  This is a declared
    # as global so that during multiple calls to process_event,
    # the pointer in EV3 will have a persistant value

    EV3 = None

    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()

    aiy.audio.set_tts_volume(15)  # Set vol for local speech
    aiy.audio.set_tts_pitch(100)

    with Assistant(credentials) as assistant:
        for event in assistant.start():
            exit_conv = process_event(assistant, event)
            if exit_conv:
                break  # Stop this look if user requested it
Exemple #23
0
def main():
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)

    GPIO.setmode(GPIO.BCM)

    GPIO.setup(_relay, GPIO.OUT)
    GPIO.output(_relay, GPIO.LOW)

    #blink_pi(1)

    # Instantiates a client
    translate_client = translate.Client()
    #translate1(translate_client, "Hello World", "zh-CN")

    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, event, translate_client)

    GPIO.cleanup()
Exemple #24
0
def main():
    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        process_event(EventType.ON_CONVERSATION_TURN_STARTED)
Exemple #25
0
def main():
    logging.basicConfig(level=logging.INFO)
    logging.basicConfig(level=logging.DEBUG)

    parser = argparse.ArgumentParser(description='Assistant service example.')
    parser.add_argument('--language', default=locale_language())
    args = parser.parse_args()
    while (1):
        try:
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=SHOW&module=module_0_clock'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=HIDE&module=module_2_calendar'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=HIDE&module=module_5_MMM-google-route'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=HIDE&module=module_3_currentweather'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=HIDE&module=module_4_weatherforecast'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=HIDE&module=module_6_MMM-Remote-Control'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=HIDE&module=module_7_newsfeed'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=SHOW&module=module_1_compliments'
            )
            r = requests.get(
                'http://127.0.0.1:8080/remote?action=HIDE&module=module_9_MMM-ToDoList'
            )
            client = CloudSpeechClient()
            print(client)
            credentials = auth_helpers.get_assistant_credentials()
            print(credentials)
            with Board() as board, Assistant(credentials) as assistant:
                print('s')
                assistant.set_mic_mute(True)
                print('ss')
                assistant.start()
                print('sss')
                print('start')
                while (1):
                    # status_ui=aiy.Assistant.get_status_ui()

                    print('coming')
                    board.led.state = Led.ON
                    print('here')
                    text = client.recognize(language_code=args.language)

                    # text="friday"
                    print('hgjhr')
                    if text is None:

                        continue
                    elif text.lower().find('friday') != -1:
                        board.led.state = Led.ON
                        index = text.lower().find('friday')
                        aiy.voice.audio.play_wav(
                            '/home/pi/Smart_Mirror/googlestart.wav')
                        text = text[index + 7:]
                        if (len(text) > 5):
                            logging.info('Processing..')
                            process_event(text, assistant, board, client)
                        else:
                            while (1):
                                logging.info('Smart Mirror Listening..')
                                text1 = client.recognize(
                                    language_code=args.language)

                                if text1 is None:
                                    continue
                                else:
                                    process_event(text1, assistant, board,
                                                  client)
                                    break
                    elif text.lower().find('minimize') != -1 or text.lower(
                    ).find('minimise') != -1 or text.lower().find(
                            'close') != -1:
                        process_event('minimise', assistant, board, client)
                    else:
                        continue
        except Exception as e:
            print(str(e))
            print('exception caught')
            time.sleep(0.5)
Exemple #26
0
 def _run_task(self):
     credentials = auth_helpers.get_assistant_credentials()
     with Assistant(credentials) as assistant:
         self._assistant = assistant
         for event in assistant.start():
             self._process_event(event)
Exemple #27
0
        status_ui.status('ready')
        detector.start(detected_callback=detect_callback,
                       interrupt_check=interrupt_callback,
                       sleep_time=0.03)

    elif event.type == EventType.ON_ASSISTANT_ERROR and event.args and event.args[
            'is_fatal']:
        sys.exit(1)
        detector.start(detected_callback=detect_callback,
                       interrupt_check=interrupt_callback,
                       sleep_time=0.03)


def main():
    if platform.machine() == 'armv6l':
        print('Cannot run hotword demo on Pi Zero!')
        exit(-1)


credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
with Assistant(credentials) as assistant:
    for event in assistant.start():
        process_event(assistant, event)

# main loop

detector.terminate()

if __name__ == '__main__':
    main()
Exemple #28
0
def main():
    GPIO.setwarnings(False)
    credentials = aiy.assistant.auth_helpers.get_assistant_credentials()
    with Assistant(credentials) as assistant:
        for event in assistant.start():
            process_event(assistant, event)