From 1e195ee063e4fda51abe8668d7d95a28dba83501 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 22 Oct 2017 23:35:47 +0200 Subject: [PATCH] improve emacspeak driver --- src/fenrir/speechDriver/emacspeakDriver.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/fenrir/speechDriver/emacspeakDriver.py b/src/fenrir/speechDriver/emacspeakDriver.py index 53981452..9139b334 100644 --- a/src/fenrir/speechDriver/emacspeakDriver.py +++ b/src/fenrir/speechDriver/emacspeakDriver.py @@ -9,6 +9,7 @@ from core import debug from subprocess import Popen, PIPE import pexpect import sys +import time class driver(): def __init__(self): @@ -35,9 +36,14 @@ class driver(): if not queueable: self.cancel() try: - self.server.sendline('tts_say ' + '\"' + text +'\"') + cleanText = text.replace('}', '\}') + cleanText = cleanText.replace('{', '\{') + cleanText = cleanText.replace('*', '\*') + cleanText = cleanText.replace('"', '\"') + cleanText = cleanText.replace('\n', ' ') + cleanText = cleanText.replace('[', '\[') #print(text.replace('"', '\\\"')) - self.server.sendline('tts_say ' + '"' + text.replace('"', '\"') +'"') + self.server.sendline('tts_say ' + '"' + cleanText +'"') except Exception as e: self.env['runtime']['debug'].writeDebugOut('speechDriver:speak:self.server.sendline():' + str(e),debug.debugLevel.ERROR) @@ -45,7 +51,7 @@ class driver(): if not self._isInitialized: return try: - self.server.sendline('s') + self.server.sendline('s') except Exception as e: self.env['runtime']['debug'].writeDebugOut('speechDriver:cancel:self.server.sendline():' + str(e),debug.debugLevel.ERROR) @@ -67,7 +73,7 @@ class driver(): if not self._isInitialized: return try: - self.server.sendline('tts_set_speech_rate' + str(int(rate * 500))) + 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,6 +82,6 @@ class driver(): def setLanguage(self, language): if not self._isInitialized: return - self.server.sendline('set_lang ' + language) + self.server.sendline('set_lang ' + language + '') def setVolume(self, volume): pass