Skip to content

Commit b38c4b4

Browse files
committed
Remove the need for useless exc and pred files
1 parent 91d2fbc commit b38c4b4

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This software is also a useful resource as an open source starting point for Wav
1919

2020
1. Then, run the resulting executable:
2121
```
22-
./dump_data input.s16 exc.s8 features.f32 pred.s16 pcm.s16
22+
./dump_data input.s16 features.f32 pcm.s16
2323
```
2424

2525
where the first file contains 16 kHz 16-bit raw PCM audio (no header)
@@ -29,7 +29,7 @@ always use ±5% or 10% resampling to augment your data).
2929

3030
1. Now that you have your files, you can do the training with:
3131
```
32-
./train_lpcnet.py exc.s8 features.f32 pred.s16 pcm.s16
32+
./train_lpcnet.py features.f32 pcm.s16
3333
```
3434
and it will generate a wavenet*.h5 file for each iteration. If it stops with a
3535
"Failed to allocate RNN reserve space" message try reducing the *batch\_size* variable in train_wavenet_audio.py.

src/denoise.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -579,24 +579,20 @@ int main(int argc, char **argv) {
579579
float mem_preemph=0;
580580
float x[FRAME_SIZE];
581581
FILE *f1;
582-
FILE *fexc;
583582
FILE *ffeat;
584-
FILE *fpred;
585583
FILE *fpcm;
586584
signed char iexc[FRAME_SIZE];
587585
short pred[FRAME_SIZE];
588586
short pcm[FRAME_SIZE];
589587
DenoiseState *st;
590588
st = rnnoise_create();
591-
if (argc!=6) {
592-
fprintf(stderr, "usage: %s <speech> <exc out> <features out> <prediction out> <pcm out> \n", argv[0]);
589+
if (argc!=4) {
590+
fprintf(stderr, "usage: %s <speech> <features out>\n", argv[0]);
593591
return 1;
594592
}
595593
f1 = fopen(argv[1], "r");
596-
fexc = fopen(argv[2], "w");
597-
ffeat = fopen(argv[3], "w");
598-
fpred = fopen(argv[4], "w");
599-
fpcm = fopen(argv[5], "w");
594+
ffeat = fopen(argv[2], "w");
595+
fpcm = fopen(argv[3], "w");
600596
while (1) {
601597
kiss_fft_cpx X[FREQ_SIZE], P[WINDOW_SIZE];
602598
float Ex[NB_BANDS], Ep[NB_BANDS];
@@ -617,17 +613,14 @@ int main(int argc, char **argv) {
617613
preemphasis(x, &mem_preemph, x, PREEMPHASIS, FRAME_SIZE);
618614

619615
compute_frame_features(st, iexc, pred, pcm, X, P, Ex, Ep, Exp, features, x);
620-
#if 1
621-
fwrite(iexc, sizeof(signed char), FRAME_SIZE, fexc);
622616
fwrite(features, sizeof(float), NB_FEATURES, ffeat);
623-
fwrite(pred, sizeof(short), FRAME_SIZE, fpred);
624617
fwrite(pcm, sizeof(short), FRAME_SIZE, fpcm);
625-
#endif
626618
count++;
627619
}
628620
//fprintf(stderr, "matrix size: %d x %d\n", count, NB_FEATURES + 2*NB_BANDS + 1);
629621
fclose(f1);
630-
fclose(fexc);
622+
fclose(ffeat);
623+
fclose(fpcm);
631624
return 0;
632625
}
633626

src/train_lpcnet.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@
5656
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
5757
model.summary()
5858

59-
exc_file = sys.argv[1] # not used at present
60-
feature_file = sys.argv[2]
61-
pred_file = sys.argv[3] # LPC predictor samples. Not used at present, see below
62-
pcm_file = sys.argv[4] # 16 bit unsigned short PCM samples
59+
feature_file = sys.argv[1]
60+
pcm_file = sys.argv[2] # 16 bit unsigned short PCM samples
6361
frame_size = 160
6462
nb_features = 55
6563
nb_used_features = model.nb_used_features
@@ -96,8 +94,7 @@
9694
# Note: the LPC predictor output is now calculated by the loop below, this code was
9795
# for an ealier version that implemented the prediction filter in C
9896

99-
upred = np.fromfile(pred_file, dtype='int16')
100-
upred = upred[:nb_frames*pcm_chunk_size]
97+
upred = np.zeros((nb_frames*pcm_chunk_size,), dtype='int16')
10198

10299
# Use 16th order LPC to generate LPC prediction output upred[] and (in
103100
# mu-law form) pred[]

0 commit comments

Comments
 (0)