From 87c0a1bfe93ffbe7eb67c41ea2b46fd5a7c1ab28 Mon Sep 17 00:00:00 2001 From: "Clayton G. Hobbs" Date: Sun, 27 Dec 2015 12:56:57 -0500 Subject: Improved config/argument behaviour The configuration file is now properly overridden by argument parsing. This was accomplished by loading the config file, then treating the specified options as a namespace for the ArgumentParser. This makes things from the config file get overridden iff they were specified on the command line (not simply from defaults set in the ArgumentParser). --- recognizer.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'recognizer.py') diff --git a/recognizer.py b/recognizer.py index 06a2b87..02424a8 100755 --- a/recognizer.py +++ b/recognizer.py @@ -3,16 +3,14 @@ # Copyright 2013 Jezra # Copyright 2015 Clayton G. Hobbs +import os.path +import sys + import gi gi.require_version('Gst', '1.0') from gi.repository import GObject, Gst GObject.threads_init() Gst.init(None) -import os.path -import sys - -# Define some global variables -this_dir = os.path.dirname(os.path.abspath(__file__)) class Recognizer(GObject.GObject): @@ -20,7 +18,7 @@ class Recognizer(GObject.GObject): 'finished' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)) } - def __init__(self, language_file, dictionary_file, src = None): + def __init__(self, language_file, dictionary_file, src=None): GObject.GObject.__init__(self) self.commands = {} if src: @@ -41,7 +39,7 @@ class Recognizer(GObject.GObject): bus.add_signal_watch() # Get the Auto Speech Recognition piece - asr=self.pipeline.get_by_name('asr') + asr = self.pipeline.get_by_name('asr') bus.connect('message::element', self.result) asr.set_property('lm', language_file) asr.set_property('dict', dictionary_file) -- cgit 1.4.1