From 5331ffed12e574b7574391689666330d2ccbcee8 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 3 Oct 2018 22:30:44 -0400 Subject: [PATCH] deeper features --- src/lpcnet.py | 12 +++++++++--- src/test_wavenet_audio.py | 4 ++-- src/train_wavenet_audio.py | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lpcnet.py b/src/lpcnet.py index fcdf242..d0fb01c 100644 --- a/src/lpcnet.py +++ b/src/lpcnet.py @@ -2,7 +2,7 @@ import math from keras.models import Model -from keras.layers import Input, LSTM, CuDNNGRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Bidirectional, MaxPooling1D, Activation +from keras.layers import Input, LSTM, CuDNNGRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation from keras import backend as K from keras.initializers import Initializer from mdense import MDense @@ -47,14 +47,14 @@ def new_wavernn_model(): pitch = Input(shape=(None, 1)) feat = Input(shape=(None, nb_used_features)) pitch = Input(shape=(None, 1)) - dec_feat = Input(shape=(None, 32)) + dec_feat = Input(shape=(None, 128)) dec_state = Input(shape=(rnn_units,)) conv1 = Conv1D(16, 7, padding='causal', activation='tanh') pconv1 = Conv1D(16, 5, padding='same', activation='tanh') pconv2 = Conv1D(16, 5, padding='same', activation='tanh') fconv1 = Conv1D(128, 3, padding='same', activation='tanh') - fconv2 = Conv1D(32, 3, padding='same', activation='tanh') + fconv2 = Conv1D(102, 3, padding='same', activation='tanh') if False: cpcm = conv1(pcm) @@ -73,6 +73,12 @@ def new_wavernn_model(): cfeat = fconv2(fconv1(cat_feat)) + fdense1 = Dense(128, activation='tanh') + fdense2 = Dense(128, activation='tanh') + + cfeat = Add()([cfeat, cat_feat]) + cfeat = fdense2(fdense1(cfeat)) + rep = Lambda(lambda x: K.repeat_elements(x, 160, 1)) rnn = CuDNNGRU(rnn_units, return_sequences=True, return_state=True) diff --git a/src/test_wavenet_audio.py b/src/test_wavenet_audio.py index 3175ef3..a68707e 100755 --- a/src/test_wavenet_audio.py +++ b/src/test_wavenet_audio.py @@ -66,7 +66,7 @@ in_data = np.reshape(in_data, (nb_frames*pcm_chunk_size, 1)) out_data = np.reshape(data, (nb_frames*pcm_chunk_size, 1)) -model.load_weights('wavenet4d2_203.h5') +model.load_weights('wavenet4f3_30.h5') order = 16 @@ -75,7 +75,7 @@ fexc = np.zeros((1, 1, 2), dtype='float32') iexc = np.zeros((1, 1, 1), dtype='int16') state = np.zeros((1, lpcnet.rnn_units), dtype='float32') for c in range(1, nb_frames): - cfeat = enc.predict(features[c:c+1, :, :nb_used_features]) + cfeat = enc.predict([features[c:c+1, :, :nb_used_features], periods[c:c+1, :, :]]) for fr in range(1, feature_chunk_size): f = c*feature_chunk_size + fr a = features[c, fr, nb_features-order:] diff --git a/src/train_wavenet_audio.py b/src/train_wavenet_audio.py index 9a30470..7fcc83a 100755 --- a/src/train_wavenet_audio.py +++ b/src/train_wavenet_audio.py @@ -104,8 +104,8 @@ in_data = np.concatenate([in_data, pred], axis=-1) # f.create_dataset('data', data=in_data[:50000, :, :]) # f.create_dataset('feat', data=features[:50000, :, :]) -checkpoint = ModelCheckpoint('wavenet4e_{epoch:02d}.h5') +checkpoint = ModelCheckpoint('wavenet4f3_{epoch:02d}.h5') -#model.load_weights('wavernn1c_01.h5') +#model.load_weights('wavenet4f2_30.h5') model.compile(optimizer=Adam(0.001, amsgrad=True, decay=2e-4), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy']) model.fit([in_data, in_exc, features, periods], out_data, batch_size=batch_size, epochs=30, validation_split=0.2, callbacks=[checkpoint])