Example #1
0
    def handle_message(self,
                       msg,
                       force_TTS=False,
                       screen=True,
                       speech=True,
                       braille=True,
                       mark=None):
        """When the client receives a message.

        Args:
            msg: the text to be displayed (str)
            force_TTS: should the text be spoken regardless?
            screen: should the text appear on screen?
            speech: should the speech be enabled?
            braille: should the braille be enabled?
            mark: the index where to move the cursor.

        """
        if screen:
            if self.factory.engine.redirect_message:
                self.factory.engine.redirect_message(msg)
            else:
                wx.CallAfter(pub.sendMessage,
                             "message",
                             client=self,
                             message=msg,
                             mark=mark)

        # In any case, tries to find the TTS
        msg = ANSI_ESCAPE.sub('', msg)
        panel = self.factory.panel
        if self.factory.engine.TTS_on or force_TTS:
            # If outside of the window
            tts = False
            if force_TTS:
                tts = True
            elif panel.inside and panel.focus:
                tts = True
            elif not panel.inside and panel.engine.TTS_outside:
                tts = True

            if tts:
                interrupt = self.factory.engine.settings[
                    "options.TTS.interrupt"]
                ScreenReader.talk(msg,
                                  speech=speech,
                                  braille=braille,
                                  interrupt=interrupt)
Example #2
0
    def find_word(self, word, TTS=False):
        """Find the most likely word for auto-completion."""
        matches = {}
        word = word.lower()
        for potential, count in self.words.items():
            if potential.startswith(word):
                if potential not in self.ac_choices:
                    matches[potential] = count

        # Sort through the most common
        for potential, count in sorted(matches.items(),
                key=lambda tup: tup[1], reverse=True):
            self.ac_choices.append(potential)
            if TTS:
                ScreenReader.talk(potential)
            return potential

        return None
Example #3
0
 def OnUpdateProgress(self, value=0):
     """Update the progress level."""
     if self:
         text = self.text.GetValue()
         ScreenReader.talk("{}% {}".format(value, text), speech=False)
         self.gauge.SetValue(value)
Example #4
0
 def handle_disconnection(self):
     """The client has been disconnected for any reason."""
     message = u"--- {} ---".format(t("ui.client.disconnected"))
     self.Send(message)
     ScreenReader.talk(message, interrupt=False)
Example #5
0
 def OnUpdateProgress(self, value=0):
     """Update the progress level."""
     if self:
         text = self.text.GetValue()
         ScreenReader.talk(u"{}% {}".format(value, text), speech=False)
         self.gauge.SetValue(value)