diff --git a/dnn/lpcnet_demo.c b/dnn/lpcnet_demo.c index 3dac10c4ed6a11f573463225149079bbfb5b0fd8..67df63bc1989c063947ff6b27104f2b9c119f568 100644 --- a/dnn/lpcnet_demo.c +++ b/dnn/lpcnet_demo.c @@ -82,7 +82,7 @@ void free_blob(unsigned char *blob, int len) { #endif #define MODE_FEATURES 2 -#define MODE_SYNTHESIS 3 +/*#define MODE_SYNTHESIS 3*/ #define MODE_PLC 4 #define MODE_ADDLPC 5 #define MODE_FWGAN_SYNTHESIS 6 @@ -90,7 +90,7 @@ void free_blob(unsigned char *blob, int len) { void usage(void) { fprintf(stderr, "usage: lpcnet_demo -features <input.pcm> <features.f32>\n"); - fprintf(stderr, " lpcnet_demo -synthesis <features.f32> <output.pcm>\n"); + fprintf(stderr, " lpcnet_demo -fargan_synthesis <features.f32> <output.pcm>\n"); fprintf(stderr, " lpcnet_demo -plc <plc_options> <percent> <input.pcm> <output.pcm>\n"); fprintf(stderr, " lpcnet_demo -plc_file <plc_options> <percent> <input.pcm> <output.pcm>\n"); fprintf(stderr, " lpcnet_demo -addlpc <features_without_lpc.f32> <features_with_lpc.lpc>\n\n"); @@ -114,7 +114,6 @@ int main(int argc, char **argv) { #endif if (argc < 4) usage(); if (strcmp(argv[1], "-features") == 0) mode=MODE_FEATURES; - else if (strcmp(argv[1], "-synthesis") == 0) mode=MODE_SYNTHESIS; else if (strcmp(argv[1], "-fargan-synthesis") == 0) mode=MODE_FARGAN_SYNTHESIS; else if (strcmp(argv[1], "-plc") == 0) { mode=MODE_PLC; @@ -170,24 +169,6 @@ int main(int argc, char **argv) { fwrite(features, sizeof(float), NB_TOTAL_FEATURES, fout); } lpcnet_encoder_destroy(net); - } else if (mode == MODE_SYNTHESIS) { - LPCNetState *net; - net = lpcnet_create(); -#ifdef USE_WEIGHTS_FILE - lpcnet_load_model(net, data, len); -#endif - while (1) { - float in_features[NB_TOTAL_FEATURES]; - float features[NB_FEATURES]; - opus_int16 pcm[LPCNET_FRAME_SIZE]; - size_t ret; - ret = fread(in_features, sizeof(features[0]), NB_TOTAL_FEATURES, fin); - if (feof(fin) || ret != NB_TOTAL_FEATURES) break; - OPUS_COPY(features, in_features, NB_FEATURES); - lpcnet_synthesize(net, features, pcm, LPCNET_FRAME_SIZE); - fwrite(pcm, sizeof(pcm[0]), LPCNET_FRAME_SIZE, fout); - } - lpcnet_destroy(net); } else if (mode == MODE_FARGAN_SYNTHESIS) { FARGANState fargan; size_t ret, i; diff --git a/dnn/nnet.c b/dnn/nnet.c index d17ff9bae70f1d323459c752e7b5a66a423764c6..65c991010beb01a662ab0f65c31b350e6d636685 100644 --- a/dnn/nnet.c +++ b/dnn/nnet.c @@ -218,59 +218,6 @@ void _lpcnet_compute_dense(const DenseLayer *layer, float *output, const float * compute_activation(output, output, layer->nb_neurons, layer->activation); } -int sample_mdense(const MDenseLayer *layer, const float *input, const float *sampling_logit_table, kiss99_ctx *rng) -{ - int b, j, N, M, C, stride; - int val=0; - float thresholds[8]; - M = layer->nb_inputs; - N = layer->nb_neurons; - C = layer->nb_channels; - celt_assert(N*C <= MAX_MDENSE_TMP); - stride = M*C; - - celt_assert(N <= DUAL_FC_OUT_SIZE); - - /* Computing all the random thresholds in advance. These thresholds are directly - based on the logit to avoid computing the sigmoid.*/ - for (b=0;b<8;b+=4) { - uint32_t r = kiss99_rand(rng); - thresholds[b] = sampling_logit_table[r&0xFF]; - thresholds[b+1] = sampling_logit_table[(r>>8)&0xFF]; - thresholds[b+2] = sampling_logit_table[(r>>16)&0xFF]; - thresholds[b+3] = sampling_logit_table[(r>>24)&0xFF]; - } - - for (b=0;b<8;b++) - { - int bit; - int i; - float sum1, sum2; - - i = (1<<b) | val; - - sum1 = layer->bias[i]; - sum2 = layer->bias[i + N]; - for (j=0;j<M;j++) { - sum1 += layer->input_weights[i*stride + j]*input[j]; - sum2 += layer->input_weights[i*stride + j + M]*input[j]; - } - sum1 = layer->factor[i]*tanh_approx(sum1); - sum2 = layer->factor[N + i]*tanh_approx(sum2); - sum1 += sum2; - /*sum1 = 1.f/(1 + exp(-sum1));*/ -#if 1 /* Sample the decision based on the logit. */ - bit = thresholds[b] < sum1; -#else - sum1 = sigmoid_approx(sum1); - bit = .025+.95*((rand()+.5f)/(RAND_MAX+1.f)) < sum1; -#endif - val = (val << 1) | bit; - } - return val; - -} - #ifdef USE_SU_BIAS #define bias_type subias #else diff --git a/lpcnet_headers.mk b/lpcnet_headers.mk index b699a33d3d888e112d769d8e0633902853ea595e..f09adf16f46908cf899aef48bc6ae7eefb67b9da 100644 --- a/lpcnet_headers.mk +++ b/lpcnet_headers.mk @@ -10,9 +10,7 @@ dnn/common.h \ dnn/freq.h \ dnn/fargan.h \ dnn/fargan_data.h \ -dnn/kiss99.h \ dnn/lpcnet_private.h \ -dnn/nnet_data.h \ dnn/nnet.h \ dnn/plc_data.h \ dnn/tansig_table.h \ diff --git a/lpcnet_sources.mk b/lpcnet_sources.mk index 6950be8c383f0cf39ee7825ed6d4b7923d1ae70b..416b946cd02d0da454168385d65f886c0d697df9 100644 --- a/lpcnet_sources.mk +++ b/lpcnet_sources.mk @@ -3,13 +3,10 @@ dnn/burg.c \ dnn/freq.c \ dnn/fargan.c \ dnn/fargan_data.c \ -dnn/kiss99.c \ -dnn/lpcnet.c \ dnn/lpcnet_enc.c \ dnn/lpcnet_plc.c \ dnn/lpcnet_tables.c \ dnn/nnet.c \ -dnn/nnet_data.c \ dnn/plc_data.c \ dnn/parse_lpcnet_weights.c \ dnn/dred_rdovae.c \