shithub: opus

Download patch

ref: b9e0ea23e00cd7a8ea49f046b9f0ee9404f747bd
parent: d533e4024d6bf35648f5b5b63dff375e95f40ea5
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Mon Dec 10 06:23:31 EST 2018

Fix flooring of the pitch period

Without the 0.1 bias, the rounding error could cause an offset of -1

--- a/dnn/lpcnet.c
+++ b/dnn/lpcnet.c
@@ -154,7 +154,7 @@
     /* FIXME: Remove this -- it's just a temporary hack to match the Python code. */
     static int start = LPC_ORDER+1;
     /* FIXME: Do proper rounding once the Python code rounds properly. */
-    pitch = (int)floor(50*features[36]+100);
+    pitch = (int)floor(.1 + 50*features[36]+100);
     /* FIXME: get the pitch gain from 2 frames in the past. */
     pitch_gain = features[PITCH_GAIN_FEATURE];
     run_frame_network(lpcnet, condition, gru_a_condition, features, pitch);
--- a/dnn/test_lpcnet.py
+++ b/dnn/test_lpcnet.py
@@ -59,7 +59,7 @@
 
 features = np.reshape(features, (nb_frames, feature_chunk_size, nb_features))
 features[:,:,18:36] = 0
-periods = (50*features[:,:,36:37]+100).astype('int16')
+periods = (.1 + 50*features[:,:,36:37]+100).astype('int16')
 
 
 
--- a/dnn/train_lpcnet.py
+++ b/dnn/train_lpcnet.py
@@ -136,7 +136,7 @@
 pred = np.reshape(pred, (nb_frames, pcm_chunk_size, 1))
 pred = pred.astype('uint8')
 
-periods = (50*features[:,:,36:37]+100).astype('int16')
+periods = (.1 + 50*features[:,:,36:37]+100).astype('int16')
 
 in_data = np.concatenate([in_data, pred], axis=-1)
 
@@ -143,7 +143,7 @@
 del pred
 
 # dump models to disk as we go
-checkpoint = ModelCheckpoint('lpcnet14_384_10_G16_{epoch:02d}.h5')
+checkpoint = ModelCheckpoint('lpcnet15_384_10_G16_{epoch:02d}.h5')
 
 #model.load_weights('lpcnet9b_384_10_G16_01.h5')
 model.compile(optimizer=Adam(0.001, amsgrad=True, decay=5e-5), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
--