implement sd driver
This commit is contained in:
parent
eef85bafa9
commit
5c31ab691b
@ -7,6 +7,7 @@ import hashlib
|
|||||||
import difflib
|
import difflib
|
||||||
import textwrap
|
import textwrap
|
||||||
import speech.es as es
|
import speech.es as es
|
||||||
|
import speech.sd as sd
|
||||||
|
|
||||||
runtime = {
|
runtime = {
|
||||||
'running':True,
|
'running':True,
|
||||||
@ -22,8 +23,8 @@ runtime = {
|
|||||||
'newContentBytes': b'',
|
'newContentBytes': b'',
|
||||||
'newContentText': '',
|
'newContentText': '',
|
||||||
'newContentAttrib': b'',
|
'newContentAttrib': b'',
|
||||||
'speechDriverString':'es',
|
'speechDriverString':'sd',
|
||||||
'speechDriver': es.speech()
|
'speechDriver': sd.speech()
|
||||||
}
|
}
|
||||||
|
|
||||||
while(runtime['running']):
|
while(runtime['running']):
|
||||||
@ -46,7 +47,7 @@ while(runtime['running']):
|
|||||||
# changes on the screen
|
# changes on the screen
|
||||||
if runtime['oldContentBytes'] != runtime['newContentBytes']:
|
if runtime['oldContentBytes'] != runtime['newContentBytes']:
|
||||||
if len(runtime['delta']) < 3:
|
if len(runtime['delta']) < 3:
|
||||||
runtime['speechDriver'].stop()
|
runtime['speechDriver'].cancel()
|
||||||
print("tty3 changed")
|
print("tty3 changed")
|
||||||
|
|
||||||
diff = difflib.ndiff(runtime['oldContentText'], runtime['newContentText'])
|
diff = difflib.ndiff(runtime['oldContentText'], runtime['newContentText'])
|
||||||
|
BIN
src/speech/__pycache__/es.cpython-35.pyc
Normal file
BIN
src/speech/__pycache__/es.cpython-35.pyc
Normal file
Binary file not shown.
BIN
src/speech/__pycache__/sd.cpython-35.pyc
Normal file
BIN
src/speech/__pycache__/sd.cpython-35.pyc
Normal file
Binary file not shown.
@ -17,11 +17,11 @@ class speech():
|
|||||||
def speak(self,text, queueable=True):
|
def speak(self,text, queueable=True):
|
||||||
if not self.isInitialized:
|
if not self.isInitialized:
|
||||||
return False
|
return False
|
||||||
if queueable == False: self.stop()
|
if queueable == False: self.cancel()
|
||||||
self.es.synth(text)
|
self.es.synth(text)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def stop(self):
|
def cancel(self):
|
||||||
if not self.isInitialized:
|
if not self.isInitialized:
|
||||||
return False
|
return False
|
||||||
self.es.cancel()
|
self.es.cancel()
|
||||||
@ -46,4 +46,5 @@ class speech():
|
|||||||
if not self.isInitialized:
|
if not self.isInitialized:
|
||||||
return False
|
return False
|
||||||
return es.set_parameter(espeak.Parameter.Rate, speed)
|
return es.set_parameter(espeak.Parameter.Rate, speed)
|
||||||
|
def shutdown(self):
|
||||||
|
pass
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# speech-dispatcher driver
|
||||||
|
|
||||||
|
class speech():
|
||||||
|
def __init__(self, ):
|
||||||
|
self.sd = None
|
||||||
|
self.isInitialized = False
|
||||||
|
try:
|
||||||
|
import speechd
|
||||||
|
self.sd = speechd.SSIPClient('fenrir')
|
||||||
|
self.isInitialized = True
|
||||||
|
except:
|
||||||
|
self.initialized = False
|
||||||
|
|
||||||
|
|
||||||
|
def speak(self,text, queueable=True):
|
||||||
|
if not self.isInitialized:
|
||||||
|
return False
|
||||||
|
if queueable == False: self.cancel()
|
||||||
|
self.sd.speak(text)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def cancel(self):
|
||||||
|
if not self.isInitialized:
|
||||||
|
return False
|
||||||
|
self.sd.cancel()
|
||||||
|
return True
|
||||||
|
|
||||||
|
def clear_buffer(self):
|
||||||
|
if not self.isInitialized:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def setVoice(self, voice):
|
||||||
|
if not self.isInitialized:
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
self.sd.set_voice(voice)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def setPitch(self, pitch):
|
||||||
|
if not self.isInitialized:
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
self.sd.set_pitch(pitch)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def setSpeed(self, speed):
|
||||||
|
if not self.isInitialized:
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
self.sd.set_rate(speed)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def shutdown(self):
|
||||||
|
self.cancel()
|
||||||
|
self.sd.close()
|
Loading…
Reference in New Issue
Block a user