def transcribeme(): base_dir = conf.get_user_input_files_folder() wavfile = base_dir + 'sa1.wav' transcription_file = base_dir + 'sa1.txt' time_extractor = PocketSphinxContinuousDecoder(wavfile,transcription_file) (extracted_words,error_key) = time_extractor.extract_raw_timing_data() return
def extract_timing_data(self,wav,output_file_path): self.output_file_path = output_file_path timing_dict = {} filename,ext = wav.split('/')[-1].split('.') if ext in conf.audio_file_type() or ext in conf.audio_file_type().upper(): if filename in self.transcriptions: pcd = PocketSphinxContinuousDecoder(wav,self.transcriptions[filename]) (timing_data,error_dict) = pcd.get_timing_data() else: timing_data,error_dict = '',{'error':1, 'error_message':'No matching transcription found!'} else: timing_data,error_dict = '',{'error':1, 'error_message':'Wrong file type, must be a .wav file'} timing_dict[filename] = {'timing_data': timing_data, 'error_dict': error_dict} if not error_dict: self.write_data(timing_dict) return timing_dict