make punctuation initial working
This commit is contained in:
parent
5454723d1f
commit
ac6e11537c
@ -28,7 +28,7 @@ class command():
|
|||||||
if currChar.strip(" \t\n") == '':
|
if currChar.strip(" \t\n") == '':
|
||||||
self.env['runtime']['outputManager'].presentText("blank" ,interrupt=True)
|
self.env['runtime']['outputManager'].presentText("blank" ,interrupt=True)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True)
|
self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True, ignorePunctuation=True)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -28,7 +28,7 @@ class command():
|
|||||||
if currChar.strip(" \t\n") == '':
|
if currChar.strip(" \t\n") == '':
|
||||||
self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
|
self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -28,7 +28,7 @@ class command():
|
|||||||
if currChar.strip(" \t\n") == '':
|
if currChar.strip(" \t\n") == '':
|
||||||
self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
|
self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
|
||||||
else:
|
else:
|
||||||
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -33,7 +33,7 @@ class command():
|
|||||||
return
|
return
|
||||||
currChar = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']][self.env['screenData']['newCursor']['x']]
|
currChar = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']][self.env['screenData']['newCursor']['x']]
|
||||||
if not currChar.strip(" \t\n") == '':
|
if not currChar.strip(" \t\n") == '':
|
||||||
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True)
|
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -28,7 +28,7 @@ class command():
|
|||||||
# big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now)
|
# big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now)
|
||||||
if len(self.env['screenData']['newDelta']) > 3:
|
if len(self.env['screenData']['newDelta']) > 3:
|
||||||
return
|
return
|
||||||
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=True)
|
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=True, ignorePunctuation=True)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -35,7 +35,7 @@ class command():
|
|||||||
# too much for a single backspace...
|
# too much for a single backspace...
|
||||||
if len(self.env['screenData']['newNegativeDelta']) >= 5:
|
if len(self.env['screenData']['newNegativeDelta']) >= 5:
|
||||||
return
|
return
|
||||||
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True)
|
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True, ignorePunctuation=True)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -20,7 +20,7 @@ class outputManager():
|
|||||||
self.env['runtime']['settingsManager'].shutdownDriver('soundDriver')
|
self.env['runtime']['settingsManager'].shutdownDriver('soundDriver')
|
||||||
self.env['runtime']['settingsManager'].shutdownDriver('speechDriver')
|
self.env['runtime']['settingsManager'].shutdownDriver('speechDriver')
|
||||||
|
|
||||||
def presentText(self, text, interrupt=True, soundIcon = ''):
|
def presentText(self, text, interrupt=True, soundIcon = '', ignorePunctuation=False):
|
||||||
self.env['runtime']['debug'].writeDebugOut("presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO)
|
||||||
if self.playSoundIcon(soundIcon, interrupt):
|
if self.playSoundIcon(soundIcon, interrupt):
|
||||||
self.env['runtime']['debug'].writeDebugOut("soundIcon found" ,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("soundIcon found" ,debug.debugLevel.INFO)
|
||||||
@ -28,7 +28,7 @@ class outputManager():
|
|||||||
self.speakText(text, interrupt)
|
self.speakText(text, interrupt)
|
||||||
self.brailleText(text, interrupt)
|
self.brailleText(text, interrupt)
|
||||||
|
|
||||||
def speakText(self, text, interrupt=True):
|
def speakText(self, text, interrupt=True, ignorePunctuation=False):
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'enabled'):
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'enabled'):
|
||||||
self.env['runtime']['debug'].writeDebugOut("Speech disabled in outputManager.speakText",debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Speech disabled in outputManager.speakText",debug.debugLevel.INFO)
|
||||||
return
|
return
|
||||||
@ -74,8 +74,10 @@ class outputManager():
|
|||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
text = self.env['runtime']['punctuationManager'].proceedPunctuation(text,ignorePunctuation)
|
||||||
self.env['runtime']['speechDriver'].speak(text)
|
self.env['runtime']['speechDriver'].speak(text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# Fenrir TTY screen reader
|
# Fenrir TTY screen reader
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
|
import string
|
||||||
from core import debug
|
from core import debug
|
||||||
|
|
||||||
class punctuationManager():
|
class punctuationManager():
|
||||||
@ -12,7 +13,7 @@ class punctuationManager():
|
|||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
self.punctuation = {
|
self.punctuation = {
|
||||||
'currLevel':'1',
|
'currLevel':'3',
|
||||||
'levels':{
|
'levels':{
|
||||||
'1':',',
|
'1':',',
|
||||||
'2':'.',
|
'2':'.',
|
||||||
@ -39,16 +40,18 @@ class punctuationManager():
|
|||||||
return resultText
|
return resultText
|
||||||
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
||||||
resultText = str(text)
|
resultText = str(text)
|
||||||
if punctuationDict and punctuation != '':
|
|
||||||
|
if punctuationDict and punctuation and punctuation != '':
|
||||||
for key,item in punctuationDict.items():
|
for key,item in punctuationDict.items():
|
||||||
if key in punctuation:
|
if key in punctuation:
|
||||||
resultText = resultText.replace(str(key),' ' +str(item) +' ')
|
resultText = resultText.replace(str(key),' ' +str(item) +' ')
|
||||||
|
|
||||||
return resultText
|
return resultText
|
||||||
|
|
||||||
def proceedPunctuation(self, text, ignoreLevel=False):
|
def proceedPunctuation(self, text, ignorePunctuation=False):
|
||||||
resultText = self.useCustomDict(text, self.punctuation['customDict'])
|
resultText = self.useCustomDict(text, self.punctuation['customDict'])
|
||||||
currPunctLevel = ''
|
currPunctLevel = ''
|
||||||
if not ignoreLevel:
|
if not ignorePunctuation and self.punctuation['currLevel'] in self.punctuation['levels']:
|
||||||
currPunctLevel = self.punctuation['levels'][self.punctuation['currLevel']]
|
currPunctLevel = self.punctuation['levels'][self.punctuation['currLevel']]
|
||||||
else:
|
else:
|
||||||
currPunctLevel = string.punctuation
|
currPunctLevel = string.punctuation
|
||||||
|
Loading…
Reference in New Issue
Block a user