make genericSpeechDriver initial working (voice, pitch, rate and stuff still missing
This commit is contained in:
parent
08c07c86d9
commit
9ba8c627df
@ -22,7 +22,7 @@ class speakQueue(Queue):
|
|||||||
class driver():
|
class driver():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.proc = None
|
self.proc = None
|
||||||
self.speechThread = threading.Thread(target=worker)
|
self.speechThread = Thread(target=self.worker)
|
||||||
self.textQueue = speakQueue()
|
self.textQueue = speakQueue()
|
||||||
self.volume = None
|
self.volume = None
|
||||||
self.rate = None
|
self.rate = None
|
||||||
@ -33,9 +33,11 @@ class driver():
|
|||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self._isInitialized = True
|
self._isInitialized = True
|
||||||
self.env = environment
|
self.env = environment
|
||||||
self.speechCommand = self.env['runtime']['settingsManager'].getSetting('speech', 'genericSpeechCommand')
|
self.speechCommand = ''
|
||||||
|
#self.speechCommand = self.env['runtime']['settingsManager'].getSetting('speech', 'genericSpeechCommand')
|
||||||
if self.speechCommand == '':
|
if self.speechCommand == '':
|
||||||
self.speechCommand = 'espeak fenrirModule fenrirLanguage -v fenrirVoice -p fenrirPitch -v fenrirVolume -s fenrirRate'
|
self.speechCommand = 'spd-say "fenrirText"'
|
||||||
|
#'espeak -a fenrirVolume -s fenrirRate -p fenrirPitch -v fenrirVoice "fenrirText"'
|
||||||
if self._isInitialized:
|
if self._isInitialized:
|
||||||
self.speechThread.start()
|
self.speechThread.start()
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
@ -49,7 +51,12 @@ class driver():
|
|||||||
return
|
return
|
||||||
if not queueable:
|
if not queueable:
|
||||||
self.cancel()
|
self.cancel()
|
||||||
= None
|
self.volume = '200'
|
||||||
|
self.rate = '200'
|
||||||
|
self.pitch = '200'
|
||||||
|
self.module = ''
|
||||||
|
self.language = ''
|
||||||
|
self.voice = 'de'
|
||||||
utterance = {
|
utterance = {
|
||||||
'text': text,
|
'text': text,
|
||||||
'volume': self.volume,
|
'volume': self.volume,
|
||||||
@ -65,7 +72,9 @@ class driver():
|
|||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
self.clear_buffer()
|
self.clear_buffer()
|
||||||
|
if self.proc:
|
||||||
|
self.proc.kill()
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
print('SpeechDummyDriver: setCallback')
|
print('SpeechDummyDriver: setCallback')
|
||||||
|
|
||||||
@ -74,7 +83,6 @@ class driver():
|
|||||||
return
|
return
|
||||||
if not self.textQueue.not_empty:
|
if not self.textQueue.not_empty:
|
||||||
self.textQueue.clear()
|
self.textQueue.clear()
|
||||||
|
|
||||||
def setVoice(self, voice):
|
def setVoice(self, voice):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
@ -112,17 +120,32 @@ class driver():
|
|||||||
if utterance == -1:
|
if utterance == -1:
|
||||||
return
|
return
|
||||||
elif not isinstance(utterance, dict):
|
elif not isinstance(utterance, dict):
|
||||||
if not len(utterance) == 7:
|
continue
|
||||||
continue
|
print(utterance)
|
||||||
print(utterance)#
|
for key, item in utterance.items():
|
||||||
|
if not utterance[key]:
|
||||||
|
utterance[key] = ''
|
||||||
|
|
||||||
popenSpeechCommand = self.speechCommand
|
popenSpeechCommand = self.speechCommand
|
||||||
popenSpeechCommand = self.popenSpeechCommand.replace('fenrirVolume', str(utterance['volume'] ))
|
popenSpeechCommand = popenSpeechCommand.replace('fenrirVolume', str(utterance['volume'] ))
|
||||||
popenSpeechCommand = popenSpeechCommand.replace('fenrirModule', str(utterance['module']))
|
popenSpeechCommand = popenSpeechCommand.replace('fenrirModule', str(utterance['module']))
|
||||||
popenSpeechCommand = popenSpeechCommand.replace('fenrirLanguage', str(utterance['language']))
|
popenSpeechCommand = popenSpeechCommand.replace('fenrirLanguage', str(utterance['language']))
|
||||||
popenSpeechCommand = popenSpeechCommand.replace('fenrirVoice', str(utterance['voice']))
|
popenSpeechCommand = popenSpeechCommand.replace('fenrirVoice', str(utterance['voice']))
|
||||||
popenSpeechCommand = popenSpeechCommand.replace('fenrirPitch', str(utterance['pitch']))
|
popenSpeechCommand = popenSpeechCommand.replace('fenrirPitch', str(utterance['pitch']))
|
||||||
popenSpeechCommand = popenSpeechCommand.replace('fenrirRate', str(utterance['rate'] ))
|
popenSpeechCommand = popenSpeechCommand.replace('fenrirRate', str(utterance['rate'] ))
|
||||||
popenSpeechCommand = popenSpeechCommand.replace('fenrirRate', str(utterance['text'] ))
|
popenSpeechCommand = popenSpeechCommand.replace('fenrirText', str(utterance['text'] ))
|
||||||
|
|
||||||
self.proc = subprocess.Popen(popenSpeechCommand, shell=True)
|
self.proc = Popen(popenSpeechCommand, shell=True)
|
||||||
|
try:
|
||||||
|
self.proc = Popen(popenSpeechCommand , stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding')
|
||||||
|
stderr = stderr.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
|
||||||
|
stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
|
||||||
|
if stderr != '':
|
||||||
|
print('err' + stderr)
|
||||||
|
if stdout != '':
|
||||||
|
print('out' + stdout)
|
||||||
|
except Exception as e:
|
||||||
|
print('except' + str(e))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user