diff --git a/src/fenrir/speechDriver/emacspeakDriver.py b/src/fenrir/speechDriver/emacspeakDriver.py index 488da091..d9d91818 100644 --- a/src/fenrir/speechDriver/emacspeakDriver.py +++ b/src/fenrir/speechDriver/emacspeakDriver.py @@ -8,6 +8,7 @@ from subprocess import Popen, PIPE import pexpect import ptyprocess +import shlex import sys import time from core import debug @@ -19,8 +20,8 @@ class driver(speechDriver): def initialize(self, environment): self.env = environment try: - 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 = 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._isInitialized = True except Exception as e: self.env['runtime']['debug'].writeDebugOut('speechDriver:initialize:' + str(e),debug.debugLevel.ERROR) @@ -39,16 +40,16 @@ class driver(speechDriver): if not queueable: self.cancel() try: - cleanText = text.replace('}', '\}') - cleanText = cleanText.replace('{', '\{') - cleanText = cleanText.replace('*', '\*') - cleanText = cleanText.replace('"', '\"') - cleanText = cleanText.replace('\n', ' ') - cleanText = cleanText.replace('[', '\[') - print(text.replace('"', '\\\"')) - self.server.write('tts_say ' + '"' + cleanText +'"\n') - print(self.server.read(1000)) - #self.server.sendline('tts_say ' + '"' + cleanText +'"') + cleanText = shlex.split('tts_say "'+text.replace(',','')+'"') + for idx, word in enumerate(cleanText): + cleanText[idx] = word + cleanText = ' '.join(cleanText) + #print(cleanText[0]) + #self.server.write('tts_say ' + '"' + cleanText[0] +'"\n') + #print(self.server.read(1000)) + #self.server.sendline('tts_say ' + '"' + cleanText + '"') + self.server.sendline(cleanText) + print(cleanText) except Exception as e: 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: return try: - self.server.write('s\n') - print('drin') - print(self.server.read(1000)) - #self.server.sendline('s') + pass + #self.server.write('s\n') + #print(self.server.read(1000)) + #self.server.sendline('stop') except Exception as e: print(e) 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: return 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)) + '') except Exception as e: 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): if not self._isInitialized: return - self.server.write('set_lang ' + language + '\n') + #self.server.write('set_lang ' + language + '\n') #self.server.sendline('set_lang ' + language + '')