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
|
@ -35,7 +35,7 @@ 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')
|
||||
|
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
|
||||
@ -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,7 +143,7 @@ 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
|
||||
@ -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)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
driver_mod = module_utils.importModule(driverName,
|
||||
fenrirPath + "/" + driverType + '/' + driverName + '.py')
|
||||
self.env['runtime'][driverType] = driver_mod.driver()
|
||||
@ -172,8 +175,6 @@ class settingsManager():
|
||||
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'))
|
||||
@ -359,7 +381,8 @@ class settingsManager():
|
||||
environment['runtime']['tableManager'].initialize(environment)
|
||||
environment['runtime']['barrierManager'] = barrierManager.barrierManager()
|
||||
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)
|
||||
@ -367,4 +390,3 @@ class settingsManager():
|
||||
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,12 +17,10 @@ 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:
|
||||
@ -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