fixed empty phoneme boundary case

master
Malar Kannan 2017-12-11 13:05:46 +05:30
parent d387922f7d
commit a6543491f8
2 changed files with 5 additions and 9 deletions

View File

@ -156,8 +156,8 @@ def create_segments_tfrecords(collection_name='story_test_segments',sample_count
f_bounds = [spec_frame(phrase_spec,b) for b in ph_bounds]
valid_bounds = [i for i in f_bounds if 0 < i < spec_n]
b_frames = np.asarray(valid_bounds)
# print(spec_n,b_frames)
result[b_frames] = 1
if len(b_frames) > 0:
result[b_frames] = 1
nonlocal n_records,n_spec,n_features
n_spec = max([n_spec,spec_n])
n_features = spec_w
@ -178,9 +178,10 @@ def create_segments_tfrecords(collection_name='story_test_segments',sample_count
word_groups = [i for i in audio_samples.groupby('phrase')]
wg_sampled = reservoir_sample(word_groups,sample_count) if sample_count > 0 else word_groups
# write_samples(word_groups,'all')
tr_audio_samples,te_audio_samples = train_test_split(wg_sampled,test_size=train_test_ratio)
write_samples(tr_audio_samples,'train')
# write_samples(te_audio_samples,'test')
write_samples(te_audio_samples,'test')
const_file = './outputs/segments/'+collection_name+'/constants.pkl'
pickle.dump((n_spec,n_features,n_records),open(const_file,'wb'))
@ -257,7 +258,7 @@ if __name__ == '__main__':
# plot_segments('story_test_segments')
# fix_csv('story_phrases')
# pass
create_segments_tfrecords('story_phrases', sample_count=100)
create_segments_tfrecords('story_phrases_full', sample_count=0)
# record_generator,input_data,output_data,copy_read_consts = read_segments_tfrecords_generator('story_test')
# tr_gen = record_generator()
# for i in tr_gen:

View File

@ -36,21 +36,16 @@ def ctc_lambda_func(args):
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
def segment_model(input_dim):
# input_dim = (100,100,1)
inp = Input(shape=input_dim)
cnv1 = Conv2D(filters=32, kernel_size=(5,9))(inp)
cnv2 = Conv2D(filters=1, kernel_size=(5,9))(cnv1)
dr_cnv2 = Dropout(rate=0.95)(cnv2)
# dr_cnv2
cn_rnn_dim = (dr_cnv2.shape[1].value,dr_cnv2.shape[2].value)
r_dr_cnv2 = Reshape(target_shape=cn_rnn_dim)(dr_cnv2)
b_gr1 = Bidirectional(GRU(512, return_sequences=True),merge_mode='sum')(r_dr_cnv2)
# b_gr1
b_gr2 = Bidirectional(GRU(512, return_sequences=True),merge_mode='sum')(b_gr1)
b_gr3 = Bidirectional(GRU(512, return_sequences=True),merge_mode='sum')(b_gr2)
# b_gr3
oup = Dense(2, activation='softmax')(b_gr3)
# oup
return Model(inp, oup)
def simple_segment_model(input_dim):