blob: c221eef588afb5f8208fdffa3ba077c8a18cd4f6 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Richard Burtonf32a86a2022-11-15 11:46:11 +00002 * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
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 ASR_RESULT_HPP
18#define ASR_RESULT_HPP
19
20#include "ClassificationResult.hpp"
21
22#include <vector>
23
24namespace arm {
25namespace app {
26namespace asr {
27
Richard Burtonc2911442022-04-22 09:08:21 +010028 using ResultVec = std::vector<arm::app::ClassificationResult>;
alexander3c798932021-03-26 21:42:19 +000029
30 /* Structure for holding ASR result. */
31 class AsrResult {
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 AsrResult() = delete;
40 AsrResult(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();
50 for (auto& i : resultVec) {
51 if (i.m_normalisedVal >= this->m_threshold) {
52 this->m_resultVec.emplace_back(i);
53 }
54 }
55 }
56 ~AsrResult() = default;
57 };
58
59} /* namespace asr */
60} /* namespace app */
61} /* namespace arm */
62
63#endif /* ASR_RESULT_HPP */