wip emacspeak driver
This commit is contained in:
parent
49ae561d21
commit
d76a613cfd
@ -8,6 +8,7 @@
|
|||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import pexpect
|
import pexpect
|
||||||
import ptyprocess
|
import ptyprocess
|
||||||
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from core import debug
|
from core import debug
|
||||||
@ -19,8 +20,8 @@ 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 = ptyprocess.PtyProcessUnicode.spawn(['/usr/bin/tclsh', self.env['runtime']['settingsManager'].getSetting('speech', 'serverPath')])
|
||||||
#self.server = pexpect.spawnu('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)
|
||||||
@ -39,16 +40,16 @@ class driver(speechDriver):
|
|||||||
if not queueable:
|
if not queueable:
|
||||||
self.cancel()
|
self.cancel()
|
||||||
try:
|
try:
|
||||||
cleanText = text.replace('}', '\}')
|
cleanText = shlex.split('tts_say "'+text.replace(',','')+'"')
|
||||||
cleanText = cleanText.replace('{', '\{')
|
for idx, word in enumerate(cleanText):
|
||||||
cleanText = cleanText.replace('*', '\*')
|
cleanText[idx] = word
|
||||||
cleanText = cleanText.replace('"', '\"')
|
cleanText = ' '.join(cleanText)
|
||||||
cleanText = cleanText.replace('\n', ' ')
|
#print(cleanText[0])
|
||||||
cleanText = cleanText.replace('[', '\[')
|
#self.server.write('tts_say ' + '"' + cleanText[0] +'"\n')
|
||||||
print(text.replace('"', '\\\"'))
|
#print(self.server.read(1000))
|
||||||
self.server.write('tts_say ' + '"' + cleanText +'"\n')
|
#self.server.sendline('tts_say ' + '"' + cleanText + '"')
|
||||||
print(self.server.read(1000))
|
self.server.sendline(cleanText)
|
||||||
#self.server.sendline('tts_say ' + '"' + 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)
|
||||||
|
|
||||||
@ -56,10 +57,10 @@ class driver(speechDriver):
|
|||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self.server.write('s\n')
|
pass
|
||||||
print('drin')
|
#self.server.write('s\n')
|
||||||
print(self.server.read(1000))
|
#print(self.server.read(1000))
|
||||||
#self.server.sendline('s')
|
#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)
|
||||||
@ -68,7 +69,8 @@ class driver(speechDriver):
|
|||||||
if not self._isInitialized:
|
if not self._isInitialized:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self.server.write('tts_set_speech_rate ' + str(int(rate * 400)) + '\n')
|
pass
|
||||||
|
#self.server.write('tts_set_speech_rate ' + str(int(rate * 400)) + '\n')
|
||||||
#self.server.sendline('tts_set_speech_rate ' + str(int(rate * 400)) + '')
|
#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)
|
||||||
@ -76,5 +78,5 @@ class driver(speechDriver):
|
|||||||
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.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