xref: /aosp_15_r20/external/armnn/samples/KeywordSpotting/include/DsCNNPreprocessor.hpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #ifndef KEYWORD_SPOTTING_EXAMPLE_DSCNNPREPROCESSOR_HPP
6 #define KEYWORD_SPOTTING_EXAMPLE_DSCNNPREPROCESSOR_HPP
7 
8 #include <numeric>
9 #include "DsCnnMfcc.hpp"
10 
11 namespace kws
12 {
13 class DsCNNPreprocessor
14 {
15 public:
16     DsCNNPreprocessor(uint32_t windowLen, uint32_t windowStride,
17                       std::unique_ptr<DsCnnMFCC> mfccInst);
18 
19     /**
20     * @brief       Calculates the features required from audio data. This
21     *              includes MFCC, first and second order deltas,
22     *              normalisation and finally, quantisation. The tensor is
23     *              populated with feature from a given window placed along
24     *              in a single row.
25     * @param[in]   audioData     pointer to the first element of audio data
26     * @param[in]   output        output to be populated
27     * @return      true if successful, false in case of error.
28     */
29     std::vector<int8_t> Invoke(const float* audioData,
30                                size_t dataSize,
31                                int quantOffset,
32                                float quantScale) ;
33 
34     uint32_t m_windowLen;       // Window length for MFCC
35     uint32_t m_windowStride;    // Window stride len for MFCC
36     std::unique_ptr<MFCC> m_mfcc;
37 };
38 } // namespace kws
39 #endif //KEYWORD_SPOTTING_EXAMPLE_DSCNNPREPROCESSOR_HPP
40