コード例 #1
0
    def in_ready(self, message: Any, sender: RhasspyActor) -> None:
        """Handle messages in rady state."""
        if isinstance(message, SpeakSentence):
            self.wav_data = bytes()
            self.receiver = message.receiver or sender
            try:
                self.wav_data = self.speak(message.sentence)
                self.transition("speaking")
                self.send(self.player, PlayWavData(self.wav_data))
            except Exception:
                self._logger.exception("speak")

                # Try fallback system
                try:
                    assert (
                        self.fallback_actor is not None
                    ), "No fallback text to speech system"

                    self._logger.debug("Falling back to %s", self.fallback_actor)
                    self.transition("speaking")
                    self.send(self.fallback_actor, SpeakSentence(message.sentence))
                except Exception:
                    # Give up
                    self.transition("ready")
                    self.send(self.receiver, SentenceSpoken(bytes()))
        elif isinstance(message, Configured):
            # Fallback actor is configured
            pass
コード例 #2
0
 def in_ready(self, message: Any, sender: RhasspyActor) -> None:
     """Handle messages in ready state."""
     if isinstance(message, SpeakSentence):
         self.receiver = message.receiver or sender
         self.wav_data = self.speak(message.sentence)
         self.transition("speaking")
         self.send(self.player, PlayWavData(self.wav_data))
コード例 #3
0
    def in_ready(self, message: Any, sender: RhasspyActor) -> None:
        """Handle messages in ready state."""
        if isinstance(message, SpeakSentence):
            self.receiver = message.receiver or sender
            language = message.language or message.voice or self.language
            self.wav_data = self.speak(message.sentence, language=language)

            if message.play:
                self.transition("speaking")
                self.send(self.player, PlayWavData(self.wav_data))
            else:
                self.transition("ready")
                self.send(self.receiver, SentenceSpoken(self.wav_data))