base_cmllr_config = files_dir + '/config.base_cmllr'
    regtree_hed = files_dir + '/regtree.hed'
    regtree_tree = classes_dir + '/regtree.tree'
    global_f = classes_dir + '/global'

    current_step += 1
    if current_step >= options.step:
        data_manipulation.write_regtree_hed_file(regtree_hed, si_model,
                                                 num_regtree_nodes_personal,
                                                 'regtree')

        data_manipulation.write_base_cmllr_config(base_cmllr_config, global_f)
        data_manipulation.write_tree_cmlllr_config(tree_cmllr_config,
                                                   regtree_tree)

        data_manipulation.write_global(global_f)

        logger.info("Start step: %d (%s)" %
                    (current_step, 'Generate regression tree'))
        htk.HHEd(current_step, si_model, classes_dir, regtree_hed, phones_list,
                 '/dev/null')

    current_step += 1
    if current_step >= options.step:

        logger.info("Start step: %d (%s)" %
                    (current_step, 'Estimate global transforms'))
        htk.HERest_estimate_transform(current_step, scp_file, si_model,
                                      xforms_dir, phones_list, adapt_mlf,
                                      max_adap_sentences,
                                      [orig_config, base_cmllr_config],
Esempio n. 2
0
    def make_adaptation(self, id, parent_transform, experiment):
        work_dir = experiment.name
        classes_dir = work_dir + '/classes'
        xforms_dir = work_dir + '/xforms'
        files_dir = work_dir + '/files'

        log_dir = os.path.join(work_dir, 'log')

        target_extension = 'mllr%d' % id
        source_extension = None
        if parent_transform is not None:
            source_extension = parent_transform[0]

        scp_file = self.configuration['scp']
        if scp_file is None or len(scp_file) == 0:
            scp_file = work_dir + '/recog.scp'

        adap_scp = work_dir +"/adap%d.scp" %id
        data_manipulation.copy_scp_file(scp_file, adap_scp)
#        shutil.copyfile(scp_file, adap_scp)

        model_hvite = experiment.model.configuration['model_dir'] + '/' + self.configuration['model_hvite']
        model_adapt = experiment.model.configuration['model_dir'] + '/' + self.configuration['model_adapt']

        phones_list = experiment.model.configuration['model_dir'] + '/files/tiedlist'
        dict_hvite = experiment.model.configuration['dict_hvite']
        source_mlf = self.configuration['mlf']
        source_mlf_ext = self.configuration['mlf_ext']
        adapt_mlf = work_dir + '/adap%d.mlf'%id
        num_nodes = self.configuration['nodes']

        hvite_config = experiment.model.configuration['model_dir'] + '/config/config'
        standard_config = experiment.model.configuration['config']
        adapt_config = files_dir + '/adapt%d.config' % id

        speaker_name_width = self.configuration['speaker_name_width']
        num_adaptation_samples = None
        if self.configuration['num_adaptation_samples'] >= 0:
            num_adaptation_samples = self.configuration['num_adaptation_samples']


        # align transcription
        htk.HVite(log_dir, adap_scp, model_hvite, dict_hvite, phones_list, source_mlf, adapt_mlf, source_mlf_ext, hvite_config)

        if self.configuration['type'] == 'tree':
            regtree_hed = files_dir + '/regtree%d.hed'%id
            regtree = classes_dir+'/regtree%d.tree'%id

            data_manipulation.write_regtree_hed_file(regtree_hed, model_adapt, num_nodes, 'regtree%d'%id)
            data_manipulation.write_tree_cmlllr_config(adapt_config, regtree, '"IntVec 3 13 13 13"')

            htk.HHEd(log_dir, model_adapt, classes_dir, regtree_hed, phones_list, '/dev/null')


            htk.HERest_estimate_transform(log_dir, adap_scp, model_adapt, xforms_dir, phones_list, adapt_mlf,
                                          num_adaptation_samples,
                                          [hvite_config, adapt_config], speaker_name_width, target_extension,
                                          [(xforms_dir, source_extension), (classes_dir, None)], False,
                                          [(xforms_dir, source_extension), (classes_dir, None)])

        elif self.configuration['type'] == 'base':
            global_f = classes_dir + '/global%d' % id

            mask = None
            if parent_transform is not None and parent_transform[2] != speaker_name_width:
                mask = '%%%'
                if parent_transform[2] > 0:
                    mask = ('%' * parent_transform[2]) + "*.*"
            data_manipulation.write_base_cmllr_config(adapt_config, global_f, mask)
            data_manipulation.write_global(global_f, 'global%d'%id)

            input_transforms = [(classes_dir, None)]
            parent_transforms = []
            if parent_transform is not None:
                input_transforms.append((xforms_dir, source_extension))
                parent_transforms.append((xforms_dir, source_extension))

            htk.HERest_estimate_transform(log_dir, adap_scp, model_adapt, xforms_dir, phones_list, adapt_mlf,
                                          num_adaptation_samples,
                                          [hvite_config, adapt_config], speaker_name_width, target_extension,
                                          input_transforms, False, parent_transforms)


        else:
            raise Exception("Unknown adaptation type!")


        return (target_extension, adapt_config, speaker_name_width)
Esempio n. 3
0
    if not os.path.exists(files_dir): os.mkdir(files_dir)

    tree_cmllr_config = files_dir+'/config.tree_cmllr'
    base_cmllr_config = files_dir+'/config.base_cmllr'
    regtree_hed =  files_dir+'/regtree.hed'
    regtree_tree = classes_dir+'/regtree.tree'
    global_f = classes_dir + '/global'

    current_step += 1
    if current_step >= options.step:
        data_manipulation.write_regtree_hed_file(regtree_hed,si_model,num_regtree_nodes_personal,'regtree')

        data_manipulation.write_base_cmllr_config(base_cmllr_config, global_f)
        data_manipulation.write_tree_cmlllr_config(tree_cmllr_config, regtree_tree)

        data_manipulation.write_global(global_f)

        logger.info("Start step: %d (%s)" % (current_step, 'Generate regression tree'))
        htk.HHEd(current_step, si_model, classes_dir, regtree_hed, phones_list, '/dev/null')


    current_step += 1
    if current_step >= options.step:


        logger.info("Start step: %d (%s)" % (current_step, 'Estimate global transforms'))
        htk.HERest_estimate_transform(current_step, scp_file, si_model, xforms_dir, phones_list, adapt_mlf, max_adap_sentences, [orig_config, base_cmllr_config], speaker_name_width, 'mllr1', [(classes_dir, None)])


    current_step += 1
    if current_step >= options.step:
Esempio n. 4
0
    def make_adaptation(self, id, parent_transform, experiment):
        work_dir = experiment.name
        classes_dir = work_dir + '/classes'
        xforms_dir = work_dir + '/xforms'
        files_dir = work_dir + '/files'

        log_dir = os.path.join(work_dir, 'log')

        target_extension = 'mllr%d' % id
        source_extension = None
        if parent_transform is not None:
            source_extension = parent_transform[0]

        scp_file = self.configuration['scp']
        if scp_file is None or len(scp_file) == 0:
            scp_file = work_dir + '/recog.scp'

        adap_scp = work_dir + "/adap%d.scp" % id
        data_manipulation.copy_scp_file(scp_file, adap_scp)
        #        shutil.copyfile(scp_file, adap_scp)

        model_hvite = experiment.model.configuration[
            'model_dir'] + '/' + self.configuration['model_hvite']
        model_adapt = experiment.model.configuration[
            'model_dir'] + '/' + self.configuration['model_adapt']

        phones_list = experiment.model.configuration[
            'model_dir'] + '/files/tiedlist'
        dict_hvite = experiment.model.configuration['dict_hvite']
        source_mlf = self.configuration['mlf']
        source_mlf_ext = self.configuration['mlf_ext']
        adapt_mlf = work_dir + '/adap%d.mlf' % id
        num_nodes = self.configuration['nodes']

        hvite_config = experiment.model.configuration[
            'model_dir'] + '/config/config'
        standard_config = experiment.model.configuration['config']
        adapt_config = files_dir + '/adapt%d.config' % id

        speaker_name_width = self.configuration['speaker_name_width']
        num_adaptation_samples = None
        if self.configuration['num_adaptation_samples'] >= 0:
            num_adaptation_samples = self.configuration[
                'num_adaptation_samples']

        # align transcription
        htk.HVite(log_dir, adap_scp, model_hvite, dict_hvite, phones_list,
                  source_mlf, adapt_mlf, source_mlf_ext, hvite_config)

        if self.configuration['type'] == 'tree':
            regtree_hed = files_dir + '/regtree%d.hed' % id
            regtree = classes_dir + '/regtree%d.tree' % id

            data_manipulation.write_regtree_hed_file(regtree_hed, model_adapt,
                                                     num_nodes,
                                                     'regtree%d' % id)
            data_manipulation.write_tree_cmlllr_config(adapt_config, regtree,
                                                       '"IntVec 3 13 13 13"')

            htk.HHEd(log_dir, model_adapt, classes_dir, regtree_hed,
                     phones_list, '/dev/null')

            htk.HERest_estimate_transform(log_dir, adap_scp, model_adapt,
                                          xforms_dir, phones_list, adapt_mlf,
                                          num_adaptation_samples,
                                          [hvite_config, adapt_config],
                                          speaker_name_width, target_extension,
                                          [(xforms_dir, source_extension),
                                           (classes_dir, None)], False,
                                          [(xforms_dir, source_extension),
                                           (classes_dir, None)])

        elif self.configuration['type'] == 'base':
            global_f = classes_dir + '/global%d' % id

            mask = None
            if parent_transform is not None and parent_transform[
                    2] != speaker_name_width:
                mask = '%%%'
                if parent_transform[2] > 0:
                    mask = ('%' * parent_transform[2]) + "*.*"
            data_manipulation.write_base_cmllr_config(adapt_config, global_f,
                                                      mask)
            data_manipulation.write_global(global_f, 'global%d' % id)

            input_transforms = [(classes_dir, None)]
            parent_transforms = []
            if parent_transform is not None:
                input_transforms.append((xforms_dir, source_extension))
                parent_transforms.append((xforms_dir, source_extension))

            htk.HERest_estimate_transform(
                log_dir, adap_scp, model_adapt, xforms_dir, phones_list,
                adapt_mlf, num_adaptation_samples,
                [hvite_config, adapt_config], speaker_name_width,
                target_extension, input_transforms, False, parent_transforms)

        else:
            raise Exception("Unknown adaptation type!")

        return (target_extension, adapt_config, speaker_name_width)