def process_htk_files(mlf_file, scp_file, tail_process_function, scp_prefix_subst=None): """ Read an HTK MLF (Master Label File) file and a corresponding scp file, call tail_process_function with results in the form of LabeledDataEvents. mlf_file and scp_file should be open file handles; tail_process_function should be a callable taking one argument. scp_prefix_subst, if it is not None, will be passed to ScpProcessor to be used in converting filenames in the scp_file. We're going to set up the following dataflow network: label_source ==> line_proc ==> block_proc ==\ join ==> ld_proc audio_source ==> audio_proc ================/ """ def handler(label_evt): return label_evt.word_label ld_proc = HtkLabeledDataProcessor(tail_process_function) join = SynchronizingSequenceJoin(ld_proc.process) # We need to make sure we call join.get_process_function in the right # order here, since the ld_proc is expecting pairs of (label_block, audio_block) block_proc = MLFBlockProcessor(handler, sendee=join.get_process_function()) line_proc = MLFProcessor(block_proc.process) audio_proc = ScpProcessor(sendee=join.get_process_function(), prefix_subst=scp_prefix_subst) label_source = IteratorSource(mlf_file, sendee=line_proc.process) audio_source = IteratorSource(scp_file, sendee=audio_proc.process) label_source.start() audio_source.start() while not (label_source.is_iter_stopped and audio_source.is_iter_stopped): time.sleep(1 / 64) label_source.stop(flush=True) audio_source.stop(flush=True) label_source.wait() audio_source.wait() label_source.done() audio_source.done()
def process_htk_files(mlf_file, scp_file, tail_process_function, scp_prefix_subst=None): """ Read an HTK MLF (Master Label File) file and a corresponding scp file, call tail_process_function with results in the form of LabeledDataEvents. mlf_file and scp_file should be open file handles; tail_process_function should be a callable taking one argument. scp_prefix_subst, if it is not None, will be passed to ScpProcessor to be used in converting filenames in the scp_file. We're going to set up the following dataflow network: label_source ==> line_proc ==> block_proc ==\ join ==> ld_proc audio_source ==> audio_proc ================/ """ def handler(label_evt): return label_evt.word_label ld_proc = HtkLabeledDataProcessor(tail_process_function) join = SynchronizingSequenceJoin(ld_proc.process) # We need to make sure we call join.get_process_function in the right # order here, since the ld_proc is expecting pairs of (label_block, audio_block) block_proc = MLFBlockProcessor(handler, sendee=join.get_process_function()) line_proc = MLFProcessor(block_proc.process) audio_proc = ScpProcessor(sendee=join.get_process_function(), prefix_subst=scp_prefix_subst) label_source = IteratorSource(mlf_file, sendee=line_proc.process) audio_source = IteratorSource(scp_file, sendee=audio_proc.process) label_source.start() audio_source.start() while not (label_source.is_iter_stopped and audio_source.is_iter_stopped): time.sleep(1/64) label_source.stop(flush=True) audio_source.stop(flush=True) label_source.wait() audio_source.wait() label_source.done() audio_source.done()
coalesce1 = SequenceFunctionProcessor(Coalescer()) ddt_join = SynchronizingSequenceJoin() # build the network (uggg, by hand) audio.mic.set_sendee(fftmag.process) fftmag.set_sendee(spectral_split.process) spectral_split.add_sendee(endpointer.process) endpointer.set_sendee(utt_tag_split.process) spectral_split.add_sendee(mfcc0.process) spectral_split.add_sendee(square.process) square.set_sendee(mfcc1.process) utt_tag_split.add_sendee(gmm0_join.get_process_function()) utt_tag_split.add_sendee(gmm1_join.get_process_function()) mfcc0.set_sendee(gmm0_join.get_process_function()) mfcc1.set_sendee(gmm1_join.get_process_function()) gmm0_join.set_sendee(coalesce0.process) gmm1_join.set_sendee(coalesce1.process) coalesce0.set_sendee(classifier0.process) coalesce1.set_sendee(classifier1.process) classifier0.set_sendee(ddt_join.get_process_function()) classifier1.set_sendee(ddt_join.get_process_function()) ddt_join.set_sendee(ddt_accum) class Mode(object):