self.add_event('speak', self.yourHandler) # this will call the function/method yourHandler everytime a speak-event is triggered
def yourHandler(self, message):
response = message.data.get("utterance") # this extracts the utterance from the event
print(response) # prints the utterance part from the Event in CLI
I have a couple of what are probably very stupid questions.
Does this have to run on the Mark I itself? I tried running the code that @pcwii provided, and it seems to work, but fails in the end. A quick nmap shows that port 8181 (from @KathyReid) isn’t open. Only port 22.
On the Mark I, doing a straight up pip install of the websocket library fails because it doesn’t think pip is installed. pip is there, but in the Mycroft core virtual environment. If I just do an apt-get install python-pip, it’s wanting me to install a host of things, and I’m trying not to hose up my Mark I. Is it safe to do an apt-get install pip on these things?
I apologize in advance for these questions. I admit that I’m mucking around in things that are outside of my comfort zone and over my head for the most part. I appreciate your patience.
Sure, but the errors are pretty uninteresting. I’m using the code @pcwii posted last week exactly other than updating IP information to actually point to my Mark I. That’s here:
When I execute that code, I get this output after quite some time:
Traceback (most recent call last):
File “test.py”, line 22, in
send_message(‘speak, hello’)
File “test.py”, line 17, in send_message
ws = create_connection(url)
File “/usr/local/lib/python2.7/dist-packages/websocket/_core.py”, line 494, in create_connection
websock.connect(url, **options)
File “/usr/local/lib/python2.7/dist-packages/websocket/_core.py”, line 217, in connect
options.pop(‘socket’, None))
File “/usr/local/lib/python2.7/dist-packages/websocket/_http.py”, line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File “/usr/local/lib/python2.7/dist-packages/websocket/_http.py”, line 186, in _open_socket
raise error
socket.error: [Errno 110] Connection timed out
I don’t think it’s anything to do with the code, which seems pretty straight forward. I did do an nmap of the system, and the only open port is showing as 22, and if the MessageBus operates on 8181 I’m not sure how it would establish a connection from outside of the Mark I.
It’s on my main computer, which is running Mint 19. It is running under Python 2.7, but the results are the same if I run it with Python 3.6, which I also have installed.
Traceback (most recent call last):
File "test.py", line 22, in <module>
send_message('speak, hello')
File "test.py", line 17, in send_message
ws = create_connection(url)
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_core.py", line 494, in create_connection
websock.connect(url, **options)
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_core.py", line 217, in connect
options.pop('socket', None))
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_http.py", line 120, in connect
sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_http.py", line 186, in _open_socket
raise error
File "/home/mike/.local/lib/python3.6/site-packages/websocket/_http.py", line 170, in _open_socket
sock.connect(address)
TimeoutError: [Errno 110] Connection timed out
I’m trying to connect to a Mark I unit, but port 8181 doesn’t seem open.
Silly question, is ssh enabled on the Device - ie have you used the button on the top to enable ssh - it seems like a silly question but I often forget to do it after a reimage.
Nope, my laptop and the Mark I are on the same internal network. No firewall between them. The only slight variation (and this sounds weird) is that my laptop is wired to the network, and the Mark I is wireless. They’re connected to the exact same router though.
OK, check to see whether your router has something called “wireless isolation” turned on. It’s kinda like a firewall between wired and wireless devices.
As far as I can tell, my router doesn’t have anything called that on or off. I wasn’t able to locate any settings in my router configuration like that.
@linuxrants, @KathyReid
Thought I would chime in on this. if you used my code as is I had the IP address for my device hardcoded.
This should be changed to the IP address of your Mark1.