From d816477c58e7a229c74b910e426e2dbf14a03eb8 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 2 Feb 2022 03:54:05 -0500 Subject: [PATCH] Add decay --- dnn/lpcnet_plc.c | 7 +++++++ dnn/lpcnet_private.h | 1 + 2 files changed, 8 insertions(+) diff --git a/dnn/lpcnet_plc.c b/dnn/lpcnet_plc.c index d6ae6d0f..6cd8311c 100644 --- a/dnn/lpcnet_plc.c +++ b/dnn/lpcnet_plc.c @@ -47,6 +47,7 @@ LPCNET_EXPORT void lpcnet_plc_init(LPCNetPLCState *st) { st->pcm_fill = PLC_BUF_SIZE; st->skip_analysis = 0; st->blend = 0; + st->loss_count = 0; } LPCNET_EXPORT LPCNetPLCState *lpcnet_plc_create() { @@ -128,9 +129,11 @@ LPCNET_EXPORT int lpcnet_plc_update(LPCNetPLCState *st, short *pcm) { RNN_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE); } RNN_COPY(st->features, st->enc.features[0], NB_TOTAL_FEATURES); + st->loss_count = 0; return 0; } +static const float att_table[10] = {0, 0, -.2, -.2, -.4, -.4, -.8, -.8, -1.6, -1.6}; LPCNET_EXPORT int lpcnet_plc_conceal(LPCNetPLCState *st, short *pcm) { #if PLC_READ_FEATURES || PLC_DUMP_FEATURES int i; @@ -163,6 +166,9 @@ LPCNET_EXPORT int lpcnet_plc_conceal(LPCNetPLCState *st, short *pcm) { lpcnet_synthesize_tail_impl(&st->lpcnet, pcm, FRAME_SIZE-TRAINING_OFFSET, 0); #if PLC_DNN_PRED compute_plc_pred(&st->plc_net, st->features, zeros); + if (st->loss_count >= 10) st->features[0] = MAX16(-10, st->features[0]+att_table[9] - 2*(st->loss_count-9)); + else st->features[0] = MAX16(-10, st->features[0]+att_table[st->loss_count]); + if (st->loss_count > 4) st->features[NB_FEATURES-1] = MAX16(-.5, st->features[NB_FEATURES-1]-.1*(st->loss_count-4)); #endif #if PLC_READ_FEATURES for (i=0;ifeatures[i]); @@ -181,6 +187,7 @@ LPCNET_EXPORT int lpcnet_plc_conceal(LPCNetPLCState *st, short *pcm) { compute_frame_features(&st->enc, x); process_single_frame(&st->enc, NULL); } + st->loss_count++; st->blend = 1; return 0; } diff --git a/dnn/lpcnet_private.h b/dnn/lpcnet_private.h index 0c50c0b0..e1b4c99a 100644 --- a/dnn/lpcnet_private.h +++ b/dnn/lpcnet_private.h @@ -75,6 +75,7 @@ struct LPCNetPLCState { int skip_analysis; int blend; float features[NB_TOTAL_FEATURES]; + int loss_count; PLCNetState plc_net; };