From f261583a4b57279d578901345561d00640870566 Mon Sep 17 00:00:00 2001 From: Chrys Date: Wed, 19 May 2021 11:19:11 +0200 Subject: [PATCH] normalize gstreamer, make generic work --- src/fenrirscreenreader/core/fenrirManager.py | 2 +- src/fenrirscreenreader/core/outputManager.py | 2 +- src/fenrirscreenreader/soundDriver/genericDriver.py | 8 +++++--- src/fenrirscreenreader/soundDriver/gstreamerDriver.py | 5 +++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index d9643143..e519fe4b 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -23,7 +23,7 @@ class fenrirManager(): raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable') except RuntimeError: raise - self.environment['runtime']['outputManager'].playFrequence(500, 500, interrupt=True) + self.environment['runtime']['outputManager'].playFrequence(500, 1, interrupt=True) #self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True) signal.signal(signal.SIGINT, self.captureSignal) signal.signal(signal.SIGTERM, self.captureSignal) diff --git a/src/fenrirscreenreader/core/outputManager.py b/src/fenrirscreenreader/core/outputManager.py index 455aa6bd..bf1ce254 100644 --- a/src/fenrirscreenreader/core/outputManager.py +++ b/src/fenrirscreenreader/core/outputManager.py @@ -239,7 +239,7 @@ class outputManager(): def interruptOutput(self): try: self.env['runtime']['speechDriver'].cancel() - self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO) + self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO) except: pass diff --git a/src/fenrirscreenreader/soundDriver/genericDriver.py b/src/fenrirscreenreader/soundDriver/genericDriver.py index f39458b7..543359c4 100644 --- a/src/fenrirscreenreader/soundDriver/genericDriver.py +++ b/src/fenrirscreenreader/soundDriver/genericDriver.py @@ -26,17 +26,19 @@ class driver(soundDriver): self.frequenceCommand = 'play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence' self._initialized = True - def playFrequence(self, frequence = 1000, duration = 0.3, adjustVolume = 0): + def playFrequence(self, frequence, duration, adjustVolume = 0, interrupt=True): + print('drin') if not self._initialized: return if interrupt: self.cancel() popenFrequenceCommand = shlex.split(self.frequenceCommand) for idx, word in enumerate(popenFrequenceCommand): - word = word.replace('fenrirVolume', str(self.volume + adjustVolume )) - word = word.replace('fenrirFreqDuration', str(duration)) + word = word.replace('fenrirVolume', str(self.volume)) + word = word.replace('fenrirDuration', str(duration)) word = word.replace('fenrirFrequence', str(frequence)) popenFrequenceCommand[idx] = word + print(popenFrequenceCommand) self.proc = subprocess.Popen(popenFrequenceCommand, stdin=None, stdout=None, stderr=None, shell=False) self.soundType = 'frequence' def playSoundFile(self, filePath, interrupt = True): diff --git a/src/fenrirscreenreader/soundDriver/gstreamerDriver.py b/src/fenrirscreenreader/soundDriver/gstreamerDriver.py index 00bf1836..4a2ce2f7 100644 --- a/src/fenrirscreenreader/soundDriver/gstreamerDriver.py +++ b/src/fenrirscreenreader/soundDriver/gstreamerDriver.py @@ -92,12 +92,13 @@ class driver(soundDriver): self._player.set_property('uri', 'file://%s' % fileName) self._player.set_state(Gst.State.PLAYING) - def playFrequence(self, frequence, duration, interrupt=True): + def playFrequence(self, frequence, duration, adjustVolume = 0, interrupt=True): if not self._initialized: return if interrupt: self.cancel() - self._source.set_property('volume', self.volume) + duration = duration * 1000 + self._source.set_property('volume', self.volume - adjustVolume) self._source.set_property('freq', frequence) self._pipeline.set_state(Gst.State.PLAYING) GLib.timeout_add(duration, self._onTimeout, self._pipeline)