Package speakeasy :: Module markupManagement :: Class MarkupManagement
[hide private]
[frames] | no frames]

Class MarkupManagement

source code

object --+
         |
        MarkupManagement

Instance Methods [hide private]

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
addMarkup(theStr, markupType, startPos, length=None, numWords=None, value=0)
Given appropriate information, enclose parts of a string in a SpeakEasy speech markup.
source code
String
removeMarkup(theStr, startPos)
Remove one SpeakEasy markup from a string.
source code
int
getValue(theStr, startPos)
Given a string and position within the string, Find the immediately enclosing markup, and return its magnitude.
source code
String.
changeValue(theStr, startPos, newValue)
Change magnitude part of an existing markup.
source code
 
pointerToEnclosingMarkup(theStr, cursorPos)
Given a string and a cursor position into it, return the cursor position of the nearest opening markup char.
source code
int
getLenFromNumWords(str, startPos, numWords)
Given a string, a start position within the string, and a number of words, return number of chars to end of start plus numWords words.
source code
int
isProperMarkupOpening(theStr, cursorPos=0)
Return True if theStr contains a legal speech markup opening at cursorPos.
source code
 
isLetter(oneChar) source code
 
findFirstNonDigit(theStr) source code
String.
convertStringToSSML(theStr)
Given a string with SpeakEasy markups, replace all SpeakEasy markups with official W3C SSML.
source code
 
restToSSML(markupType, theStrRest) source code
Class Variables [hide private]
  openMark = '['
  closeMark = ']'
  marks = {'E': '[E', 'P': '[P', 'R': '[R', 'S': '[S', 'V': '[V'}
  emphasisVals = {0: 'none', 1: 'moderate', 2: 'strong'}
  units = {'E': '', 'P': '%', 'R': '', 'S': 'ms', 'V': '%'}
  ssmlOpener = {'E': '<emphasis level=', 'P': '<prosody pitch=',...
  ssmlCLoser = {'E': '</emphasis>', 'P': '</prosody>', 'R': '</p...
  markupOpeningLen = 2
  splitter = re.compile(r'[,;\s!\?:\.<>]+')
  letterChecker = re.compile(r'[a-zA-Z]')
  digitChecker = re.compile(r'[-\+]?[0-9]')
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

addMarkup(theStr, markupType, startPos, length=None, numWords=None, value=0)
Static Method

source code 

Given appropriate information, enclose parts of a string in a SpeakEasy speech markup. Note that these are the less intrusive markups (an opening char plus a char identifying the type of markup (speech rate, pitch, volume, level, silence length).

Parameters:
  • theStr (String) - phrase containing the substring to be marked.
  • markupType (MarkupManagement.Marks) - indicator for what type of markup is intended
  • startPos (int) - first string index to be inclosed in the mark
  • length (int) - number of chars to be enclosed in the mark. (If used, do not use numWords)
  • numWords (int) - number of words to be enclosed in the mark (If used, do not use length)
  • value ({int | MarkupManagement.emphasisVals}) - the magnitude of the mark.

removeMarkup(theStr, startPos)
Static Method

source code 

Remove one SpeakEasy markup from a string.

Parameters:
  • theStr (String) - string containing markup to remove
  • startPos (int) - position somewhere inside the marked-up text, or right on the opening marker.
Returns: String
a new string with the markup removed.

getValue(theStr, startPos)
Static Method

source code 

Given a string and position within the string, Find the immediately enclosing markup, and return its magnitude.

Parameters:
  • theStr (String) - string containing the markup under consideration.
  • startPos (int) - index into the string, including the opening char of the mark.
Returns: int
magnitude value of the markup

changeValue(theStr, startPos, newValue)
Static Method

source code 

Change magnitude part of an existing markup.

Parameters:
  • theStr (String) - string containing the markup under consideration.
  • startPos (int) - index into the marked-up text, including the opening marker.
  • newValue (int) - new value for the markup
Returns: String.
a new string with the respective value modified.

pointerToEnclosingMarkup(theStr, cursorPos)
Static Method

source code 

Given a string and a cursor position into it, return the cursor position of the nearest opening markup char.

Parameters:
  • theStr (String) - string to examine.
  • cursorPos (int) - starting position of the search.
Returns:
Cursor position resPos such that theStr[resPos] == MarkupManagement.openMark. None if no enclosing openMark is found.
Raises:
  • ValueError - if passed-in cursorPos is out of range.:

getLenFromNumWords(str, startPos, numWords)
Static Method

source code 

Given a string, a start position within the string, and a number of words, return number of chars to end of start plus numWords words.

Parameters:
  • str (String) - string to examine
  • startPos (int) - start position for counting letters
  • numWords (int) - number of words to include in the count
Returns: int
number of chars between startPos and the end of the numWord's word.

isProperMarkupOpening(theStr, cursorPos=0)
Static Method

source code 

Return True if theStr contains a legal speech markup opening at cursorPos. Else throw error with illuminating text.

Parameters:
  • theStr (String) - string to check
  • cursorPos (int) - Starting position
Returns: int
Index to start of the markup opening's value, if cursorPos points to a legal markup opening within theStr.
Raises:
  • ValueError - if anything wrong.

convertStringToSSML(theStr)
Static Method

source code 

Given a string with SpeakEasy markups, replace all SpeakEasy markups with official W3C SSML.

Parameters:
  • theStr (String) - string containing the markup under consideration.
Returns: String.
new string with only SSML markup

Class Variable Details [hide private]

ssmlOpener

Value:
{'E': '<emphasis level=',
 'P': '<prosody pitch=',
 'R': '<prosody rate=',
 'S': '<break time=',
 'V': '<prosody volume='}

ssmlCLoser

Value:
{'E': '</emphasis>',
 'P': '</prosody>',
 'R': '</prosody>',
 'S': ' />',
 'V': '</prosody>'}