start inherit drivers
This commit is contained in:
parent
fc53810e14
commit
cd49aa3dca
@ -5,51 +5,8 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
from core.brailleDriver import brailleDriver
|
||||
|
||||
class driver():
|
||||
class driver(brailleDriver):
|
||||
def __init__(self):
|
||||
self.printMessages = False
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self._isInitialized = True
|
||||
self.deviceSize = (40,0)
|
||||
if self.printMessages:
|
||||
print('BrailleDummyDriver: Initialize')
|
||||
|
||||
|
||||
def getDeviceSize(self):
|
||||
if not self._isInitialized:
|
||||
return (0,0)
|
||||
if self.printMessages:
|
||||
print('BrailleDummyDriver: getDeviceSize ' + str(self.deviceSize))
|
||||
return self.deviceSize
|
||||
|
||||
def writeText(self,text):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if self.printMessages:
|
||||
print('BrailleDummyDriver: writeText:' + str(text))
|
||||
print('BrailleDummyDriver: -----------------------------------')
|
||||
|
||||
def connectDevice(self):
|
||||
if self.printMessages:
|
||||
print('BrailleDummyDriver: connectDevice')
|
||||
|
||||
def enterScreen(self, screen):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if self.printMessages:
|
||||
print('BrailleDummyDriver: enterScreen')
|
||||
|
||||
def leveScreen(self):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if self.printMessages:
|
||||
print('BrailleDummyDriver: leveScreen')
|
||||
|
||||
def shutdown(self):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if self.printMessages:
|
||||
print('BrailleDummyDriver: Shutdown')
|
||||
brailleDriver.__init__(self)
|
||||
|
@ -6,55 +6,13 @@
|
||||
|
||||
import time
|
||||
from core import debug
|
||||
from core.inputDriver import inputDriver
|
||||
|
||||
class driver():
|
||||
class driver(inputDriver):
|
||||
def __init__(self):
|
||||
self._initialized = False
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
inputDriver.__init__(self)
|
||||
|
||||
def getInputEvent(self):
|
||||
time.sleep(0.05)
|
||||
if not self._initialized:
|
||||
return None
|
||||
|
||||
def writeEventBuffer(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
|
||||
def clearEventBuffer(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
del self.env['input']['eventBuffer'][:]
|
||||
|
||||
def updateInputDevices(self, force = False, init = False):
|
||||
if not self._initialized:
|
||||
return
|
||||
|
||||
def getLedState(self, led = 0):
|
||||
if not self._initialized:
|
||||
return False
|
||||
return False
|
||||
|
||||
def toggleLedState(self, led = 0):
|
||||
if not self._initialized:
|
||||
return None
|
||||
|
||||
def grabDevices(self):
|
||||
if not self._initialized:
|
||||
return None
|
||||
|
||||
def releaseDevices(self):
|
||||
if not self._initialized:
|
||||
return None
|
||||
|
||||
def __del__(self):
|
||||
if not self._initialized:
|
||||
return None
|
||||
self.releaseDevices()
|
||||
|
||||
|
||||
|
@ -5,51 +5,8 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
from core.soundDriver import soundDriver
|
||||
|
||||
class driver():
|
||||
class driver(soundDriver):
|
||||
def __init__(self):
|
||||
self.volume = None
|
||||
self._initialized = False
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self._initialized = True
|
||||
print('SoundDummyDriver: Initialize')
|
||||
|
||||
def shutdown(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
self.cancel()
|
||||
print('SoundDummyDriver: Shutdown')
|
||||
|
||||
def playFrequence(self, frequence = 1000, duration = 0.3, adjustVolume = 0):
|
||||
if not self._initialized:
|
||||
return
|
||||
if interrupt:
|
||||
self.cancel()
|
||||
print('SoundDummyDriver: playFrequence:' + ' freq:' + str(frequence) + ' duration:' + str(duration) + ' adjustVolume:' + str(adjustVolume) )
|
||||
print('SoundDummyDriver: -----------------------------------')
|
||||
|
||||
def playSoundFile(self, filePath, interrupt = True):
|
||||
if not self._initialized:
|
||||
return
|
||||
if interrupt:
|
||||
self.cancel()
|
||||
print('SoundDummyDriver: playSoundFile:' + str(filePath))
|
||||
print('SoundDummyDriver: -----------------------------------')
|
||||
|
||||
def cancel(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('SoundDummyDriver: Cancel')
|
||||
|
||||
def setCallback(self, callback):
|
||||
if not self._initialized:
|
||||
return
|
||||
print('SoundDummyDriver: setCallback')
|
||||
|
||||
def setVolume(self, volume):
|
||||
if not self._initialized:
|
||||
return
|
||||
self.volume = volume
|
||||
print('SoundDummyDriver: setVolume:' + str(self.volume))
|
||||
soundDriver.__init__(self)
|
||||
|
@ -6,15 +6,15 @@
|
||||
|
||||
from core import debug
|
||||
import subprocess
|
||||
from core.soundDriver import soundDriver
|
||||
|
||||
class driver():
|
||||
class driver(soundDriver):
|
||||
def __init__(self):
|
||||
soundDriver.__init__(self)
|
||||
self.proc = None
|
||||
self.volume = 1.0
|
||||
self.soundType = ''
|
||||
self.soundFileCommand = ''
|
||||
self.frequenceCommand = ''
|
||||
self._initialized = False
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.soundFileCommand = self.env['runtime']['settingsManager'].getSetting('sound', 'genericPlayFileCommand')
|
||||
@ -24,10 +24,7 @@ class driver():
|
||||
if self.frequenceCommand == '':
|
||||
self.frequenceCommand = 'play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence'
|
||||
self._initialized = True
|
||||
def shutdown(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
self.cancel()
|
||||
|
||||
def playFrequence(self, frequence = 1000, duration = 0.3, adjustVolume = 0):
|
||||
if not self._initialized:
|
||||
return
|
||||
@ -56,11 +53,4 @@ class driver():
|
||||
self.proc.kill()
|
||||
if self.soundType == 'frequence':
|
||||
self.proc.kill()
|
||||
self.soundType = ''
|
||||
def setCallback(self, callback):
|
||||
if not self._initialized:
|
||||
return
|
||||
def setVolume(self, volume):
|
||||
if not self._initialized:
|
||||
return
|
||||
self.volume = volume
|
||||
self.soundType = ''
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
from core import debug
|
||||
import time, threading
|
||||
|
||||
from core.soundDriver import soundDriver
|
||||
|
||||
_gstreamerAvailable = False
|
||||
try:
|
||||
@ -19,12 +19,11 @@ except Exception as e:
|
||||
_gstreamerAvailable = False
|
||||
_availableError = str(e)
|
||||
|
||||
class driver:
|
||||
class driver(soundDriver):
|
||||
def __init__(self):
|
||||
soundDriver.__init__(self)
|
||||
self._source = None
|
||||
self._sink = None
|
||||
self.volume = 1
|
||||
self._initialized = False
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
@ -112,10 +111,3 @@ class driver:
|
||||
return
|
||||
self._player.set_state(Gst.State.NULL)
|
||||
self._pipeline.set_state(Gst.State.NULL)
|
||||
def setVolume(self, volume):
|
||||
if not self._initialized:
|
||||
return
|
||||
self.volume = volume
|
||||
|
||||
|
||||
|
||||
|
@ -6,65 +6,7 @@
|
||||
# generic driver
|
||||
|
||||
from core import debug
|
||||
|
||||
class driver():
|
||||
from core.speechDriver import speechDriver
|
||||
class driver(speechDriver):
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self._isInitialized = True
|
||||
self.env = environment
|
||||
print('SpeechDummyDriver: Iitialize')
|
||||
|
||||
def shutdown(self):
|
||||
print('SpeechDummyDriver: Shutdown')
|
||||
|
||||
def speak(self,text, queueable=True):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if not queueable:
|
||||
self.cancel()
|
||||
print('SpeechDummyDriver: Speak:'+text)
|
||||
print('SpeechDummyDriver: -----------------------------------')
|
||||
|
||||
def cancel(self):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: Cancel')
|
||||
|
||||
def setCallback(self, callback):
|
||||
print('SpeechDummyDriver: setCallback')
|
||||
|
||||
def clear_buffer(self):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: clear_buffer')
|
||||
|
||||
def setVoice(self, voice):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: setVoice:' + str(voice))
|
||||
|
||||
def setPitch(self, pitch):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: setPitch:' + str(pitch))
|
||||
|
||||
def setRate(self, rate):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: setRate:' + str(rate))
|
||||
|
||||
def setModule(self, module):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: setModule:' + str(module))
|
||||
|
||||
def setLanguage(self, language):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: setLanguage:' + str(language))
|
||||
|
||||
def setVolume(self, volume):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
print('SpeechDummyDriver: setVolume:' + str(volume))
|
||||
speechDriver.__init__(self)
|
||||
|
@ -10,12 +10,12 @@ from subprocess import Popen, PIPE
|
||||
import pexpect
|
||||
import sys
|
||||
import time
|
||||
from core.speechDriver import speechDriver
|
||||
|
||||
class driver():
|
||||
class driver(speechDriver):
|
||||
def __init__(self):
|
||||
pass
|
||||
speechDriver.__init__(self)
|
||||
def initialize(self, environment):
|
||||
self._isInitialized = False
|
||||
self.env = environment
|
||||
try:
|
||||
self.server = pexpect.spawnu('tclsh ' + self.env['runtime']['settingsManager'].getSetting('speech', 'serverPath'))
|
||||
@ -55,20 +55,6 @@ class driver():
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:cancel:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
def clear_buffer(self):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
|
||||
def setVoice(self, voice):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
|
||||
def setPitch(self, pitch):
|
||||
pass
|
||||
|
||||
def setRate(self, rate):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
@ -77,11 +63,7 @@ class driver():
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:setRate:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def setModule(self, module):
|
||||
pass
|
||||
def setLanguage(self, language):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
self.server.sendline('set_lang ' + language + '')
|
||||
def setVolume(self, volume):
|
||||
pass
|
||||
|
@ -6,11 +6,12 @@
|
||||
# Espeak driver
|
||||
|
||||
from core import debug
|
||||
from core.speechDriver import speechDriver
|
||||
|
||||
class driver():
|
||||
class driver(speechDriver):
|
||||
def __init__(self):
|
||||
speechDriver.__init__(self)
|
||||
self._es = None
|
||||
self._isInitialized = False
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
@ -21,15 +22,18 @@ class driver():
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||
self._initialized = False
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def speak(self,text, interrupt=True):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if not interrupt:
|
||||
self.cancel()
|
||||
if self.language != None:
|
||||
if self.language != '':
|
||||
self._es.set_voice(self.language)
|
||||
elif self.voice != None:
|
||||
if self.voice != '':
|
||||
self._es.set_voice(self.voice)
|
||||
self._es.synth(text)
|
||||
|
||||
def cancel(self):
|
||||
@ -38,20 +42,6 @@ class driver():
|
||||
self._es.cancel()
|
||||
return True
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
def clear_buffer(self):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
|
||||
def setVoice(self, voice):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if voice =='':
|
||||
return
|
||||
return self._es.set_voice(voice)
|
||||
|
||||
def setPitch(self, pitch):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
@ -62,17 +52,6 @@ class driver():
|
||||
return
|
||||
return self._es.set_parameter(self._es.Parameter().Rate, int(rate * 500 + 100))
|
||||
|
||||
def setModule(self, module):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
|
||||
def setLanguage(self, language):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if language =='':
|
||||
return
|
||||
return self._es.set_voice(language)
|
||||
|
||||
def setVolume(self, volume):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
|
@ -6,12 +6,12 @@
|
||||
# speech-dispatcher driver
|
||||
|
||||
from core import debug
|
||||
from core.speechDriver import speechDriver
|
||||
|
||||
class driver():
|
||||
class driver(speechDriver):
|
||||
def __init__(self):
|
||||
speechDriver.__init__(self)
|
||||
self._sd = None
|
||||
self._isInitialized = False
|
||||
self._language = ''
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
@ -22,7 +22,6 @@ class driver():
|
||||
self._isInitialized = True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver initialize:' + str(e),debug.debugLevel.ERROR)
|
||||
self._initialized = False
|
||||
|
||||
def shutdown(self):
|
||||
if not self._isInitialized:
|
||||
@ -42,7 +41,18 @@ class driver():
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
self._sd.set_synthesis_voice(self._language)
|
||||
self._sd.set_output_module(self.module)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver setModule:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
try:
|
||||
if self.voice != '':
|
||||
self._sd.set_voice(self.voice)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver setVoice:' + str(e),debug.debugLevel.ERROR)
|
||||
try:
|
||||
if self.language != '':
|
||||
self._sd.set_synthesis_voice(self.language)
|
||||
self._sd.set_punctuation(self._punct.NONE)
|
||||
self._sd.speak(text)
|
||||
except Exception as e:
|
||||
@ -57,23 +67,7 @@ class driver():
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver cancel:' + str(e),debug.debugLevel.ERROR)
|
||||
self._isInitialized = False
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
def clear_buffer(self):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
|
||||
def setVoice(self, voice):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
if voice != '':
|
||||
self._sd.set_voice(voice)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver setVoice:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
|
||||
def setPitch(self, pitch):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
@ -88,20 +82,7 @@ class driver():
|
||||
try:
|
||||
self._sd.set_rate(int(-100 + rate * 200))
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver setRate:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def setModule(self, module):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
self._sd.set_output_module(module)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver setModule:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def setLanguage(self, language):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
self._language = language
|
||||
self.env['runtime']['debug'].writeDebugOut('speechDriver setRate:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def setVolume(self, volume):
|
||||
if not self._isInitialized:
|
||||
|
Loading…
Reference in New Issue
Block a user