blob: 13a3905b99500330d43abe5548dfd8e86936fb1b [file] [log] [blame]
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +01001//
2// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include <catch.hpp>
7#include <map>
8#include "Decoder.hpp"
9
10std::map<int, std::string> labels = {
11 {0, "a" },
12 {1, "b" },
13 {2, "c" },
14 {3, "d" },
15 {4, "e" },
16 {5, "f" },
17 {6, "g" },
18 {7, "h" },
19 {8, "i" },
20 {9, "j" },
21 {10,"k" },
22 {11,"l" },
23 {12,"m" },
24 {13,"n" },
25 {14,"o" },
26 {15,"p" },
27 {16,"q" },
28 {17,"r" },
29 {18,"s" },
30 {19,"t" },
31 {20,"u" },
32 {21,"v" },
33 {22,"w" },
34 {23,"x" },
35 {24,"y" },
36 {25,"z" },
37 {26, "\'" },
38 {27, " "},
39 {28,"$" }
40};
41
42TEST_CASE("Test Wav2Letter output decoder")
43{
44
45 std::vector<uint16_t> outputValues =
46 {
47 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,
48
49 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,
50
51 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
52
53 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
54
55 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, 1,
56
57 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, 1,
58
59 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
60
61 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, 1,
62
63 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, 1,
64
65 1, 1, 1, 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,
66
67 1, 1, 1, 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,
68
69 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
70
71 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2
72 };
73
74 std::vector<int8_t> convertedValues;
75
76 for(uint16_t outputVal : outputValues)
77 {
78 convertedValues.emplace_back(static_cast<int8_t>(outputVal));
79 }
80
81 asr::Decoder decoder(labels);
82 std::string text = decoder.DecodeOutput<int8_t>(convertedValues);
83 CHECK(text == "hello");
84}
85
86