Beispiel #1
0
    def __init__(self):
        recognizer = Recognizer()
        recognizer.dynamic_energy_threshold = False
        recognizer.energy_threshold = 1000
        self.recognizer = recognizer
        self.microphone = Microphone()
        self.susi = susi

        try:
            res = requests.get('http://ip-api.com/json').json()
            self.susi.update_location(longitude=res['lon'],
                                      latitude=res['lat'])

        except ConnectionError as e:
            logging.error(e)

        self.config = json_config.connect('config.json')

        if self.config['hotword_engine'] == 'Snowboy':
            from main.hotword_engine import SnowboyDetector
            self.hotword_detector = SnowboyDetector()
        else:
            from main.hotword_engine import PocketSphinxDetector
            self.hotword_detector = PocketSphinxDetector()

        if self.config['wake_button'] == 'enabled':
            if self.config['device'] == 'RaspberryPi':
                from ..hardware_components import RaspberryPiWakeButton
                self.wake_button = RaspberryPiWakeButton()
            else:
                self.wake_button = None
        else:
            self.wake_button = None
    def __init__(self, renderer=None):
        try:
            import RPi.GPIO as GPIO
            GPIO.setmode(GPIO.BCM)
            GPIO.setup(17, GPIO.OUT)
            GPIO.setup(27, GPIO.OUT)
            GPIO.setup(22, GPIO.OUT)
        except ImportError:
            print("Only available for devices with GPIO ports ")
        except RuntimeError:
            pass

        recognizer = Recognizer()
        recognizer.dynamic_energy_threshold = False
        recognizer.energy_threshold = 1000
        self.recognizer = recognizer
        self.microphone = Microphone()
        self.susi = susi
        self.renderer = renderer

        try:
            res = requests.get('http://ip-api.com/json').json()
            self.susi.update_location(
                longitude=res['lon'], latitude=res['lat'], country_name=res['country'], country_code=res['countryCode'])

        except ConnectionError as e:
            logging.error(e)

        self.config = json_config.connect('config.json')

        if self.config['usage_mode'] == 'authenticated':
            try:
                susi.sign_in(email=self.config['login_credentials']['email'],
                             password=self.config['login_credentials']['password'])
            except Exception:
                print('Some error occurred in login. Check you login details in config.json')

        if self.config['hotword_engine'] == 'Snowboy':
            from main.hotword_engine import SnowboyDetector
            self.hotword_detector = SnowboyDetector()
        else:
            from main.hotword_engine import PocketSphinxDetector
            self.hotword_detector = PocketSphinxDetector()

        if self.config['WakeButton'] == 'enabled':
            print("\nSusi has the wake button enabled")
            if self.config['Device'] == 'RaspberryPi':
                print("\nSusi runs on a RaspberryPi")
                from ..hardware_components import RaspberryPiWakeButton
                self.wake_button = RaspberryPiWakeButton()
            else:
                print("\nSusi is not running on a RaspberryPi")
                self.wake_button = None
        else:
            print("\nSusi has the wake button disabled")
            self.wake_button = None
Beispiel #3
0
    def __init__(self, renderer=None):
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(17, GPIO.OUT)
        GPIO.setup(27, GPIO.OUT)
        GPIO.setup(22, GPIO.OUT)

        recognizer = Recognizer()
        recognizer.dynamic_energy_threshold = False
        recognizer.energy_threshold = 1000
        self.recognizer = recognizer
        self.microphone = Microphone()
        self.susi = susi
        self.renderer = renderer

        try:
            res = requests.get('http://ip-api.com/json').json()
            self.susi.update_location(longitude=res['lon'],
                                      latitude=res['lat'])

        except ConnectionError as e:
            logging.error(e)

        self.config = json_config.connect('config.json')

        if self.config['usage_mode'] == 'authenticated':
            try:
                susi.sign_in(
                    email=self.config['login_credentials']['email'],
                    password=self.config['login_credentials']['password'])
            except Exception:
                print(
                    'Some error occurred in login. Check you login details in config.json'
                )

        if self.config['hotword_engine'] == 'Snowboy':
            from main.hotword_engine import SnowboyDetector
            self.hotword_detector = SnowboyDetector()
        else:
            from main.hotword_engine import PocketSphinxDetector
            self.hotword_detector = PocketSphinxDetector()

        if self.config['wake_button'] == 'enabled':
            if self.config['device'] == 'RaspberryPi':
                from ..hardware_components import RaspberryPiWakeButton
                self.wake_button = RaspberryPiWakeButton()
            else:
                self.wake_button = None
        else:
            self.wake_button = None
Beispiel #4
0
    def __init__(self):
        recognizer = Recognizer()
        recognizer.dynamic_energy_threshold = False
        recognizer.energy_threshold = 1000
        self.recognizer = recognizer
        self.microphone = Microphone()
        self.susi = susi
        self.config = json_config.connect('config.json')

        if self.config['hotword_engine'] == 'Snowboy':
            from main.hotword_engine import SnowboyDetector
            self.hotword_detector = SnowboyDetector()
        else:
            from main.hotword_engine import PocketSphinxDetector
            self.hotword_detector = PocketSphinxDetector()

        if self.config['wake_button'] == 'enabled':
            if self.config['device'] == 'RaspberryPi':
                from ..hardware_components import RaspberryPiWakeButton
                self.wake_button = RaspberryPiWakeButton()
            else:
                self.wake_button = None
        else:
            self.wake_button = None