Merge branch 'bleed'
This commit is contained in:
commit
d01bd47833
@ -75,7 +75,6 @@ Braille Support:
|
||||
|
||||
Driver (speech):
|
||||
[S] talkey driver ( verry unresponsive for espeak in linux)
|
||||
[S] emacspeak driver (breaks for a whole screen)
|
||||
https://pypi.python.org/pypi/ptyprocess#downloads
|
||||
https://github.com/tbsaunde/yasr/blob/master/yasr/tts.c
|
||||
[] Dectalk SpeechDriver (Easy for contribution, device needed - i dont own one)
|
||||
|
5
realese nots/1.9.4
Normal file
5
realese nots/1.9.4
Normal file
@ -0,0 +1,5 @@
|
||||
- initial working emacspeak driver
|
||||
- fixes for fenrir-ignore-screen/ fenrir-unignore-screen management tools
|
||||
- settings and sections are now case sensitive (this makes it possible to make better validity checks.)
|
||||
- validate datatype for settings you set with "-o" parameter or remotemanager "setting set"
|
||||
- variouse speedups and bugfixes
|
@ -16,14 +16,14 @@ class fenrirManager():
|
||||
self.initialized = False
|
||||
cliArgs = self.handleArgs()
|
||||
if not cliArgs:
|
||||
return
|
||||
return
|
||||
try:
|
||||
self.environment = settingsManager.settingsManager().initFenrirConfig(cliArgs, self)
|
||||
if not self.environment:
|
||||
raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable')
|
||||
except RuntimeError:
|
||||
raise
|
||||
self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True)
|
||||
self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True)
|
||||
signal.signal(signal.SIGINT, self.captureSignal)
|
||||
signal.signal(signal.SIGTERM, self.captureSignal)
|
||||
self.initialized = True
|
||||
@ -35,11 +35,11 @@ class fenrirManager():
|
||||
args = None
|
||||
parser = argparse.ArgumentParser(description="Fenrir Help")
|
||||
parser.add_argument('-s', '--setting', metavar='SETTING-FILE', default='/etc/fenrir/settings/settings.conf', help='Use a specified settingsfile')
|
||||
parser.add_argument('-o', '--options', metavar='SECTION#SETTING=VALUE;..', default='', help='Overwrite options in given settings file')
|
||||
parser.add_argument('-o', '--options', metavar='SECTION#SETTING=VALUE;..', default='', help='Overwrite options in given settings file. Sections, settings and Values are cases sensitive')
|
||||
parser.add_argument('-d', '--debug', action='store_true', help='Turns on Debugmode')
|
||||
parser.add_argument('-p', '--print', action='store_true', help='Print debug messages on screen')
|
||||
parser.add_argument('-e', '--emulated-pty', action='store_true', help='Use PTY emulation and escape sequences for input')
|
||||
parser.add_argument('-E', '--emulated-evdev', action='store_true', help='Use PTY emulation and evdev for input (single instance)')
|
||||
parser.add_argument('-p', '--print', action='store_true', help='Print debug messages on screen')
|
||||
parser.add_argument('-e', '--emulated-pty', action='store_true', help='Use PTY emulation and escape sequences for input')
|
||||
parser.add_argument('-E', '--emulated-evdev', action='store_true', help='Use PTY emulation and evdev for input (single instance)')
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
except Exception as e:
|
||||
@ -52,38 +52,38 @@ class fenrirManager():
|
||||
self.shutdown()
|
||||
def handleInput(self, event):
|
||||
#startTime = time.time()
|
||||
self.environment['runtime']['debug'].writeDebugOut('DEBUG INPUT fenrirMan:' + str(event),debug.debugLevel.INFO)
|
||||
self.environment['runtime']['debug'].writeDebugOut('DEBUG INPUT fenrirMan:' + str(event),debug.debugLevel.INFO)
|
||||
if not event['Data']:
|
||||
event['Data'] = self.environment['runtime']['inputManager'].getInputEvent()
|
||||
if event['Data']:
|
||||
event['Data']['EventName'] = self.environment['runtime']['inputManager'].convertEventName(event['Data']['EventName'])
|
||||
if event['Data']:
|
||||
event['Data']['EventName'] = self.environment['runtime']['inputManager'].convertEventName(event['Data']['EventName'])
|
||||
self.environment['runtime']['inputManager'].handleInputEvent(event['Data'])
|
||||
else:
|
||||
return
|
||||
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||
self.environment['runtime']['inputManager'].clearLastDeepInput()
|
||||
if self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
else:
|
||||
if self.environment['runtime']['helpManager'].isTutorialMode():
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
|
||||
self.detectShortcutCommand()
|
||||
self.detectShortcutCommand()
|
||||
|
||||
if self.modifierInput:
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
if self.singleKeyCommand:
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
else:
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
self.modifierInput = False
|
||||
self.singleKeyCommand = False
|
||||
if self.environment['input']['keyForeward'] > 0:
|
||||
self.environment['input']['keyForeward'] -=1
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onKeyInput')
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onKeyInput')
|
||||
#print('handleInput:',time.time() - startTime)
|
||||
def handleByteInput(self, event):
|
||||
if not event['Data']:
|
||||
|
30
src/fenrirscreenreader/core/sayAllManager.py
Normal file
30
src/fenrirscreenreader/core/sayAllManager.py
Normal file
@ -0,0 +1,30 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
|
||||
class sayAllManager():
|
||||
def __init__(self):
|
||||
self.isActive = False
|
||||
self.isActiveLock = None
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def setIsActive(self, isActive):
|
||||
pass
|
||||
def start(self):
|
||||
pass
|
||||
def isSayAllActive(self):
|
||||
pass
|
||||
def sayAllWorker(self):
|
||||
pass
|
||||
def stop(self):
|
||||
pass
|
||||
def finish(self):
|
||||
pass
|
||||
def gotoNextPage(self):
|
||||
pass
|
@ -28,6 +28,7 @@ from fenrirscreenreader.core import byteManager
|
||||
from fenrirscreenreader.core import attributeManager
|
||||
from fenrirscreenreader.core import barrierManager
|
||||
from fenrirscreenreader.core import remoteManager
|
||||
from fenrirscreenreader.core import sayAllManager
|
||||
from fenrirscreenreader.core import environment
|
||||
from fenrirscreenreader.core.settingsData import settingsData
|
||||
from fenrirscreenreader.core import debug
|
||||
@ -50,7 +51,7 @@ class settingsManager():
|
||||
break
|
||||
line = line.replace('\n','')
|
||||
if line.replace(" ","") == '':
|
||||
continue
|
||||
continue
|
||||
if line.replace(" ","").startswith("#"):
|
||||
continue
|
||||
if line.count("=") != 1:
|
||||
@ -103,7 +104,7 @@ class settingsManager():
|
||||
def getSetting(self, section, setting):
|
||||
value = ''
|
||||
try:
|
||||
value = self.settingArgDict[section.lower()][setting.lower()]
|
||||
value = self.settingArgDict[section][setting]
|
||||
return value
|
||||
except:
|
||||
pass
|
||||
@ -116,7 +117,7 @@ class settingsManager():
|
||||
def getSettingAsInt(self, section, setting):
|
||||
value = 0
|
||||
try:
|
||||
value = int(self.settingArgDict[section.lower()][setting.lower()])
|
||||
value = int(self.settingArgDict[section][setting])
|
||||
return value
|
||||
except Exception as e:
|
||||
pass
|
||||
@ -129,7 +130,7 @@ class settingsManager():
|
||||
def getSettingAsFloat(self, section, setting):
|
||||
value = 0.0
|
||||
try:
|
||||
value = float(self.settingArgDict[section.lower()][setting.lower()])
|
||||
value = float(self.settingArgDict[section][setting])
|
||||
return value
|
||||
except Exception as e:
|
||||
pass
|
||||
@ -142,10 +143,10 @@ class settingsManager():
|
||||
def getSettingAsBool(self, section, setting):
|
||||
value = False
|
||||
try:
|
||||
value = self.settingArgDict[section.lower()][setting.lower()].upper() in ['1','YES','JA','TRUE']
|
||||
value = self.settingArgDict[section][setting].upper() in ['1','YES','JA','TRUE']
|
||||
return value
|
||||
except Exception as e:
|
||||
pass
|
||||
pass
|
||||
try:
|
||||
value = self.env['settings'].getboolean(section, setting)
|
||||
except:
|
||||
@ -154,8 +155,10 @@ class settingsManager():
|
||||
|
||||
def loadDriver(self, driverName, driverType):
|
||||
try:
|
||||
if self.env['runtime'][driverType] != None:
|
||||
self.env['runtime'][driverType].shutdown(self.env)
|
||||
self.env['runtime'][driverType].shutdown(self.env)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
driver_mod = module_utils.importModule(driverName,
|
||||
fenrirPath + "/" + driverType + '/' + driverName + '.py')
|
||||
self.env['runtime'][driverType] = driver_mod.driver()
|
||||
@ -170,10 +173,8 @@ class settingsManager():
|
||||
self.env['runtime'][driverType].initialize(self.env)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('(fallback) Loading Driver ' + driverType + ' (dummyDriver) FAILED:'+ str(e), debug.debugLevel.ERROR)
|
||||
|
||||
|
||||
def shutdownDriver(self, driverType):
|
||||
if self.env['runtime'][driverType] == None:
|
||||
return
|
||||
try:
|
||||
self.env['runtime'][driverType].shutdown()
|
||||
except Exception as e:
|
||||
@ -194,14 +195,35 @@ class settingsManager():
|
||||
self.env['input']['scriptKey'].append(key)
|
||||
def resetSettingArgDict(self):
|
||||
self.settingArgDict = {}
|
||||
def setOptionArgDict(self, section, option, value):
|
||||
section = section.lower()
|
||||
option = option.lower()
|
||||
def setOptionArgDict(self, section, setting, value):
|
||||
#section = section.lower()
|
||||
#setting = setting.lower()
|
||||
try:
|
||||
e = self.settingArgDict[section]
|
||||
except KeyError:
|
||||
self.settingArgDict[section] = {}
|
||||
self.settingArgDict[section][option] = str(value)
|
||||
try:
|
||||
t = self.settings[section][setting]
|
||||
except:
|
||||
print(section,setting, 'not found')
|
||||
return
|
||||
try:
|
||||
if isinstance(self.settings[section][setting], str):
|
||||
v = str(value)
|
||||
elif isinstance(self.settings[section][setting], bool):
|
||||
if not value in ['True','False']:
|
||||
raise ValueError('could not convert string to bool: '+ value)
|
||||
elif isinstance(self.settings[section][setting], int):
|
||||
v = int(value)
|
||||
elif isinstance(self.settings[section][setting], float):
|
||||
v = float(value)
|
||||
self.settingArgDict[section][setting] = str(value)
|
||||
except Exception as e:
|
||||
print('settingsManager:setOptionArgDict:Datatype missmatch: '+ section + '#' + setting + '=' + value + ' Error:' + str(e))
|
||||
#self.env['runtime']['debug'].writeDebugOut('settingsManager:setOptionArgDict:Datatype missmatch: '+ section + '#' + setting + '=' + value + ' Error:' + str(e), debug.debugLevel.ERROR)
|
||||
return
|
||||
|
||||
|
||||
|
||||
def parseSettingArgs(self, settingArgs):
|
||||
for optionElem in settingArgs.split(';'):
|
||||
@ -245,20 +267,20 @@ class settingsManager():
|
||||
if cliArgs.options != '':
|
||||
self.parseSettingArgs(cliArgs.options)
|
||||
if cliArgs.debug:
|
||||
self.setOptionArgDict('general', 'debugLevel', 3)
|
||||
self.setSetting('general', 'debugLevel', 3)
|
||||
if cliArgs.print:
|
||||
self.setOptionArgDict('general', 'debugLevel', 3)
|
||||
self.setOptionArgDict('general', 'debugMode', 'PRINT')
|
||||
self.setSetting('general', 'debugLevel', 3)
|
||||
self.setSetting('general', 'debugMode', 'PRINT')
|
||||
if cliArgs.emulated_pty:
|
||||
self.setOptionArgDict('screen', 'driver', 'ptyDriver')
|
||||
self.setOptionArgDict('keyboard', 'driver', 'ptyDriver')
|
||||
self.setSetting('screen', 'driver', 'ptyDriver')
|
||||
self.setSetting('keyboard', 'driver', 'ptyDriver')
|
||||
# TODO needs cleanup use dict
|
||||
#self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty')
|
||||
self.setSetting('keyboard', 'keyboardLayout', 'pty')
|
||||
self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log')
|
||||
self.setSetting('general', 'debugFile', '/tmp/fenrir-pty.log')
|
||||
if cliArgs.emulated_evdev:
|
||||
self.setOptionArgDict('screen', 'driver', 'ptyDriver')
|
||||
self.setOptionArgDict('keyboard', 'driver', 'evdevDriver')
|
||||
self.setSetting('screen', 'driver', 'ptyDriver')
|
||||
self.setSetting('keyboard', 'driver', 'evdevDriver')
|
||||
|
||||
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
|
||||
self.setScriptKeys(self.getSetting('general','scriptKeys'))
|
||||
@ -267,9 +289,9 @@ class settingsManager():
|
||||
environment['runtime']['debug'].initialize(environment)
|
||||
|
||||
if not os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'):
|
||||
if os.path.exists(soundRoot + self.getSetting('sound','theme')):
|
||||
if os.path.exists(soundRoot + self.getSetting('sound','theme')):
|
||||
self.setSetting('sound', 'theme', soundRoot + self.getSetting('sound','theme'))
|
||||
if os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'):
|
||||
if os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'):
|
||||
environment['runtime']['settingsManager'].loadSoundIcons(self.getSetting('sound','theme'))
|
||||
else:
|
||||
environment['runtime']['settingsManager'].loadSoundIcons(self.getSetting('sound','theme'))
|
||||
@ -348,23 +370,23 @@ class settingsManager():
|
||||
environment['runtime']['byteManager'].loadByteShortcuts(self.getSetting('keyboard','keyboardLayout'))
|
||||
else:
|
||||
environment['runtime']['byteManager'].loadByteShortcuts(self.getSetting('keyboard','keyboardLayout'))
|
||||
|
||||
|
||||
environment['runtime']['cursorManager'] = cursorManager.cursorManager()
|
||||
environment['runtime']['cursorManager'].initialize(environment)
|
||||
environment['runtime']['cursorManager'].initialize(environment)
|
||||
environment['runtime']['applicationManager'] = applicationManager.applicationManager()
|
||||
environment['runtime']['applicationManager'].initialize(environment)
|
||||
environment['runtime']['applicationManager'].initialize(environment)
|
||||
environment['runtime']['textManager'] = textManager.textManager()
|
||||
environment['runtime']['textManager'].initialize(environment)
|
||||
environment['runtime']['textManager'].initialize(environment)
|
||||
environment['runtime']['tableManager'] = tableManager.tableManager()
|
||||
environment['runtime']['tableManager'].initialize(environment)
|
||||
environment['runtime']['tableManager'].initialize(environment)
|
||||
environment['runtime']['barrierManager'] = barrierManager.barrierManager()
|
||||
environment['runtime']['barrierManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['debug'].writeDebugOut('\/-------environment-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['barrierManager'].initialize(environment)
|
||||
environment['runtime']['sayAllManager'] = sayAllManager.sayAllManager()
|
||||
environment['runtime']['sayAllManager'].initialize(environment)
|
||||
environment['runtime']['debug'].writeDebugOut('\/-------environment-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['debug'].writeDebugOut(str(environment), debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['debug'].writeDebugOut('\/-------settings.conf-------\/', debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['debug'].writeDebugOut('\/-------settings.conf-------\/', debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['debug'].writeDebugOut(str(environment['settings']._sections) , debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['debug'].writeDebugOut('\/-------self.settingArgDict-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['debug'].writeDebugOut('\/-------self.settingArgDict-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
||||
environment['runtime']['debug'].writeDebugOut(str( self.settingArgDict) ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||
return environment
|
||||
|
||||
|
@ -5,11 +5,8 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# generic driver
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
import pexpect
|
||||
import ptyprocess
|
||||
import shlex
|
||||
import sys
|
||||
import time
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.core.speechDriver import speechDriver
|
||||
@ -20,13 +17,11 @@ class driver(speechDriver):
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
try:
|
||||
#self.server = ptyprocess.PtyProcessUnicode.spawn(['/usr/bin/tclsh', self.env['runtime']['settingsManager'].getSetting('speech', 'serverPath')])
|
||||
self.server = pexpect.spawn('tclsh ' + self.env['runtime']['settingsManager'].getSetting('speech', 'serverPath'))
|
||||
self._isInitialized = True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:initialize:' + str(e),debug.debugLevel.ERROR)
|
||||
print(e)
|
||||
|
||||
|
||||
def shutdown(self):
|
||||
if self.server:
|
||||
try:
|
||||
@ -40,16 +35,15 @@ class driver(speechDriver):
|
||||
if not queueable:
|
||||
self.cancel()
|
||||
try:
|
||||
cleanText = shlex.split('tts_say "'+text.replace(',','')+'"')
|
||||
cleanText = text
|
||||
for c in '[]{}\\|_@#^*<>\"`~^':
|
||||
cleanText.replace(c,'')
|
||||
cleanText = shlex.split(cleanText)
|
||||
for idx, word in enumerate(cleanText):
|
||||
cleanText[idx] = word
|
||||
cleanText = ' '.join(cleanText)
|
||||
#print(cleanText[0])
|
||||
#self.server.write('tts_say ' + '"' + cleanText[0] +'"\n')
|
||||
#print(self.server.read(1000))
|
||||
#self.server.sendline('tts_say ' + '"' + cleanText + '"')
|
||||
cleanText = 'tts_say \"' + cleanText +'\"'
|
||||
self.server.sendline(cleanText)
|
||||
print(cleanText)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:speak:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
@ -57,10 +51,7 @@ class driver(speechDriver):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
pass
|
||||
#self.server.write('s\n')
|
||||
#print(self.server.read(1000))
|
||||
#self.server.sendline('stop')
|
||||
self.server.sendline('stop')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:cancel:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
||||
@ -69,14 +60,11 @@ class driver(speechDriver):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
pass
|
||||
#self.server.write('tts_set_speech_rate ' + str(int(rate * 400)) + '\n')
|
||||
#self.server.sendline('tts_set_speech_rate ' + str(int(rate * 400)) + '')
|
||||
self.server.sendline('tts_set_speech_rate ' + str(int(rate * 400)))
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:setRate:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def setLanguage(self, language):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
#self.server.write('set_lang ' + language + '\n')
|
||||
#self.server.sendline('set_lang ' + language + '')
|
||||
self.server.sendline('set_lang ' + language)
|
||||
|
Loading…
Reference in New Issue
Block a user