summaryrefslogtreecommitdiff
path: root/source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc
diff options
context:
space:
mode:
authorLiam Barry <liam.barry@arm.com>2023-08-03 18:21:58 +0100
committerRichard <richard.burton@arm.com>2023-08-29 12:48:06 +0000
commit677d43fa8f55a8aa52e6bd9d1884e2797650fd65 (patch)
tree154774010a306aeac14bf2eb4b4a0846dd905c1b /source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc
parentf1b28b861e301122b85ad7dc3d8ccb0720fcb584 (diff)
downloadml-embedded-evaluation-kit-677d43fa8f55a8aa52e6bd9d1884e2797650fd65.tar.gz
MLECO-4260: Replace raw C++ pointers with smart variants
Model: Added std::unique_ptr qualifier to Model.cc member and used make_unique when creating interpreter object Removed custom destructor and un-necessary memory cleanup following failed allocation DataStructures: Refactored array 2d to use a std::vector under the hood. This should preserve desired attributes including contiguous memory while removing the need for custom destructor. Original size function renamed to dimSize to avoid confusion with vector.size() Accompanying changes made to preprocessing and ASR tests. AppContext: Replaced use of raw pointers in AppContext.hpp. Previously a std::map including IAttribute pointers required individual deallocation as they were allocated using new. Signed-off-by: Liam Barry <liam.barry@arm.com> Change-Id: I1a34dce5dea6ecf4883a9ada3a20f827eb6e6d6b
Diffstat (limited to 'source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc')
-rw-r--r--source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc b/source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc
index 99e769c..1794894 100644
--- a/source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc
+++ b/source/application/api/use_case/asr/src/Wav2LetterPreprocess.cc
@@ -1,6 +1,6 @@
/*
- * SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
- * SPDX-License-Identifier: Apache-2.0
+ * SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates
+ * <open-source-office@arm.com> SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ namespace app {
mfccWindow,
mfccWindow + this->m_mfccWindowLen);
auto mfcc = this->m_mfcc.MfccCompute(mfccAudioData);
- for (size_t i = 0; i < this->m_mfccBuf.size(0); ++i) {
+ for (size_t i = 0; i < this->m_mfccBuf.dimSize(0); ++i) {
this->m_mfccBuf(i, mfccBufIdx) = mfcc[i];
}
++mfccBufIdx;
@@ -126,16 +126,16 @@ namespace app {
-0.03679654, -0.04329004, -0.03679654,
-0.01731602, 0.01515152, 0.06060606};
- if (delta1.size(0) == 0 || delta2.size(0) != delta1.size(0) ||
- mfcc.size(0) == 0 || mfcc.size(1) == 0) {
+ if (delta1.dimSize(0) == 0 || delta2.dimSize(0) != delta1.dimSize(0) ||
+ mfcc.dimSize(0) == 0 || mfcc.dimSize(1) == 0) {
return false;
}
/* Get the middle index; coeff vec len should always be odd. */
const size_t coeffLen = delta1Coeffs.size();
const size_t fMidIdx = (coeffLen - 1)/2;
- const size_t numFeatures = mfcc.size(0);
- const size_t numFeatVectors = mfcc.size(1);
+ const size_t numFeatures = mfcc.dimSize(0);
+ const size_t numFeatVectors = mfcc.dimSize(1);
/* Iterate through features in MFCC vector. */
for (size_t i = 0; i < numFeatures; ++i) {
@@ -169,7 +169,7 @@ namespace app {
void AsrPreProcess::StandardizeVecF32(Array2d<float>& vec)
{
- auto mean = math::MathUtils::MeanF32(vec.begin(), vec.totalSize());
+ auto mean = math::MathUtils::MeanF32(vec.begin(), vec.totalSize());
auto stddev = math::MathUtils::StdDevF32(vec.begin(), vec.totalSize(), mean);
debug("Mean: %f, Stddev: %f\n", mean, stddev);