示例#1
0
	def get_timing_data(self):
		self.error_key = 0
		error_dict = {}
		args_list = self.get_arg_list()
		if(os.path.isfile(conf.get_extracted_words_file())):
			os.remove(conf.get_extracted_words_file())
		with open(os.devnull, "w") as fnull:
			timing_extraction_process = subprocess.Popen(args_list, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
			(stdoutdata, stderrdata) = timing_extraction_process.communicate()
			if(stderrdata.find('ERROR') !=-1 or stderrdata.find('FATAL') != -1 or stdoutdata.find('null') != -1):
				self.error_key = 1
				error_dict = {'error_message': 'Sorry we were unable to transcribe this file'}
			timing_extraction_process.wait()
		return self.create_word_timing_dict(),error_dict
	def create_word_timing_dict(self):
		if(self.error_key):
			return
		else:
			timing_data = open(conf.get_extracted_words_file(),'rb')
			return self.format_continuous_output(timing_data.readlines())