aboutsummaryrefslogtreecommitdiff
path: root/samples/KeywordSpotting/include/DsCNNPreprocessor.hpp
diff options
context:
space:
mode:
authorGeorge Gekov <george.gekov@arm.com>2021-08-16 11:32:10 +0100
committerJim Flynn <jim.flynn@arm.com>2022-02-05 19:49:06 +0000
commit23c26277086c78704a17f0dae86da947816320c0 (patch)
tree88b02fd1fae3130256d059251788a7ef68d2831f /samples/KeywordSpotting/include/DsCNNPreprocessor.hpp
parent922b912fd2d462bac0809bac5669310ad1506310 (diff)
downloadarmnn-23c26277086c78704a17f0dae86da947816320c0.tar.gz
MLECO-2079 Adding the C++ KWS example
Signed-off-by: Eanna O Cathain <eanna.ocathain@arm.com> Change-Id: I81899bbfaada32f478c2e2fc6441eabb94d8d0fc
Diffstat (limited to 'samples/KeywordSpotting/include/DsCNNPreprocessor.hpp')
-rw-r--r--samples/KeywordSpotting/include/DsCNNPreprocessor.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/samples/KeywordSpotting/include/DsCNNPreprocessor.hpp b/samples/KeywordSpotting/include/DsCNNPreprocessor.hpp
new file mode 100644
index 0000000000..b635d1a41e
--- /dev/null
+++ b/samples/KeywordSpotting/include/DsCNNPreprocessor.hpp
@@ -0,0 +1,39 @@
+//
+// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#ifndef KEYWORD_SPOTTING_EXAMPLE_DSCNNPREPROCESSOR_HPP
+#define KEYWORD_SPOTTING_EXAMPLE_DSCNNPREPROCESSOR_HPP
+
+#include <numeric>
+#include "DsCnnMfcc.hpp"
+
+namespace kws
+{
+class DsCNNPreprocessor
+{
+public:
+ DsCNNPreprocessor(uint32_t windowLen, uint32_t windowStride,
+ std::unique_ptr<DsCnnMFCC> mfccInst);
+
+ /**
+ * @brief Calculates the features required from audio data. This
+ * includes MFCC, first and second order deltas,
+ * normalisation and finally, quantisation. The tensor is
+ * populated with feature from a given window placed along
+ * in a single row.
+ * @param[in] audioData pointer to the first element of audio data
+ * @param[in] output output to be populated
+ * @return true if successful, false in case of error.
+ */
+ std::vector<int8_t> Invoke(const float* audioData,
+ size_t dataSize,
+ int quantOffset,
+ float quantScale) ;
+
+ uint32_t m_windowLen; // Window length for MFCC
+ uint32_t m_windowStride; // Window stride len for MFCC
+ std::unique_ptr<MFCC> m_mfcc;
+};
+} // namespace kws
+#endif //KEYWORD_SPOTTING_EXAMPLE_DSCNNPREPROCESSOR_HPP