-
-
Save jrwarwick/8df47f2f69bdd94bbb92b227f43e9ca8 to your computer and use it in GitHub Desktop.
Connecting to the mycroft message bus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
#pip install websocket-client | |
#python mycroft_ws_test.py localhost recognizer_loop:utterance '{"utterances": ["what time is it"]}' | |
import sys | |
from websocket import create_connection | |
uri = 'ws://' + sys.argv[1] + ':8181/core' | |
ws = create_connection(uri) | |
print("Sending " + sys.argv[2] + " to " + uri + "...") | |
if len(sys.argv) >= 4: | |
data = sys.argv[3] | |
else: | |
data = "{}" | |
message = '{"type": "' + sys.argv[2] + '", "data": ' + data +'}' | |
result = ws.send(message) | |
print("Receiving...") | |
result = ws.recv() | |
print("Received '%s'" % result) | |
ws.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment