shithub: opus

Download patch

ref: a9bf6cee8af41b9639f8a209d8ce0cea91b6c7b7
parent: b5b1d5013e83fb3b2353f4964a1c6f6737c6495f
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Wed Oct 20 13:20:32 EDT 2021

Don't hardcode the number of bands

--- a/dnn/lpcnet.c
+++ b/dnn/lpcnet.c
@@ -89,7 +89,7 @@
     int pitch;
     float rc[LPC_ORDER];
     /* Matches the Python code -- the 0.1 avoids rounding issues. */
-    pitch = (int)floor(.1 + 50*features[18]+100);
+    pitch = (int)floor(.1 + 50*features[NB_BANDS]+100);
     pitch = IMIN(255, IMAX(33, pitch));
     net = &lpcnet->nnet;
     RNN_COPY(in, features, NB_FEATURES);
--- a/dnn/training_tf2/train_lpcnet.py
+++ b/dnn/training_tf2/train_lpcnet.py
@@ -100,6 +100,8 @@
 quantize = args.quantize is not None
 retrain = args.retrain is not None
 
+lpc_order = 16
+
 if quantize:
     lr = 0.00003
     decay = 0
@@ -133,7 +135,7 @@
 feature_file = args.features
 pcm_file = args.data     # 16 bit unsigned short PCM samples
 frame_size = model.frame_size
-nb_features = 36
+nb_features = model.nb_used_features + lpc_order
 nb_used_features = model.nb_used_features
 feature_chunk_size = 15
 pcm_chunk_size = frame_size*feature_chunk_size
@@ -160,7 +162,7 @@
 #features = features[:, :, :nb_used_features]
 
 
-periods = (.1 + 50*features[:,:,18:19]+100).astype('int16')
+periods = (.1 + 50*features[:,:,nb_used_features-2:nb_used_features-1]+100).astype('int16')
 #periods = np.minimum(periods, 255)
 
 # dump models to disk as we go
--