@@ -238,7 +238,7 @@ def speakSpelling(
238238 locale = locale ,
239239 useCharacterDescriptions = useCharacterDescriptions
240240 ))
241- speak (seq , priority = priority )
241+ speak (seq , priority = priority , suppressBlanks = True )
242242
243243
244244def _getSpellingSpeechAddCharMode (
@@ -878,12 +878,14 @@ def getIndentationSpeech(indentation: str, formatConfig: Dict[str, bool]) -> Spe
878878def speak ( # noqa: C901
879879 speechSequence : SpeechSequence ,
880880 symbolLevel : Optional [int ] = None ,
881- priority : Spri = Spri .NORMAL
881+ priority : Spri = Spri .NORMAL ,
882+ suppressBlanks : bool = False
882883):
883884 """Speaks a sequence of text and speech commands
884885 @param speechSequence: the sequence of text and L{SpeechCommand} objects to speak
885886 @param symbolLevel: The symbol verbosity level; C{None} (default) to use the user's configuration.
886887 @param priority: The speech priority.
888+ @param suppressBlanks: Whether to not append "blank" to the speech even if considered blank
887889 """
888890 logBadSequenceTypes (speechSequence )
889891 # in case priority was explicitly passed in as None, set to default.
@@ -943,9 +945,22 @@ def speak( # noqa: C901
943945 if autoLanguageSwitching and isinstance (item ,LangChangeCommand ):
944946 curLanguage = item .lang
945947 if isinstance (item ,str ):
946- speechSequence [index ]= processText (curLanguage ,item ,symbolLevel )
947- if not inCharacterMode :
948- speechSequence [index ]+= CHUNK_SEPARATOR
948+ text = processText (curLanguage , item , symbolLevel )
949+ if not inCharacterMode and text :
950+ text += CHUNK_SEPARATOR
951+ speechSequence [index ] = text
952+ # speech sequence should be considered blank if:
953+ # 1. it contains strings
954+ # 2. all strings are blank after processing
955+ if (
956+ not suppressBlanks
957+ and any (isinstance (i , str ) for i in speechSequence )
958+ # for checking if blank, just check if empty instead of isBlank(),
959+ # since whitespace has been stripped during processing
960+ and all (not s for s in speechSequence if isinstance (s , str ))
961+ ):
962+ # Translators: This is spoken when the speech sequence is considered blank.
963+ speechSequence .append (_ ("blank" ))
949964 _manager .speak (speechSequence , priority )
950965
951966
@@ -964,7 +979,7 @@ def speakPreselectedText(
964979 """
965980 seq = getPreselectedTextSpeech (text )
966981 if seq :
967- speak (seq , symbolLevel = None , priority = priority )
982+ speak (seq , symbolLevel = None , priority = priority , suppressBlanks = True )
968983
969984
970985def getPreselectedTextSpeech (
@@ -1013,7 +1028,7 @@ def speakSelectionMessage(
10131028):
10141029 seq = _getSelectionMessageSpeech (message , text )
10151030 if seq :
1016- speak (seq , symbolLevel = None , priority = priority )
1031+ speak (seq , symbolLevel = None , priority = priority , suppressBlanks = True )
10171032
10181033
10191034def _getSelectionMessageSpeech (
@@ -1230,7 +1245,7 @@ def speakTextInfo(
12301245
12311246 speechGen = GeneratorWithReturn (speechGen )
12321247 for seq in speechGen :
1233- speak (seq , priority = priority )
1248+ speak (seq , priority = priority , suppressBlanks = suppressBlanks )
12341249 return speechGen .returnValue
12351250
12361251
0 commit comments