mirror of https://github.com/drowe67/LPCNet.git
Merge branch 'master' into ms-uncouple-codec2
commit
40462489c4
|
@ -25,6 +25,9 @@ jobs:
|
|||
mkdir -p build_linux && cd build_linux
|
||||
cmake ..
|
||||
make
|
||||
# simple test to make sure the code runs
|
||||
cd src && sox ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null
|
||||
|
||||
- name: Run ctests
|
||||
shell: bash
|
||||
run: |
|
||||
cd build_linux
|
||||
ctest -V --output-on-failure
|
||||
|
|
|
@ -178,16 +178,26 @@ add_subdirectory(src)
|
|||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
add_test(NAME core_synthesis_default
|
||||
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; SYNTH=1 ./test_core_nn.sh")
|
||||
add_test(NAME core_synthesis_load_20h
|
||||
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; SYNTH_20h=1 ./test_core_nn.sh")
|
||||
add_test(NAME core_synthesis_mag
|
||||
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest; SYNTH_mag=1 ./test_core_nn.sh")
|
||||
# some basic tests - unfortunately the core NN synthsis is hard to test reliably as we get
|
||||
# different results on different runs due to numerical/precision issues
|
||||
add_test(NAME feature_extraction
|
||||
COMMAND sh -c "PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src:${CMAKE_CURRENT_BINARY_DIR}/unittest;
|
||||
cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
|
||||
pwd;
|
||||
dump_data --test --c2pitch ${CMAKE_CURRENT_SOURCE_DIR}/wav/birch.wav birch.f32;
|
||||
md5sum birch.f32;
|
||||
md5sum birch_targ.f32;
|
||||
diff32 --cont birch_targ.f32 birch.f32")
|
||||
add_test(NAME nnet2f32
|
||||
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}; ./src/nnet2f32 t.f32")
|
||||
add_test(NAME SIMD_functions
|
||||
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}; ./src/test_vec")
|
||||
add_test(NAME lpcnet_enc_dec
|
||||
COMMAND sh -c "PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src;
|
||||
cd ${CMAKE_CURRENT_SOURCE_DIR};
|
||||
sox wav/wia.wav -t raw -r 16000 - |
|
||||
lpcnet_enc -s |
|
||||
lpcnet_dec -s > /dev/null")
|
||||
|
||||
# Packaging
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Next-Generation Digital Voice for Two-Way Radio")
|
||||
|
|
43
src/diff32.c
43
src/diff32.c
|
@ -1,4 +1,8 @@
|
|||
/* test tool to diffs two .f32 files */
|
||||
/* Test tool to diff two float (.f32) files that hold LPCNet
|
||||
"features". Each file can be seen as a matrix, where each row has
|
||||
"stride" columns. We calculate the "SNR" of each col measured
|
||||
between the two files, as each col represents a specific feature
|
||||
that will have it's own scaling. */
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
@ -6,10 +10,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#define NB_FEATURES 55
|
||||
#define NB_FEATURES 55
|
||||
#define FDIFF_THRESH 0.001
|
||||
#define SNR_THRESH 1000.0
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
float fdiff, fdiff_tot=0.0;
|
||||
int f=0;
|
||||
unsigned int ret, i, stride = NB_FEATURES, cont = 0;
|
||||
|
||||
|
@ -56,21 +61,39 @@ int main(int argc, char *argv[]) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
float f1[stride],f2[stride];
|
||||
float fdiff;
|
||||
float f1[stride], f2[stride], s[stride], n[stride];
|
||||
for(i=0; i<stride; i++) {s[i] = 0.0; n[i] = 0.0; }
|
||||
|
||||
while(fread(&f1,sizeof(float),stride,file1) == stride) {
|
||||
ret = fread(&f2,sizeof(float),stride,file2);
|
||||
if (ret != stride) break;
|
||||
for(i=0; i<stride; i++) {
|
||||
s[i] += f1[i]*f1[i];
|
||||
fdiff = fabs(f1[i]-f2[i]);
|
||||
fdiff_tot += fdiff;
|
||||
|
||||
if (isnan(fdiff) || (fdiff > 1E-3)) {
|
||||
printf("f: %d i: %d %f %f %f\n", f, i, f1[i], f2[i], fdiff);
|
||||
if (cont == 0) exit(0);
|
||||
n[i] += fdiff*fdiff;
|
||||
|
||||
/* flag any gross errors straight away */
|
||||
if (isnan(fdiff) || (fdiff > FDIFF_THRESH)) {
|
||||
fprintf(stderr, "f: %d i: %d %f %f %f\n", f, i, f1[i], f2[i], fdiff);
|
||||
if (cont == 0) exit(1);
|
||||
}
|
||||
}
|
||||
f++;
|
||||
}
|
||||
fprintf(stderr,"stride: %d f: %d fdiff_tot: %f\n", stride, f, fdiff_tot);
|
||||
|
||||
fclose(file1); fclose(file2);
|
||||
|
||||
/* calculate per col SNRs, as each feature might have a different scaling */
|
||||
float snr_min = 1E32;
|
||||
for(i=0; i<stride; i++) {
|
||||
float snr = s[i]/(n[i]+1E-12);
|
||||
if ((s[i] != 0) && (snr < snr_min)) snr_min = snr;
|
||||
fprintf(stderr, "i: %d s: %e n: %e SNR: %e %e\n", i, s[i], n[i], snr, snr_min);
|
||||
}
|
||||
|
||||
if (snr_min > SNR_THRESH)
|
||||
exit(0);
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -438,7 +438,9 @@ int main(int argc, char **argv) {
|
|||
g = f*speech_gain + (1-f)*old_speech_gain;
|
||||
x[i] *= g;
|
||||
}
|
||||
for (i=0;i<FRAME_SIZE;i++) x[i] += rand()/(float)RAND_MAX - .5;
|
||||
if (training) {
|
||||
for (i=0;i<FRAME_SIZE;i++) x[i] += rand()/(float)RAND_MAX - .5;
|
||||
}
|
||||
compute_frame_features(st, X, P, Ex, Ep, Exp, features, x, logmag);
|
||||
|
||||
if (c2pitch_en) {
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,68 +0,0 @@
|
|||
#!/bin/bash -x
|
||||
# test_core_nn.sh
|
||||
#
|
||||
|
||||
# Some tests for core NN, e.g. generation of test data using
|
||||
# dump_data, and unquantised synthesis using and test_lpcnet. Used to
|
||||
# ensure no existing features are broken during experimentation and
|
||||
# development.
|
||||
|
||||
# test generation of training data (doesn't really test training as that takes hours)
|
||||
# TODO: This test not working yet
|
||||
if [ ! -z $TRAIN_TEST ]; then
|
||||
TRAIN_SRC=all_speech
|
||||
TRAIN_OUT_PCM=$(mktemp).pcm
|
||||
TRAIN_OUT_F32=$(mktemp).f32
|
||||
TRAIN_TARG_PCM=all_speech.pcm
|
||||
TRAIN_TARG_F32=all_speech.f32
|
||||
../build_linux/src/dump_data --train --c2pitch -z 0 -n 1E6 ~/Downloads/$TRAIN_SRC.sw $TRAIN_OUT_F32 $TRAIN_OUT_PCM
|
||||
diff $TRAIN_OUT_F32 $TRAIN_TARG_F32 || { echo "ERROR in train .f32 output! Exiting..."; exit 1; }
|
||||
echo "train .f32 OK"
|
||||
diff $TRAIN_OUT_PCM $TRAIN_TARG_PCM || { echo "ERROR in train .pcm output! Exiting..."; exit 1; }
|
||||
echo "train .pcm OK"
|
||||
fi
|
||||
|
||||
# Basic synthesis with compiled-in in network
|
||||
|
||||
if [ ! -z $SYNTH ]; then
|
||||
../build_linux/src/dump_data --test --c2pitch ../wav/birch.wav birch.f32
|
||||
diff birch_targ.f32 birch.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; }
|
||||
echo "synth .f32 OK"
|
||||
../build_linux/src/test_lpcnet -l birch_states.f32 birch.f32 birch_out.raw
|
||||
octave -p ../src --no-gui <<< "ret=compare_states('birch_states_targ.f32', 'birch_states.f32'); quit(ret)"
|
||||
if [ ! $? -eq 0 ]; then { echo "ERROR in synth states Octave output! Exiting..."; exit 1; } fi
|
||||
echo "synth states Octave OK"
|
||||
diff birch_states_targ.f32 birch_states.f32 || { echo "ERROR in synth states output! Exiting ..."; exit 1; }
|
||||
echo "synth states OK"
|
||||
diff birch_out_targ.raw birch_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; }
|
||||
echo "synth .raw OK"
|
||||
fi
|
||||
|
||||
# Synthesis with the 20h network, loaded up at run time
|
||||
|
||||
if [ ! -z $SYNTH_20h ]; then
|
||||
../build_linux/src/dump_data --test --c2pitch ../wav/birch.wav birch.f32
|
||||
diff birch_targ.f32 birch.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; }
|
||||
echo "synth .f32 OK"
|
||||
../build_linux/src/test_lpcnet -n lpcnet_20h.f32 -l birch_states.f32 birch.f32 birch_out.raw
|
||||
octave -p ../src --no-gui <<< "ret=compare_states('birch_20h_states_targ.f32', 'birch_states.f32'); quit(ret)"
|
||||
if [ ! $? -eq 0 ]; then { echo "ERROR in synth states Octave output! Exiting..."; exit 1; } fi
|
||||
echo "synth states Octave OK"
|
||||
diff birch_20h_states_targ.f32 birch_states.f32 || { echo "ERROR in synth states output! Exiting ..."; exit 1; }
|
||||
echo "synth states OK"
|
||||
diff birch_20h_targ.raw birch_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; }
|
||||
echo "synth .raw OK"
|
||||
fi
|
||||
|
||||
# Testing log mag operation, using 190804a network. Not checking states in this test
|
||||
|
||||
if [ ! -z $SYNTH_mag ]; then
|
||||
../build_linux/src/dump_data --mag --test --c2pitch ../wav/c01_01.wav c01_01.f32
|
||||
diff c01_01_mag.f32 c01_01.f32 || { echo "ERROR in synth .f32 output! Exiting..."; exit 1; }
|
||||
echo "mag .f32 OK"
|
||||
../build_linux/src/test_lpcnet --mag 1 -n lpcnet_190804a.f32 c01_01.f32 c01_01_out.raw
|
||||
diff c01_01_190804a_targ.raw c01_01_out.raw || { echo "ERROR in synth .raw output! Exiting..."; exit 1; }
|
||||
echo "mag .raw OK"
|
||||
fi
|
||||
|
||||
echo "all tests PASSED"
|
Loading…
Reference in New Issue