From c6ab02a626e15b4a12fc09ecd844eb8b95380c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89anna=20=C3=93=20Cath=C3=A1in?= Date: Wed, 7 Apr 2021 14:35:25 +0100 Subject: MLECO-1252 ASR sample application using the public ArmNN C++ API. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I98cd505b8772a8c8fa88308121bc94135bb45068 Signed-off-by: Éanna Ó Catháin --- samples/SpeechRecognition/test/DecoderTest.cpp | 86 ++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 samples/SpeechRecognition/test/DecoderTest.cpp (limited to 'samples/SpeechRecognition/test/DecoderTest.cpp') diff --git a/samples/SpeechRecognition/test/DecoderTest.cpp b/samples/SpeechRecognition/test/DecoderTest.cpp new file mode 100644 index 0000000000..13a3905b99 --- /dev/null +++ b/samples/SpeechRecognition/test/DecoderTest.cpp @@ -0,0 +1,86 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include +#include +#include "Decoder.hpp" + +std::map labels = { + {0, "a" }, + {1, "b" }, + {2, "c" }, + {3, "d" }, + {4, "e" }, + {5, "f" }, + {6, "g" }, + {7, "h" }, + {8, "i" }, + {9, "j" }, + {10,"k" }, + {11,"l" }, + {12,"m" }, + {13,"n" }, + {14,"o" }, + {15,"p" }, + {16,"q" }, + {17,"r" }, + {18,"s" }, + {19,"t" }, + {20,"u" }, + {21,"v" }, + {22,"w" }, + {23,"x" }, + {24,"y" }, + {25,"z" }, + {26, "\'" }, + {27, " "}, + {28,"$" } +}; + +TEST_CASE("Test Wav2Letter output decoder") +{ + + std::vector outputValues = + { + 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,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convertedValues; + + for(uint16_t outputVal : outputValues) + { + convertedValues.emplace_back(static_cast(outputVal)); + } + + asr::Decoder decoder(labels); + std::string text = decoder.DecodeOutput(convertedValues); + CHECK(text == "hello"); +} + + -- cgit v1.2.1