shithub: opus

Download patch

ref: ea1391e174d46d8ccb5664f4350451dd6371c403
parent: 639766b322d300811807e5dc7b37325d4a0b2ab7
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Wed Oct 3 18:30:44 EDT 2018

deeper features

--- a/dnn/lpcnet.py
+++ b/dnn/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,7 +47,7 @@
     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')
@@ -54,7 +54,7 @@
     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 @@
     
     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)
--- a/dnn/test_wavenet_audio.py
+++ b/dnn/test_wavenet_audio.py
@@ -66,7 +66,7 @@
 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 @@
 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:]
--- a/dnn/train_wavenet_audio.py
+++ b/dnn/train_wavenet_audio.py
@@ -104,8 +104,8 @@
 # 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])
--