diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d0cbf61..0609529 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a3611e..96d20b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/unittest/birch_20h_states_targ.f32 b/unittest/birch_20h_states_targ.f32 deleted file mode 100644 index fccec93..0000000 Binary files a/unittest/birch_20h_states_targ.f32 and /dev/null differ diff --git a/unittest/birch_20h_targ.raw b/unittest/birch_20h_targ.raw deleted file mode 100644 index 5203e14..0000000 Binary files a/unittest/birch_20h_targ.raw and /dev/null differ diff --git a/unittest/birch_mag.f32 b/unittest/birch_mag.f32 deleted file mode 100644 index 97e833e..0000000 Binary files a/unittest/birch_mag.f32 and /dev/null differ diff --git a/unittest/birch_out_targ.raw b/unittest/birch_out_targ.raw deleted file mode 100644 index 8ea4bbd..0000000 Binary files a/unittest/birch_out_targ.raw and /dev/null differ diff --git a/unittest/birch_states_targ.f32 b/unittest/birch_states_targ.f32 deleted file mode 100644 index 41fefdb..0000000 Binary files a/unittest/birch_states_targ.f32 and /dev/null differ diff --git a/unittest/birch_targ.f32 b/unittest/birch_targ.f32 index 26f5b24..ae78f92 100644 Binary files a/unittest/birch_targ.f32 and b/unittest/birch_targ.f32 differ diff --git a/unittest/c01_01_190804a_targ.raw b/unittest/c01_01_190804a_targ.raw deleted file mode 100644 index 65a440e..0000000 Binary files a/unittest/c01_01_190804a_targ.raw and /dev/null differ diff --git a/unittest/c01_01_mag.f32 b/unittest/c01_01_mag.f32 deleted file mode 100644 index 466adfa..0000000 Binary files a/unittest/c01_01_mag.f32 and /dev/null differ diff --git a/unittest/lpcnet_190215.f32 b/unittest/lpcnet_190215.f32 deleted file mode 100644 index 4881544..0000000 Binary files a/unittest/lpcnet_190215.f32 and /dev/null differ diff --git a/unittest/lpcnet_190804a.f32 b/unittest/lpcnet_190804a.f32 deleted file mode 100644 index 9e38953..0000000 Binary files a/unittest/lpcnet_190804a.f32 and /dev/null differ diff --git a/unittest/lpcnet_20h.f32 b/unittest/lpcnet_20h.f32 deleted file mode 100644 index 28a8900..0000000 Binary files a/unittest/lpcnet_20h.f32 and /dev/null differ diff --git a/unittest/test_core_nn.sh b/unittest/test_core_nn.sh deleted file mode 100755 index cd955c7..0000000 --- a/unittest/test_core_nn.sh +++ /dev/null @@ -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"