ref: 80751bad709ce33f892b2f8b34f1e62d20d73574
parent: 4c6a5e0e60f1449c157632b6cf9fecbe663512c3
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Fri Aug 13 22:06:55 EDT 2021
frame-wise features
--- a/dnn/dump_data.c
+++ b/dnn/dump_data.c
@@ -75,9 +75,9 @@
}
-void write_audio(LPCNetEncState *st, const short *pcm, const int *noise, FILE *file) {+void write_audio(LPCNetEncState *st, const short *pcm, const int *noise, FILE *file, int nframes) {int i, k;
- for (k=0;k<4;k++) {+ for (k=0;k<nframes;k++) {unsigned char data[4*FRAME_SIZE];
for (i=0;i<FRAME_SIZE;i++) {float p=0;
@@ -270,12 +270,15 @@
if (fpcm) {compute_noise(&noisebuf[st->pcount*FRAME_SIZE], noise_std);
}
+ process_single_frame(st, ffeat);
+ if (fpcm) write_audio(st, pcm, &noisebuf[st->pcount*FRAME_SIZE], fpcm, 1);
+
st->pcount++;
/* Running on groups of 4 frames. */
if (st->pcount == 4) {- unsigned char buf[8];
- process_superframe(st, buf, ffeat, encode, quantize);
- if (fpcm) write_audio(st, pcmbuf, noisebuf, fpcm);
+ //unsigned char buf[8];
+ //process_superframe(st, buf, ffeat, encode, quantize);
+ //if (fpcm) write_audio(st, pcmbuf, noisebuf, fpcm, 4);
st->pcount = 0;
}
//if (fpcm) fwrite(pcm, sizeof(short), FRAME_SIZE, fpcm);
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -860,14 +860,6 @@
return 0;
}
-void print_vec(float *x, int len) {- int i;
- for (i=0;i<len;i++) {- printf("%f ", x[i]);- }
- printf("\n");-}
-
LPCNET_EXPORT int lpcnet_compute_features(LPCNetEncState *st, const short *pcm, float features[4][NB_TOTAL_FEATURES]) {int i, k;
for (k=0;k<4;k++) {@@ -876,13 +868,21 @@
preemphasis(x, &st->mem_preemph, x, PREEMPHASIS, FRAME_SIZE);
st->pcount = k;
compute_frame_features(st, x);
- process_single_frame(st, NULL);
}
- //process_superframe(st, NULL, NULL, 0, 0);
- //process_multi_frame(st, NULL);
+ process_superframe(st, NULL, NULL, 0, 0);
for (k=0;k<4;k++) {RNN_COPY(&features[k][0], &st->features[k][0], NB_TOTAL_FEATURES);
- //print_vec(&features[k][0], 20);
}
+ return 0;
+}
+
+LPCNET_EXPORT int lpcnet_compute_single_frame_features(LPCNetEncState *st, const short *pcm, float features[NB_TOTAL_FEATURES]) {+ int i;
+ float x[FRAME_SIZE];
+ for (i=0;i<FRAME_SIZE;i++) x[i] = pcm[i];
+ preemphasis(x, &st->mem_preemph, x, PREEMPHASIS, FRAME_SIZE);
+ compute_frame_features(st, x);
+ process_single_frame(st, NULL);
+ RNN_COPY(features, &st->features[0][0], NB_TOTAL_FEATURES);
return 0;
}
--
⑨