first pass at a small set of working ctests

dr-fix-ctests
drowe67 2022-08-20 09:10:11 +09:30 committed by David Rowe
parent 391ea7c77b
commit 0ed9aa9b58
14 changed files with 14 additions and 77 deletions

View File

@ -34,6 +34,4 @@ jobs:
mkdir -p build_linux && cd build_linux
cmake -DCODEC2_BUILD_DIR=$GITHUB_WORKSPACE/codec2/build_linux ..
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
ctest

View File

@ -192,16 +192,23 @@ 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;
cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
dump_data --test --c2pitch ${CMAKE_CURRENT_SOURCE_DIR}/wav/birch.wav birch.f32
diff 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")

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.

View File

@ -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"