コード例 #1
0
train_data_path = root_path+'Data/Train/'

file_indices = gtrd.get_data_files_indices(train_data_path)
syllable = np.array(['aa','r'])
avg_bgd, syllable_examples, backgrounds = gtrd.get_syllable_examples_backgrounds_files(train_data_path,
                                                                                       file_indices,
                                                                                       syllable,
                                                                                       
                                                                                       num_examples=-1,
                                                                                       verbose=True)


clipped_bgd = np.clip(avg_bgd.E,.1,.4)
np.save(tmp_data_path+'clipped_bgd_102012.npy',clipped_bgd)

padded_examples, lengths = et.extend_examples_to_max(clipped_bgd,syllable_examples,
                           return_lengths=True)

aar_template, aar_registered = et.register_templates_time_zero(syllable_examples,min_prob=.01)

test_example_lengths = gtrd.get_detect_lengths(data_path+'Test/')

np.save(tmp_data_path+'test_example_lengths_102012.npy',test_example_lengths)


detection_array = np.zeros((test_example_lengths.shape[0],
                            test_example_lengths.max() + 2),dtype=np.float32)

linear_filter,c = et.construct_linear_filter(aar_template,
                                             clipped_bgd)
# need to state the syllable we are working with
syllable = np.array(['aa','r'])
avg_bgd, syllable_examples, backgrounds = gtrd.get_syllables_examples_backgrounds_files(train_data_path,
                                            file_indices,
                                            syllables,
                                            log_part_blocks,
                                            log_invpart_blocks,
                                            num_examples=-1,
                                            verbose=True)

clipped_bgd = np.clip(avg_bgd.E,.1,.4)
np.save(tmp_data_path+'clipped_bgd_101812.npy',clipped_bgd)
import template_speech_rec.estimate_template as et

for syllable,examples in syllable_examples.items():
    np.save(tmp_data_path+'%s_%s_examples.npy' % syllable,
            et.extend_examples_to_max(clipped_bgd,examples))

padded_examples_syllable_dict = dict(
    (syll,
     et.extend_examples_to_max(clipped_bgd,examples))
     for syll, examples in syllable_examples.items())

del backgrounds


# estimate mixture models
#
import template_speech_rec.bernoulli_mixture as bm

mixture_models_syllable = {}
for syllable, examples in padded_examples_syllable_dict.items():