def in_started(self, message: Any, sender: RhasspyActor) -> None:
        """Handle messages in started state."""
        if isinstance(message, ListenForCommand):
            self.buffer = bytes()
            self.receiver = message.receiver or sender
            self.handle = message.handle
            self.transition("listening")

            if message.timeout is not None:
                # Use message timeout
                timeout_sec = message.timeout
            else:
                # Use default timeout
                timeout_sec = self.timeout_sec

            self.send(self.recorder, StartStreaming(self.myAddress))
            self.timeout_id = str(uuid.uuid4())
            self.wakeupAfter(timedelta(seconds=timeout_sec),
                             payload=self.timeout_id)
        elif isinstance(message, MqttMessage):
            # startListening
            if message.topic == self.start_topic:
                payload_json = json.loads(message.payload)
                if payload_json.get("siteId", "default") in self.site_ids:
                    # Wake up Rhasspy
                    self._logger.debug("Received startListening")
                    self.send(self._parent, ListenForCommand())
示例#2
0
    def in_loaded(self, message: Any, sender: RhasspyActor) -> None:
        """Handle messages in loaded state."""
        if isinstance(message, ListenForWakeWord):
            self.load_decoder()
            self.receivers.append(message.receiver or sender)
            self.transition("listening")

            if message.record:
                self.send(self.recorder, StartStreaming(self.myAddress))
示例#3
0
 def in_started(self, message: Any, sender: RhasspyActor) -> None:
     """Handle messages in started state."""
     if isinstance(message, ListenForWakeWord):
         try:
             self.load_handle()
             self.receivers.append(message.receiver or sender)
             self.transition("listening")
             if message.record:
                 self.send(self.recorder, StartStreaming(self.myAddress))
         except Exception:
             self._logger.exception("loading wake handle")
    def in_started(self, message: Any, sender: RhasspyActor) -> None:
        """Handle messages in started state."""
        if isinstance(message, ListenForCommand):
            self.receiver = message.receiver or sender
            self.handle = message.handle
            self.transition("listening")

            if message.timeout is not None:
                # Use message timeout
                timeout_sec = message.timeout
            else:
                # Use default timeout
                timeout_sec = self.timeout_sec

            self.send(self.recorder, StartStreaming(self.myAddress))
            self.wakeupAfter(timedelta(seconds=timeout_sec))
    def in_loaded(self, message: Any, sender: RhasspyActor) -> None:
        """Handle messages in loaded state."""
        if isinstance(message, ListenForCommand):
            if message.timeout is not None:
                # Use message timeout
                self.timeout_sec = message.timeout
            else:
                # Use default timeout
                self.timeout_sec = self.settings["timeout_sec"]

            self._logger.debug("Will timeout in %s second(s)",
                               self.timeout_sec)
            self.receiver = message.receiver or sender
            self.transition("listening")
            self.handle = message.handle
            self.send(self.recorder, StartStreaming(self.myAddress))
示例#6
0
    def in_loaded(self, message: Any, sender: RhasspyActor) -> None:
        """Handle messages in loaded state."""
        if isinstance(message, ListenForCommand):
            if message.timeout is not None:
                # Use message timeout
                self.timeout_sec = message.timeout
            else:
                # Use default timeout
                self.timeout_sec = self.settings["timeout_sec"]

            self.max_buffers = int(
                math.ceil(self.timeout_sec / self.seconds_per_buffer))
            self.receiver = message.receiver or sender
            self.transition("listening")
            self.handle = message.handle
            self.send(self.recorder, StartStreaming(self.myAddress))