fix emacspeak driver
This commit is contained in:
parent
35a9171c1f
commit
fa58953306
@ -5,11 +5,8 @@
|
|||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
# generic driver
|
# generic driver
|
||||||
|
|
||||||
from subprocess import Popen, PIPE
|
|
||||||
import pexpect
|
import pexpect
|
||||||
import ptyprocess
|
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
from fenrirscreenreader.core import debug
|
from fenrirscreenreader.core import debug
|
||||||
from fenrirscreenreader.core.speechDriver import speechDriver
|
from fenrirscreenreader.core.speechDriver import speechDriver
|
||||||
@ -20,12 +17,10 @@ class driver(speechDriver):
|
|||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
try:
|
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.server = pexpect.spawn('tclsh ' + self.env['runtime']['settingsManager'].getSetting('speech', 'serverPath'))
|
||||||
self._isInitialized = True
|
self._isInitialized = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:initialize:' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('speechDriver:initialize:' + str(e),debug.debugLevel.ERROR)
|
||||||
print(e)
|
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
if self.server:
|
if self.server:
|
||||||
@ -40,16 +35,15 @@ class driver(speechDriver):
|
|||||||
if not queueable:
|
if not queueable:
|
||||||
self.cancel()
|
self.cancel()
|
||||||
try:
|
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):
|
for idx, word in enumerate(cleanText):
|
||||||
cleanText[idx] = word
|
cleanText[idx] = word
|
||||||
cleanText = ' '.join(cleanText)
|
cleanText = ' '.join(cleanText)
|
||||||
#print(cleanText[0])
|
cleanText = 'tts_say \"' + cleanText +'\"'
|
||||||
#self.server.write('tts_say ' + '"' + cleanText[0] +'"\n')
|
|
||||||
#print(self.server.read(1000))
|
|
||||||
#self.server.sendline('tts_say ' + '"' + cleanText + '"')
|
|
||||||
self.server.sendline(cleanText)
|
self.server.sendline(cleanText)
|
||||||
print(cleanText)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:speak:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
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:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
pass
|
self.server.sendline('stop')
|
||||||
#self.server.write('s\n')
|
|
||||||
#print(self.server.read(1000))
|
|
||||||
#self.server.sendline('stop')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:cancel:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
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:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
pass
|
self.server.sendline('tts_set_speech_rate ' + str(int(rate * 400)))
|
||||||
#self.server.write('tts_set_speech_rate ' + str(int(rate * 400)) + '\n')
|
|
||||||
#self.server.sendline('tts_set_speech_rate ' + str(int(rate * 400)) + '')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut('speechDriver:setRate:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('speechDriver:setRate:self.server.sendline():' + str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def setLanguage(self, language):
|
def setLanguage(self, language):
|
||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
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