def __init__( self, mqtt_hostname=os.environ.get('audioserver_mqtt_hostname', 'mosquitto'), mqtt_port=os.environ.get('audioserver_mqtt_port', 1883), site=os.environ.get('audioserver_site', 'default'), ): SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port) self.site = site self.thread_targets.append(self.sendAudioFrames) self.subscribe_to = 'hermes/audioServer/+/playBytes/+' self.pyaudio = pyaudio.PyAudio() #self.sampleWidth = 2 self.formatFromWidth = pyaudio.paInt16 self.nchannels = 1 self.framerate = 16000 self.chunkSize = 256 self.streamOut = self.pyaudio.open(format=self.formatFromWidth, channels=self.nchannels, rate=self.framerate, output=True) self.streamIn = self.pyaudio.open(format=self.formatFromWidth, channels=self.nchannels, rate=self.framerate, input=True, frames_per_buffer=self.chunkSize)
def __init__( self, mqtt_hostname='mosquitto', mqtt_port=1883, ): SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port) self.subscribe_to = 'hermes/tts/say'
def on_connect(self, client, userdata, flags, result_code): SnipsMqttServer.on_connect(self, client, userdata, flags, result_code) # enable to start for site in self.allowedClientList: self.client.publish( 'hermes/hotword/{}/toggleOn'.format(self.hotword), payload="{\"siteId\":\"" + site + "\",\"sessionId\":null}", qos=0)
def __init__(self, mqtt_hostname='mosquitto', mqtt_port=1883, site='default'): SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port) self.site = site self.thread_targets.append(self.sendAudioFrames) self.subscribe_to = 'hermes/audioServer/+/playBytes/+'
def __init__( self, mqtt_hostname='mosquitto', mqtt_port=1883, ): SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port) self.subscribe_to = 'hermes/training/start' self.thread_targets.append(self.do_training) self.queue = [] print("start training server")
def __init__( self, mqtt_hostname=os.environ.get('rasa_nlu_mqtt_hostname', 'mosquitto'), mqtt_port=os.environ.get('rasa_nlu_mqtt_port', 1883), training_mqtt_hostname=None, training_mqtt_port=None, nlu_model_path=os.environ.get('rasa_nlu_model_path', 'models/nlu'), nlu_models=os.environ.get('rasa_nlu_models', 'default'), nlu_training_path=os.environ.get('rasa_nlu_training_path', 'training_data/nlu/'), config_file=os.environ.get('rasa_nlu_default_config_file', 'training_data/nlu/config.json'), config_file_slots=os.environ.get( 'rasa_nlu_default_config_file_slots', 'training_data/nlu/config-slots.json'), lang=os.environ.get('rasa_nlu_lang', 'en-GB'), snips_user_id=os.environ.get('rasa_nlu_snips_user_id', 'user_Kr5A7b4OD'), ): """ Initialisation. :param config: a YAML configuration. :param assistant: the client assistant class, holding the intent handler and intents registry. """ SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port, training_mqtt_hostname, training_mqtt_port) # RASA config self.trainingIds = {} self.training_request_models = {} self.interpreter = {} self.interpreter_slots = {} self.nlu_model_path = nlu_model_path self.nlu_training_path = nlu_training_path self.default_config_file = config_file self.default_config_file_slots = config_file_slots # for matching snips intents self.snips_user_id = snips_user_id self.models = nlu_models.split(",") self.thread_handler = ThreadHandler() self.thread_targets.append(self.startTrainingMqtt) self.training_client.on_message = self.on_training_message self.thread_targets.append(self.watchModels) self.lang = lang self.subscribe_to = 'hermes/nlu/query,hermes/nlu/partialQuery' self.nlu_modified = {} self.nlu_model_modified = {} self.loadModels(True) self.nlu_modified = self.getNluModifiedAll() self.nlu_model_modified = self.getNluModelModifiedAll()
def __init__(self, mqtt_hostname=os.environ.get('mqtt_hostname','mosquitto'), mqtt_port=os.environ.get('mqtt_port',1883), kaldi_url=os.environ.get('kaldi_url','ws://kaldi:80/client/ws/speech'), ): SnipsMqttServer.__init__(self,mqtt_hostname,mqtt_port) self.subscribe_to='hermes/asr/startListening,hermes/asr/stopListening' #hermes/audioServer/{}/audioFrame content_type = "audio/x-raw, layout=(string)interleaved, rate=(int)16000, format=(string)S16LE, channels=(int)1" self.kaldi_url = kaldi_url + '?{}'.format(urllib.urlencode([("content-type", content_type)])) self.log("kaldi url - {}".format(self.kaldi_url)) self.sockets = {}
def __init__( self, mqtt_hostname=os.environ.get('mqtt_hostname', 'localhost'), mqtt_port=os.environ.get('mqtt_port', 1883), listen_to=os.environ.get('hotword_listen_to', 'default'), ): SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port) self.subscribe_to = 'hermes/hotword/toggleOff,hermes/hotword/toggleOn' self.listen_to = listen_to self.clientList = [] self.allowedClientList = listen_to.split(',')
def __init__( self, mqtt_hostname=os.environ.get('mqtt_hostname', 'mosquitto'), mqtt_port=os.environ.get('mqtt_port', 1883), hotword_model=os.environ.get('hotword_model', 'resources/snowboy.umdl'), hotword=os.environ.get('hotword', 'snowboy'), sensitivity=os.environ.get('hotword_sensitivity', '0.5'), listen_to=os.environ.get('hotword_listen_to', 'default'), ): SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port) self.hotword = hotword self.hotword_model = hotword_model self.listen_to = listen_to self.subscribe_to = 'hermes/hotword/+/toggleOff,hermes/hotword/+/toggleOn,hermes/audioServer/+/audioFrame' # PIWHO self.piwho_model = os.path.dirname( os.path.abspath(__file__)) + '/piwho/' self.piwho_speakers = self.piwho_model + '/speakers.txt' self.piwho_training_data = os.path.dirname( os.path.abspath(__file__)) + '/piwho/data' self.recog = None self.clientList = [] self.allowedClientList = listen_to.split(',') self.client_buffer = {} self.client_recognition = {} self.client_talking = {} self.record = {} self.messageCount = 0 self.detection = snowboydecoder.HotwordDetector( hotword_model, sensitivity=sensitivity) for client in self.allowedClientList: self.client_buffer[client] = AudioBuffer( self.detection.detector.NumChannels() * self.detection.detector.SampleRate() * 20) self.client_recognition[client] = AudioBuffer( self.detection.detector.NumChannels() * self.detection.detector.SampleRate() * 2) self.client_talking[client] = False self.record[client] = False self.trainPiWho() if (self.piwho_enabled()): self.recog = recognition.SpeakerRecognizer()
def __init__( self, mqtt_hostname='mosquitto', mqtt_port=1883, ): SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port) self.subscribe_to = 'hermes/hotword/+/detected,hermes/hotword/detected,hermes/asr/textCaptured,hermes/nlu/intentParsed,hermes/dialogueManager/startSession,hermes/dialogueManager/continueSession,hermes/dialogueManager/endSession' self.sessions = {} # sessions keyed by siteId self.sessionIds = {} # sites keyed by sessionId self.sessionData = {} # extra data by sessionId self.sessionExpiry = {} # session expiry time by sessionId self.thread_targets.append(self.monitorSessionTimeouts) self.expiryTimeout = 10 self.hotwords = {}
def __init__(self, mqtt_hostname=os.environ.get('rasa_core_mqtt_hostname', 'mosquitto'), mqtt_port=os.environ.get('rasa_core_mqtt_port', 1883), training_mqtt_hostname=None, training_mqtt_port=None, core_model_path=os.environ.get('rasa_core_model_path', 'models/dialogue'), domain_file=os.environ.get('rasa_core_domain_file', None), core_training_file=os.environ.get('rasa_core_training_file', None), lang=os.environ.get('rasa_core_lang', 'en-GB')): """ Initialisation. :param config: a YAML configuration. :param assistant: the client assistant class, holding the intent handler and intents registry. """ SnipsMqttServer.__init__(self, mqtt_hostname, mqtt_port, training_mqtt_hostname, training_mqtt_port) self.thread_handler = ThreadHandler() self.thread_targets.append(self.startTrainingMqtt) self.thread_targets.append(self.watchModels) #self.client = mqtt.Client() #self.client.on_connect = self.on_connect #self.client.on_disconnect = self.on_disconnect #self.client.on_message = self.on_message #self.mqtt_hostname = mqtt_hostname #self.mqtt_port = mqtt_port #self.training_client.on_message = self.on_message self.lang = lang self.subscribe_to = 'hermes/intent/+' # RASA config self.core_model_path = core_model_path # RASA training config self.domain_file = domain_file self.core_training_file = core_training_file self.core_model_path = core_model_path #self.agentLoaded = SnipsMqttAgent(self.domain_file,policies=[MemoizationPolicy(), KerasPolicy()],core_server = self) self.agentLoaded = None self.trainingId = None self.siteId = None self.sessionId = None self.core_modified = self.getCoreModified() self.core_domain_modified = self.getCoreDomainModified() self.core_model_modified = self.getCoreModelModified() self.loadModels()
def on_connect(self, client, userdata, flags, result_code): SnipsMqttServer.on_connect(self,client,userdata,flags,result_code)