def __init__(self, opts): #import the recognizer so Gst doesn't clobber our -h from Recognizer import Recognizer self.ui = None self.options = {} ui_continuous_listen = False self.continuous_listen = False self.commander = Command.Commander(command_file,strings_file) #load the options file self.load_options() #merge the opts for k,v in opts.__dict__.items(): if (not k in self.options) or opts.override: self.options[k] = v if self.options['interface'] != None: if self.options['interface'] == "q": from QtUI import UI elif self.options['interface'] == "g": from GtkUI import UI elif self.options['interface'] == "gt": from GtkTrayUI import UI else: print "no GUI defined" sys.exit() self.ui = UI(args, self.options['continuous']) self.ui.connect("command", self.process_command) #can we load the icon resource? icon = self.load_resource("icon.png") if icon: self.ui.set_icon_active_asset(icon) #can we load the icon_inactive resource? icon_inactive = self.load_resource("icon_inactive.png") if icon_inactive: self.ui.set_icon_inactive_asset(icon_inactive) if self.options['history']: self.history = [] #create the recognizer try: self.recognizer = Recognizer(lang_file, dic_file, self.options['microphone'] ) except Exception, e: #no recognizer? bummer sys.exit()
def __init__(self, opts): #import the recognizer so Gst doesn't clobber our -h from Recognizer import Recognizer self.ui = None #keep track of the opts self.opts = opts ui_continuous_listen = False self.continuous_listen = opts.continuous self.commands = {} self.read_commands() self.recognizer = Recognizer(lang_file, dic_file, opts.microphone) self.recognizer.connect('finished', self.recognizer_finished) self.matchTime = 0 self.keywordTimeLimit = opts.keytime #set to 0 to always speak the keyword self.commandFileTime = 0 #updates language file and commands on start self.checkCommandFile() self.commandFileTime = os.path.getmtime(command_file) #read options if opts.interface != None: if opts.interface == "q": #import the ui from qt from QtUI import UI elif opts.interface == "g": from GtkUI import UI else: print "no GUI defined" sys.exit() self.ui = UI(args, opts.continuous) self.ui.connect("command", self.process_command) #can we load the icon resource? icon = self.load_resource("icon.png") if icon: self.ui.set_icon(icon) if self.opts.history: self.history = []
def __init__(self, opts): #import the recognizer so Gst doesn't clobber our -h from Recognizer import Recognizer #set variables self.ui = None self.options = {} ui_continuous_listen = False self.continuous_listen = False self.commands = {} #read the commands self.load_commands_file() #load the options file print("load the options") self.load_options_file() #merge the opts for k, v in opts.__dict__.items(): if (not k in self.options) or opts.override: self.options[k] = v # should we be updating? if self.options['update']: #make the sentences corpus self.generate_sentences_corpus() #run the update stuff UpdateLanguage.update_language() if self.options['interface'] != None: if self.options['interface'] == "q": from QtUI import UI elif self.options['interface'] == "g": from GtkUI import UI elif self.options['interface'] == "gt": from GtkTrayUI import UI else: print("no GUI defined") sys.exit() self.ui = UI(args, self.options['continuous']) self.ui.connect("command", self.process_command) #can we load the icon resource? icon = self.load_resource("icon.png") if icon: self.ui.set_icon_active_asset(icon) #can we load the icon_inactive resource? icon_inactive = self.load_resource("icon_inactive.png") if icon_inactive: self.ui.set_icon_inactive_asset(icon_inactive) if self.options['history']: self.history = [] #create the recognizer try: self.recognizer = Recognizer(lang_file, dic_file, self.options['microphone']) except Exception as e: print(e) #no recognizer? bummer sys.exit() self.recognizer.connect('finished', self.recognizer_finished) print("Using Options: ", self.options)