From b6201235e622cab01e9b036329d7e3b1bc90a934 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 11 Dec 2024 17:31:05 -0500 Subject: [PATCH] Removed the emacs speech driver. Also some cleanup missed from removing the old espeak driver that no longer worked. --- config/settings/settings.conf | 3 - .../speechDriver/emacspeakDriver.py | 70 --------------- .../speechDriver/pyttsxDriver.py | 85 ------------------- 3 files changed, 158 deletions(-) delete mode 100644 src/fenrirscreenreader/speechDriver/emacspeakDriver.py delete mode 100644 src/fenrirscreenreader/speechDriver/pyttsxDriver.py diff --git a/config/settings/settings.conf b/config/settings/settings.conf index ee22a69b..8eb36302 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -36,9 +36,6 @@ enabled=True driver=speechdDriver #driver=genericDriver -# server path for emacspeak -# serverPath= - # The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest. rate=0.5 diff --git a/src/fenrirscreenreader/speechDriver/emacspeakDriver.py b/src/fenrirscreenreader/speechDriver/emacspeakDriver.py deleted file mode 100644 index a09994f6..00000000 --- a/src/fenrirscreenreader/speechDriver/emacspeakDriver.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. -# generic driver - -import pexpect -import shlex -import time -from fenrirscreenreader.core import debug -from fenrirscreenreader.core.speechDriver import speechDriver - -class driver(speechDriver): - def __init__(self): - speechDriver.__init__(self) - def initialize(self, environment): - self.env = environment - try: - 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) - - def shutdown(self): - if self.server: - try: - self.server.terminate() - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('speechDriver:shutdown:self.server.terminate():' + str(e),debug.debugLevel.ERROR) - - def speak(self,text, queueable=True): - if not self._isInitialized: - return - if not queueable: - self.cancel() - try: - cleanText = text - for c in '[]{}\\|_@#^*<>\"`~^': - cleanText.replace(c,'') - cleanText = shlex.split(cleanText) - for idx, word in enumerate(cleanText): - cleanText[idx] = word - cleanText = ' '.join(cleanText) - cleanText = 'tts_say \"' + cleanText +'\"' - self.server.sendline(cleanText) - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('speechDriver:speak:self.server.sendline():' + str(e),debug.debugLevel.ERROR) - - def cancel(self): - if not self._isInitialized: - return - try: - 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) - - def setRate(self, rate): - if not self._isInitialized: - return - try: - 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) - - def setLanguage(self, language): - if not self._isInitialized: - return - self.server.sendline('set_lang ' + language) diff --git a/src/fenrirscreenreader/speechDriver/pyttsxDriver.py b/src/fenrirscreenreader/speechDriver/pyttsxDriver.py deleted file mode 100644 index bcb2f379..00000000 --- a/src/fenrirscreenreader/speechDriver/pyttsxDriver.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. -# Espeak driver - -from threading import Thread, Lock -from fenrirscreenreader.core import debug -from fenrirscreenreader.core.speechDriver import speechDriver - -class driver(speechDriver): - def __init__(self): - speechDriver.__init__(self) - self._engine = None - def initialize(self, environment): - self.env = environment - def shutdown(self): - if self._isInitialized: - self.cancel() - self._engine.endLoop() - self._initialized = False - def eventLoop(self): - self._engine.startLoop() - def startEngine(self): - try: - import pyttsx3 - if self.module != '': - self._engine = pyttsx3.init(self.module) - else: - self._engine = pyttsx3.init() - self.eventLoopThread = Thread(target=self.eventLoop) - self._isInitialized = True - self.eventLoopThread.start() - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('SpeechDriver:initialize:' + str(e),debug.debugLevel.ERROR) - - def speak(self,text, interrupt=True): - if not self._isInitialized: - self.startEngine() - if not self._isInitialized: - return - if not interrupt: - self.cancel() - try: - self._engine.setProperty('volume', self.volume) - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('SpeechDriver:speak:volume:' + str(e),debug.debugLevel.ERROR) - try: - self._engine.setProperty('rate', self.rate) - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('SpeechDriver:speak:rate:' + str(e),debug.debugLevel.ERROR) - try: - self._engine.setProperty('pitch', self.pitch) - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('SpeechDriver:speak:pitch:' + str(e),debug.debugLevel.ERROR) - if self.language != None: - if self.language != '': - try: - self._engine.setProperty('voice', self.language) - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('SpeechDriver:speak:language:' + str(e),debug.debugLevel.ERROR) - - elif self.voice != None: - if self.voice != '': - try: - self._engine.setProperty('voice', self.voice) - except Exception as e: - self.env['runtime']['debug'].writeDebugOut('SpeechDriver:speak:voice:' + str(e),debug.debugLevel.ERROR) - self._engine.say(text) - - def cancel(self): - if not self._isInitialized: - return - self._engine.stop() - - def setPitch(self, pitch): - if not self._isInitialized: - return - self.pitch = pitch - - def setRate(self, rate): - if not self._isInitialized: - return - self.rate = rate