def start(args): if args["server"]: api.Run(nlp, userin, args["server"]) if Config.TWITTER_CONSUMER_KEY != 'CONSUMER_KEY': auth = OAuthHandler(Config.TWITTER_CONSUMER_KEY, Config.TWITTER_CONSUMER_SECRET) auth.set_access_token(Config.TWITTER_ACCESS_KEY, Config.TWITTER_ACCESS_SECRET) userin.twitter_api = tweepy.API(auth) print("Listening Twitter mentions...") l = MentionListener(args) stream = Stream(auth, l) stream.filter(track=['DragonfireAI'], async=True) elif args["cli"]: while (True): com = raw_input("Enter your command: ") thread.start_new_thread(VirtualAssistant.command, (com, args)) time.sleep(0.5) elif args["gspeech"]: from dragonfire.sr.gspeech import GspeechRecognizer recognizer = GspeechRecognizer() recognizer.recognize(args) else: from dragonfire.sr.deepspeech import DeepSpeechRecognizer recognizer = DeepSpeechRecognizer() recognizer.recognize(args)
def start(args, userin): """Function that starts the virtual assistant with the correct mode according to command-line arguments. Args: args: Command-line arguments. userin: :class:`dragonfire.utilities.TextToAction` instance. """ if args["server"]: import dragonfire.api as API # API of Dragonfire import tweepy # An easy-to-use Python library for accessing the Twitter API from tweepy import OAuthHandler from tweepy import Stream from dragonfire.twitter import MentionListener if Config.TWITTER_CONSUMER_KEY != 'CONSUMER_KEY': auth = OAuthHandler(Config.TWITTER_CONSUMER_KEY, Config.TWITTER_CONSUMER_SECRET) auth.set_access_token(Config.TWITTER_ACCESS_KEY, Config.TWITTER_ACCESS_SECRET) userin.twitter_api = tweepy.API(auth) print("Listening Twitter mentions...") l = MentionListener(args, userin) stream = Stream(auth, l) stream.filter(track=['DragonfireAI'], async=True) API.Run(nlp, learner, omniscient, dc, coref, userin, args["server"], args["port"]) else: global user_full_name global user_prefix if args["cli"]: her = VirtualAssistant(args, userin, user_full_name, user_prefix) while (True): com = raw_input("Enter your command: ") thread.start_new_thread(her.command, (com, )) time.sleep(0.5) elif args["gspeech"]: from dragonfire.sr.gspeech import GspeechRecognizer recognizer = GspeechRecognizer() recognizer.recognize(args, userin, user_full_name, user_prefix) else: from dragonfire.sr.deepspeech import DeepSpeechRecognizer recognizer = DeepSpeechRecognizer() recognizer.recognize(args, userin, user_full_name, user_prefix)
def start(args, userin): """Function that starts the virtual assistant with the correct mode according to command-line arguments. Args: args: Command-line arguments. userin: :class:`dragonfire.utilities.TextToAction` instance. """ if 'TRAVIS' in os.environ or args["db"] == "mysql": engine = create_engine('mysql+pymysql://' + Config.MYSQL_USER + ':' + Config.MYSQL_PASS + '@' + Config.MYSQL_HOST + '/' + Config.MYSQL_DB) else: engine = create_engine('sqlite:///dragonfire.db', connect_args={'check_same_thread': False}, echo=True) Base.metadata.create_all(engine) Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) db_session = DBSession() learner.db_session = db_session if args["server"]: import dragonfire.api as API # API of Dragonfire import tweepy # An easy-to-use Python library for accessing the Twitter API from tweepy import OAuthHandler from tweepy import Stream from dragonfire.twitter import MentionListener if Config.TWITTER_CONSUMER_KEY != 'CONSUMER_KEY': auth = OAuthHandler(Config.TWITTER_CONSUMER_KEY, Config.TWITTER_CONSUMER_SECRET) auth.set_access_token(Config.TWITTER_ACCESS_KEY, Config.TWITTER_ACCESS_SECRET) userin.twitter_api = tweepy.API(auth) print("Listening Twitter mentions...") l = MentionListener(args, userin) stream = Stream(auth, l) stream.filter(track=['DragonfireAI'], is_async=True) API.Run(nlp, learner, omniscient, dc, coref, userin, args["server"], args["port"], db_session) else: global user_full_name global user_prefix if args["cli"]: her = VirtualAssistant(args, userin, user_full_name, user_prefix) while (True): com = raw_input("Enter your command: ") thread.start_new_thread(her.command, (com, )) time.sleep(0.5) elif args["gspeech"]: from dragonfire.sr.gspeech import GspeechRecognizer her = VirtualAssistant(args, userin, user_full_name, user_prefix) recognizer = GspeechRecognizer() recognizer.recognize(her) else: from dragonfire.sr.deepspeech import DeepSpeechRecognizer her = VirtualAssistant(args, userin, user_full_name, user_prefix) recognizer = DeepSpeechRecognizer() recognizer.recognize(her)