Skip to content

Instantly share code, notes, and snippets.

View forslund's full-sized avatar
🌙

Åke forslund

🌙
View GitHub Profile
@forslund
forslund / intent2feature.py
Created January 20, 2020 14:08
Converter script converting Mycroft skill intent tests to behave features
import json
from os.path import join
from pathlib import Path
import sys
TEMPLATE = """
Scenario: {name}
Given the skill path "{skill_path}"
When the user says "{utterance}"
#include <stdio.h>
#include <string.h>
void show_icon(const char *code)
{
static char msgHold[31] = {0};
char icon[91];
//Arduinos have a hardcoded limit of 64 bytes for their serial input
//buffer. To get around this Mycroft sends large messages as two parts.
@forslund
forslund / bad_class_var.py
Created August 22, 2019 07:54
Python class variables test
class C:
class_var = None
def __init__(self):
if self.class_var is None:
self.class_var = [1]
print('Creating new instance')
else:
print('Appending to existing')
self.class_var.append(1)
@forslund
forslund / aarch64-instructions.md
Last active June 20, 2023 11:18
Mycroft-Precise on aarch64

Set up environment

  • Setup 2 GB swap
  • Make sure there's room in /tmp ( > 2 GB)

Install python 3.5

To be able to use the prebuild wheel of tensorflow python 3.5 is needed.

Install prerequisites

import pyaudio
pa = pyaudio.PyAudio()
print('\n\n\n==========================================\nFound devices:')
for device_index in range(pa.get_device_count()):
dev = pa.get_device_info_by_index(device_index)
if dev['maxInputChannels'] > 0:
print('{}: Samplerate {} Channels {}'.format(dev['name'],
dev['defaultSampleRate'],
dev['maxInputChannels']))
import json
from adapt.intent import IntentBuilder
from adapt.engine import IntentDeterminationEngine
from adapt.context import ContextManager
engine = IntentDeterminationEngine()
context_manager = ContextManager()
# define vocabulary
#!/opt/venvs/mycroft-core/bin/python
from mycroft.messagebus.send import send
send('mycroft.wifi.start')
print("""=====================================================================
Wifi setup has begun. Use your phone, tablet or laptop to connect to
the network 'MYCROFT' using the password '12345678'. Once connected
browse to 'https://start.mycroft.ai', then follow the prompts to
complete the setup.
=====================================================================
@forslund
forslund / changing_confidence.py
Created May 30, 2018 13:38
Demonstration of changing confidence when adding extra regexes
from adapt.intent import IntentBuilder
from adapt.engine import IntentDeterminationEngine
def check_for_location(intent):
if 'Location' in intent:
print('Location: {}'.format(intent['Location']))
else:
print('Location: Not found')
@forslund
forslund / adapt_optionally_regex.py
Created May 30, 2018 06:15
Failing optionally adapt test case
from adapt.intent import IntentBuilder
from adapt.engine import IntentDeterminationEngine
def check_for_location(intent):
if 'Location' in intent:
print('Location: {}'.format(intent['Location']))
else:
print('Location: Not found')
from zeroconf import ServiceBrowser, Zeroconf
class MycroftListener(object):
def __init__(self):
self.devices = {}
def remove_service(self, zeroconf, type, name):
print("Service %s removed" % (name,))
self.devices.pop(name)