mirror of https://github.com/drowe67/LPCNet.git
added small vec test feature to quant_feat (didn't work well), and random bit error simulation feature to lpcnet_dec
parent
49d323bff7
commit
52a2198ad7
|
|
@ -142,7 +142,11 @@ Same thing with everything integrated into stand alone encoder and decoder progr
|
|||
|
||||
```cat ~/Downloads/speech_orig_16k.s16 | ./lpcnet_enc | ./lpcnet_dec | aplay -f S16_LE -r 16000```
|
||||
|
||||
The bit stream interface is 1 bit/char, as I find that convenient for my digital voice over radio experiments. The decimation rate, number of VQ stages, and a few other parameters can be set as command line options. You'll need the same set of parameters for the encoder as decoder.
|
||||
The bit stream interface is 1 bit/char, as I find that convenient for my digital voice over radio experiments. The decimation rate, number of VQ stages, and a few other parameters can be set as command line options, for example 20ms frame rate, 3 stage VQ (2050 bits/s):
|
||||
|
||||
```cat ~/Downloads/speech_orig_16k.s16 | ./lpcnet_enc -d 2 -n 3 | ./lpcnet_dec -d 2 -n 3 | aplay -f S16_LE -r 16000```
|
||||
|
||||
You'll need the same set of parameters for the encoder as decoder.
|
||||
|
||||
Useful additions would be:
|
||||
|
||||
|
|
|
|||
|
|
@ -58,10 +58,12 @@ int main(int argc, char **argv) {
|
|||
int mbest_survivors = 5;
|
||||
float weight = 1.0/sqrt(NB_BANDS);
|
||||
int pitch_bits = 6;
|
||||
|
||||
float ber = 0.0;
|
||||
|
||||
/* quantiser options */
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"ber", required_argument, 0, 'b'},
|
||||
{"decimate", required_argument, 0, 'd'},
|
||||
{"numstages", required_argument, 0, 'n'},
|
||||
{"pitchquant", required_argument, 0, 'o'},
|
||||
|
|
@ -73,8 +75,12 @@ int main(int argc, char **argv) {
|
|||
int c;
|
||||
int opt_index = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "d:n:o:p:v", long_options, &opt_index)) != -1) {
|
||||
while ((c = getopt_long (argc, argv, "b:d:n:o:p:v", long_options, &opt_index)) != -1) {
|
||||
switch (c) {
|
||||
case 'b':
|
||||
ber = atof(optarg);
|
||||
fprintf(stderr, "BER = %f\n", ber);
|
||||
break;
|
||||
case 'd':
|
||||
dec = atoi(optarg);
|
||||
fprintf(stderr, "dec = %d\n", dec);
|
||||
|
|
@ -94,8 +100,10 @@ int main(int argc, char **argv) {
|
|||
case 'v':
|
||||
lpcnet_verbose = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"usage: %s [Options]:\n [-d --decimation 1/2/3...]\n", argv[0]);
|
||||
default:
|
||||
fprintf(stderr,"usage: %s [Options]:\n", argv[0]);
|
||||
fprintf(stderr," [-b --ber BER]\n");
|
||||
fprintf(stderr," [-d --decimation 1/2/3...]\n");
|
||||
fprintf(stderr," [-n --numstages]\n [-o --pitchbits nBits]\n");
|
||||
fprintf(stderr," [-p --pred predCoff]\n");
|
||||
fprintf(stderr," [-v --verbose]\n");
|
||||
|
|
@ -120,13 +128,27 @@ int main(int argc, char **argv) {
|
|||
|
||||
fin = stdin;
|
||||
fout = stdout;
|
||||
|
||||
int nbits = 0, nerrs = 0;
|
||||
|
||||
do {
|
||||
float in_features[NB_TOTAL_FEATURES];
|
||||
float features[NB_TOTAL_FEATURES];
|
||||
short pcm[FRAME_SIZE];
|
||||
if ((q->f % q->dec) == 0)
|
||||
if ((q->f % q->dec) == 0) {
|
||||
bits_read = fread(frame, sizeof(char), q->bits_per_frame, fin);
|
||||
nbits += bits_read;
|
||||
if (ber != 0.0) {
|
||||
int i;
|
||||
for(i=0; i<q->bits_per_frame; i++) {
|
||||
float r = (float)rand()/RAND_MAX;
|
||||
if (r < ber) {
|
||||
frame[i] = (frame[i] ^ 1) & 0x1;
|
||||
nerrs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
lpcnet_frame_to_features(q, frame, in_features);
|
||||
|
||||
RNN_COPY(features, in_features, NB_TOTAL_FEATURES);
|
||||
|
|
@ -139,5 +161,8 @@ int main(int argc, char **argv) {
|
|||
fclose(fin);
|
||||
fclose(fout);
|
||||
lpcnet_destroy(net); lpcnet_quant_destroy(q);
|
||||
|
||||
if (ber != 0.0)
|
||||
fprintf(stderr, "nbits: %d nerr: %d BER: %4.3f\n", nbits, nerrs, (float)nerrs/nbits);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,10 +61,12 @@ int main(int argc, char *argv[]) {
|
|||
float weight = 1.0;
|
||||
float pitch_gain_bias = 0.0;
|
||||
int pitch_bits = 0;
|
||||
|
||||
int small_vec = 0;
|
||||
|
||||
for(i=0; i<MAX_STAGES*NB_BANDS*MAX_ENTRIES; i++) vq[i] = 0.0;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"small", required_argument, 0, 'a'},
|
||||
{"decimate", required_argument, 0, 'd'},
|
||||
{"extpitch", required_argument, 0, 'e'},
|
||||
{"first", required_argument, 0, 'f'},
|
||||
|
|
@ -83,10 +85,14 @@ int main(int argc, char *argv[]) {
|
|||
};
|
||||
|
||||
int opt_index = 0;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "d:q:vs:f:p:e:u:l:m:h:wg:o:", long_options, &opt_index)) != -1) {
|
||||
|
||||
while ((c = getopt_long (argc, argv, "ad:q:vs:f:p:e:u:l:m:h:wg:o:", long_options, &opt_index)) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
case 'a':
|
||||
/* small cpectral vectors - zero out several bands */
|
||||
small_vec = 1;
|
||||
break;
|
||||
case 'f':
|
||||
/* start VQ at band first+1 */
|
||||
first = atoi(optarg);
|
||||
k = NB_BANDS-first;
|
||||
|
|
@ -184,7 +190,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "dec: %d pred: %3.2f num_stages: %d mbest: %d", dec, pred, num_stages, mbest_survivors);
|
||||
fprintf(stderr, "dec: %d pred: %3.2f num_stages: %d mbest: %d small: %d", dec, pred, num_stages, mbest_survivors, small_vec);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
/* delay line so we can pass some features (like pitch and voicing) through unmodified */
|
||||
|
|
@ -251,7 +257,7 @@ int main(int argc, char *argv[]) {
|
|||
fprintf(stderr, "f: %d i: %d\n", f, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* convert cepstrals to dB */
|
||||
for(i=0; i<NB_BANDS; i++)
|
||||
features[i] *= 10.0;
|
||||
|
|
@ -404,6 +410,12 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
if (small_vec) {
|
||||
/* zero out unused cepstrals in small vec mode */
|
||||
for(i=12; i<NB_BANDS; i++)
|
||||
features_out[i] = 0.0;
|
||||
}
|
||||
|
||||
fwrite(features_out, sizeof(float), NB_FEATURES, fout);
|
||||
fflush(stdin);
|
||||
fflush(stdout);
|
||||
|
|
|
|||
Loading…
Reference in New Issue