OSDN Git Service

speech.processSymbol: also pass the symbol through the speech dictionaries before...
authorMichael Curran <mick@kulgan.net>
Thu, 30 Sep 2010 04:59:32 +0000 (14:59 +1000)
committerMichael Curran <mick@kulgan.net>
Thu, 30 Sep 2010 04:59:32 +0000 (14:59 +1000)
source/speech.py

index 2547f12..26e106e 100755 (executable)
@@ -81,11 +81,12 @@ def _processSymbol(m):
 RE_CONVERT_WHITESPACE = re.compile("[\0\r\n]")\r
 \r
 def processTextSymbols(text,expandPunctuation=False):\r
+       if text:\r
+               text = speechDictHandler.processText(text)\r
        if (text is None) or (len(text)==0) or (isinstance(text,basestring) and (set(text)<=set(characterSymbols.blankList))):\r
                return _("blank") \r
        #Convert non-breaking spaces to spaces\r
        text=text.replace(u'\xa0',u' ')\r
-       text = speechDictHandler.processText(text)\r
        if expandPunctuation:\r
                text = RE_PROCESS_SYMBOLS.sub(_processSymbol, text)\r
        text = RE_CONVERT_WHITESPACE.sub(u" ", text)\r
@@ -93,6 +94,7 @@ def processTextSymbols(text,expandPunctuation=False):
 \r
 def processSymbol(symbol):\r
        if isinstance(symbol,basestring):\r
+               symbol=speechDictHandler.processText(symbol)\r
                symbol=symbol.replace(u'\xa0',u' ')\r
        newSymbol=characterSymbols.names.get(symbol,symbol)\r
        return newSymbol\r