Module speech
[hide private]
[frames] | no frames]

Module speech

source code

High-level functions to speak information.

Classes [hide private]
  SpeechCommand
The base class for objects that can be inserted between string of text for parituclar speech functions that convey things such as indexing or voice parameter changes.
  IndexCommand
Represents an index within some speech.
  CharacterModeCommand
Turns character mode on and off for speech synths.
  LangChangeCommand
A command to switch the language within speech.
  BreakCommand
Forces speakWithoutPauses to flush its buffer and therefore break the sentence at this point.
Functions [hide private]
 
initialize()
Loads and sets the synth driver configured in nvda.ini.
source code
 
terminate() source code
bool
isBlank(text)
Determine whether text should be reported as blank.
source code
 
processText(locale, text, symbolLevel) source code
int
getLastSpeechIndex()
Gets the last index passed by the synthesizer.
source code
 
cancelSpeech()
Interupts the synthesizer from currently speaking
source code
 
pauseSpeech(switch) source code
 
speakMessage(text, index=None)
Speaks a given message.
source code
 
getCurrentLanguage() source code
 
spellTextInfo(info, useCharacterDescriptions=False)
Spells the text from the given TextInfo, honouring any LangChangeCommand objects it finds if autoLanguageSwitching is enabled.
source code
 
speakSpelling(text, locale=None, useCharacterDescriptions=False) source code
 
_speakSpellingGen(text, locale, useCharacterDescriptions) source code
 
speakObjectProperties(obj, reason=REASON_QUERY, index=None, **allowedProperties) source code
 
speakObject(obj, reason=REASON_QUERY, index=None) source code
 
speakText(text, index=None, reason=REASON_MESSAGE, symbolLevel=None)
Speaks some text.
source code
(basestring, basestring)
splitTextIndentation(text)
Splits indentation from the rest of the text.
source code
unicode
getIndentationSpeech(indentation)
Retrieves the phrase to be spoken for a given string of indentation.
source code
 
speak(speechSequence, symbolLevel=None)
Speaks a sequence of text and speech commands
source code
 
speakSelectionMessage(message, text) source code
 
speakSelectionChange(oldInfo, newInfo, speakSelected=True, speakUnselected=True, generalize=False)
Speaks a change in selection, either selected or unselected text.
source code
 
speakTypedCharacters(ch) source code
 
processPositiveStates(role, states, reason, positiveStates) source code
 
processNegativeStates(role, states, reason, negativeStates) source code
 
speakTextInfo(info, useCache=True, formatConfig=None, unit=None, reason=REASON_QUERY, index=None) source code
 
getSpeechTextForProperties(reason=REASON_QUERY, **propertyValues) source code
 
getControlFieldSpeech(attrs, ancestorAttrs, fieldType, formatConfig=None, extraDetail=False, reason=None) source code
 
getFormatFieldSpeech(attrs, attrsCache=None, formatConfig=None, unit=None, extraDetail=False) source code
 
getTableInfoSpeech(tableInfo, oldTableInfo, extraDetail=False) source code
 
speakWithoutPauses(speechSequence, detectBreaks=True)
Speaks the speech sequences given over multiple calls, only sending to the synth at acceptable phrase or sentence boundaries, or when given None for the speech sequence.
source code
Variables [hide private]
  speechMode_off = 0
  speechMode_beeps = 1
  speechMode_talk = 2
  speechMode = 2
  speechMode_beeps_ms = 15
  beenCanceled = True
  isPaused = False
  curWordChars = []
  REASON_FOCUS = 1
  REASON_MOUSE = 2
  REASON_QUERY = 3
  REASON_CHANGE = 4
  REASON_MESSAGE = 5
  REASON_SAYALL = 6
  REASON_CARET = 7
  REASON_DEBUG = 8
  REASON_ONLYCACHE = 9
  REASON_FOCUSENTERED = 10
  CHUNK_SEPARATOR = " "
  oldTreeLevel = None
hash(x)
  oldTableID = None
hash(x)
  oldRowNumber = None
hash(x)
  oldColumnNumber = None
hash(x)
  BLANK_CHUNK_CHARS = frozenset((" ", "\n", "\r", "\0", u"\xa0"))
  RE_CONVERT_WHITESPACE = re.compile("[\0\r\n]")
  _speakSpellingGenerator = None
