def console_output(self, text): clear() stdout_print(jarvis_logo) stdout_print(" NOTE: CTRL + C If you want to Quit.") print(OutputStyler.HEADER + '-------------- INFO --------------' + OutputStyler.ENDC) print(OutputStyler.HEADER + 'SYSTEM ---------------------------' + OutputStyler.ENDC) print(OutputStyler.BOLD + 'RAM USAGE: {0:.2f} GB'.format(self._get_memory()) + OutputStyler.ENDC) # print(OutputStyler.HEADER + 'MIC ------------------------------' + OutputStyler.ENDC) # print(OutputStyler.BOLD + # 'ENERGY THRESHOLD LEVEL: ' + '|' * int(self.energy_threshold) + '\n' # 'DYNAMIC ENERGY LEVEL: ' + '|' * int(self.dynamic_energy_ratio) + OutputStyler.ENDC) # print(' ') print(OutputStyler.HEADER + '-------------- LOG --------------' + OutputStyler.ENDC) lines = subprocess.check_output([ 'tail', '-10', self.log_settings['handlers']['file']['filename'] ]).decode("utf-8") print(OutputStyler.BOLD + lines + OutputStyler.ENDC) print(OutputStyler.HEADER + '-------------- ASSISTANT --------------' + OutputStyler.ENDC) print(OutputStyler.BOLD + '> ' + text + '\r' + OutputStyler.ENDC)
def disable_assistant(cls, **kwargs): """ Shutdown the assistant service and clean the bash stdout. """ cls.response('Bye') time.sleep(1) clear() logging.debug('Application terminated gracefully.') sys.exit()
def start_up(): """ Do initial checks, clear the console and print the assistant logo. """ startup_ckecks() clear() print(OutputStyler.CYAN + jarvis_logo + OutputStyler.ENDC) print(OutputStyler.HEADER + start_text + OutputStyler.ENDC) # Clear log file in each assistant fresh start with open(ROOT_LOG_CONF['handlers']['file']['filename'], 'r+') as f: f.truncate(0) logging.info('APPLICATION STARTED..')
def _set_microphone(self, pause_threshold, energy_threshold, ambient_duration, dynamic_energy_threshold): """ Setup the assistant microphone. """ microphone_list = self.sr.Microphone.list_microphone_names() clear() print("=" * 48) print("Microphone Setup") print("=" * 48) print("Which microphone do you want to use a assistant mic:") for index, name in enumerate(microphone_list): print("{0}) Microphone: {1}".format(index, name)) choices = "Choice[1-{0}]: ".format(len(microphone_list)) print( "WARNING: " "In case of error of 'Invalid number of channels' try again with different micrphone choice" ) index = input(choices) while not index.isnumeric(): index = input( "Please select a number between choices[1-{0}]: ".format( len(microphone_list))) with self.sr.Microphone(device_index=int(index), chunk_size=512) as source: self.speech_recognizer.pause_threshold = pause_threshold self.speech_recognizer.energy_threshold = energy_threshold clear() print("-" * 48) print("Microphone Calibration") print("-" * 48) print("Please wait.. for {} seconds ".format(ambient_duration)) self.speech_recognizer.adjust_for_ambient_noise( source, duration=ambient_duration) self.speech_recognizer.dynamic_energy_threshold = dynamic_energy_threshold print("Microphone calibrated successfully!") return source