blob: e0bb8685aa02ba6961af66a842a9a15345fb6cc4 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Richard Burtonec5e99b2022-10-05 11:00:37 +01002 * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
alexander3c798932021-03-26 21:42:19 +00003 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef KWS_RESULT_HPP
18#define KWS_RESULT_HPP
19
20#include "ClassificationResult.hpp"
21
22#include <vector>
23
24namespace arm {
25namespace app {
26namespace kws {
27
Richard Burtonb40ecf82022-04-22 16:14:57 +010028 using ResultVec = std::vector<arm::app::ClassificationResult>;
alexander3c798932021-03-26 21:42:19 +000029
30 /* Structure for holding kws result. */
31 class KwsResult {
32
33 public:
34 ResultVec m_resultVec; /* Container for "thresholded" classification results. */
35 float m_timeStamp; /* Audio timestamp for this result. */
36 uint32_t m_inferenceNumber; /* Corresponding inference number. */
37 float m_threshold; /* Threshold value for `m_resultVec`. */
38
39 KwsResult() = delete;
40 KwsResult(ResultVec& resultVec,
41 const float timestamp,
42 const uint32_t inferenceIdx,
43 const float scoreThreshold) {
44
45 this->m_threshold = scoreThreshold;
46 this->m_timeStamp = timestamp;
47 this->m_inferenceNumber = inferenceIdx;
48
49 this->m_resultVec = ResultVec();
Richard Burtonec5e99b2022-10-05 11:00:37 +010050 for (auto& i : resultVec) {
alexander3c798932021-03-26 21:42:19 +000051 if (i.m_normalisedVal >= this->m_threshold) {
52 this->m_resultVec.emplace_back(i);
53 }
54 }
55 }
56 ~KwsResult() = default;
57 };
58
59} /* namespace kws */
60} /* namespace app */
61} /* namespace arm */
62
63#endif /* KWS_RESULT_HPP */