cleanup speechd driver
This commit is contained in:
parent
76e9009a4f
commit
5d3c3f8732
@ -35,12 +35,13 @@ class driver():
|
|||||||
self._isInitialized = False
|
self._isInitialized = False
|
||||||
|
|
||||||
def speak(self,text, queueable=True):
|
def speak(self,text, queueable=True):
|
||||||
|
if not queueable:
|
||||||
|
self.cancel()
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
self.initialize(self.env)
|
self.initialize(self.env)
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return False
|
return
|
||||||
try:
|
try:
|
||||||
if queueable == False: self.cancel()
|
|
||||||
self._sd.set_synthesis_voice(self._language)
|
self._sd.set_synthesis_voice(self._language)
|
||||||
self._sd.set_punctuation(self._punct.NONE)
|
self._sd.set_punctuation(self._punct.NONE)
|
||||||
self._sd.speak(text)
|
self._sd.speak(text)
|
||||||
@ -50,7 +51,10 @@ class driver():
|
|||||||
def cancel(self):
|
def cancel(self):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
self._sd.cancel()
|
self._sd.cancel()
|
||||||
|
except Exception as e:
|
||||||
|
self._isInitialized = False
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
@ -65,32 +69,32 @@ class driver():
|
|||||||
try:
|
try:
|
||||||
if voice != '':
|
if voice != '':
|
||||||
self._sd.set_voice(voice)
|
self._sd.set_voice(voice)
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self._isInitialized = False
|
||||||
|
|
||||||
def setPitch(self, pitch):
|
def setPitch(self, pitch):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self._sd.set_pitch(int(-100 + pitch * 200))
|
self._sd.set_pitch(int(-100 + pitch * 200))
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self._isInitialized = False
|
||||||
|
|
||||||
def setRate(self, rate):
|
def setRate(self, rate):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self._sd.set_rate(int(-100 + rate * 200))
|
self._sd.set_rate(int(-100 + rate * 200))
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self._isInitialized = False
|
||||||
|
|
||||||
def setModule(self, module):
|
def setModule(self, module):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self._sd.set_output_module(module)
|
self._sd.set_output_module(module)
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self._isInitialized = False
|
||||||
|
|
||||||
def setLanguage(self, language):
|
def setLanguage(self, language):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
@ -102,5 +106,5 @@ class driver():
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self._sd.set_volume(int(-100 + volume * 200))
|
self._sd.set_volume(int(-100 + volume * 200))
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self._isInitialized = False
|
||||||
|
Loading…
Reference in New Issue
Block a user