hash(x)
  RE_INDENTATION_SPLIT = re.compile(r"^([^\S\r\n\f\v]*)(.*)$", r...
  RE_INDENTATION_CONVERT = re.compile(r"(?P<char>\s)(?P=char)*",...
  silentRolesOnFocus = set([controlTypes.ROLE_PANE, controlTypes...
  silentValuesForRoles = set([controlTypes.ROLE_CHECKBOX, contro...
  re_last_pause = re.compile(ur"^(.*(?<=[^\s.!?])[.!?][\"'”’)]?(...
Function Details [hide private]

isBlank(text)

source code 

Determine whether text should be reported as blank.

Parameters:
  • text (str) - The text in question.
Returns: bool
True if the text is blank, False if not.

getLastSpeechIndex()

source code 

Gets the last index passed by the synthesizer. Indexing is used so that its possible to find out when a certain peace of text has been spoken yet. Usually the character position of the text is passed to speak functions as the index.

Returns: int
the last index encountered

speakMessage(text, index=None)

source code 

Speaks a given message.

Parameters:
  • text (string) - the message to speak
  • index (int) - the index to mark this current text with, its best to use the character position of the text if you know it

speakText(text, index=None, reason=REASON_MESSAGE, symbolLevel=None)

source code 

Speaks some text.

Parameters:
  • text (str) - The text to speak.
  • index (int) - The index to mark this text with, which can be used later to determine whether this piece of text has been spoken.
  • reason - The reason for this speech; one of the REASON_* constants.
  • symbolLevel - The symbol verbosity level; None (default) to use the user's configuration.

splitTextIndentation(text)

source code 

Splits indentation from the rest of the text.

Parameters:
  • text (basestring) - The text to split.
Returns: (basestring, basestring)
Tuple of indentation and content.

getIndentationSpeech(indentation)

source code 

Retrieves the phrase to be spoken for a given string of indentation.

Parameters:
  • indentation (basestring) - The string of indentation.
Returns: unicode
The phrase to be spoken.

speak(speechSequence, symbolLevel=None)

source code 

Speaks a sequence of text and speech commands

Parameters:
  • speechSequence - the sequence of text and SpeechCommand objects to speak
  • symbolLevel - The symbol verbosity level; None (default) to use the user's configuration.

speakSelectionChange(oldInfo, newInfo, speakSelected=True, speakUnselected=True, generalize=False)

source code 

Speaks a change in selection, either selected or unselected text.

Parameters:
  • oldInfo (textInfos.TextInfo) - a TextInfo instance representing what the selection was before
  • newInfo (textInfos.TextInfo) - a TextInfo instance representing what the selection is now
  • generalize (boolean) - if True, then this function knows that the text may have changed between the creation of the oldInfo and newInfo objects, meaning that changes need to be spoken more generally, rather than speaking the specific text, as the bounds may be all wrong.

Variables Details [hide private]

RE_INDENTATION_SPLIT

Value:
re.compile(r"^([^\S\r\n\f\v]*)(.*)$", re.UNICODE | re.DOTALL)

RE_INDENTATION_CONVERT

Value:
re.compile(r"(?P<char>\s)(?P=char)*", re.UNICODE)

silentRolesOnFocus

Value:
set([controlTypes.ROLE_PANE, controlTypes.ROLE_ROOTPANE, controlTypes.\
ROLE_FRAME, controlTypes.ROLE_UNKNOWN, controlTypes.ROLE_APPLICATION, \
controlTypes.ROLE_TABLECELL, controlTypes.ROLE_LISTITEM, controlTypes.\
ROLE_MENUITEM, controlTypes.ROLE_CHECKMENUITEM, controlTypes.ROLE_TREE\
VIEWITEM,])

silentValuesForRoles

Value:
set([controlTypes.ROLE_CHECKBOX, controlTypes.ROLE_RADIOBUTTON, contro\
lTypes.ROLE_LINK, controlTypes.ROLE_MENUITEM, controlTypes.ROLE_APPLIC\
ATION,])

re_last_pause

Value:
re.compile(ur"^(.*(?<=[^\s.!?])[.!?][\"'”’)]?(?:\s+|$))(.*$)", re.DOTA\
LL | re.UNICODE)