Example #1
0
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()
Example #2
0
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()
Example #3
0
classify0.set_relevance(333)
classify1.set_relevance(333)
classify0.set_num_em_iterations(2)
classify1.set_num_em_iterations(2)
classifier0 = AdaptingGmmClassProcessor(classify0)
classifier1 = AdaptingGmmClassProcessor(classify1)

gaussian_trainer = SimpleGaussianTrainer(labels, nfeatures)
trainer = FunctionProcessor(gaussian_trainer)

# audio.mic, fftmag, endpointer, mfcc0, square, mfcc1, classifier0, classifier1, trainer

spectral_split = SplitProcessor()
utt_tag_split = SplitProcessor()

gmm0_join = SynchronizingSequenceJoin()
gmm1_join = SynchronizingSequenceJoin()

coalesce0 = SequenceFunctionProcessor(Coalescer())
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)