From 80eecfbdaad689c52d5a6d370a322f3d6a6150e4 Mon Sep 17 00:00:00 2001 From: alexander Date: Tue, 6 Jul 2021 19:47:59 +0100 Subject: MLECO-1987: Minor refactoring. ASRSlidingWindow can be used in other use-cases, thus it was renamed to decouple from ASR. Signed-off-by: alexander Change-Id: I2df977e4f18f490a532e0f27e3625b153ca464d7 --- source/application/main/include/AudioUtils.hpp | 29 +++++++++++----------- .../main/include/UseCaseCommonUtils.hpp | 9 +++++-- 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'source/application/main/include') diff --git a/source/application/main/include/AudioUtils.hpp b/source/application/main/include/AudioUtils.hpp index cba981d..cbf7bb7 100644 --- a/source/application/main/include/AudioUtils.hpp +++ b/source/application/main/include/AudioUtils.hpp @@ -124,18 +124,6 @@ namespace audio { return ((m_dataSize - m_size)/m_stride); } - /** - * @brief Calculates number of times the window can stride through the given data. - * May not be a whole number. - * @return Number of strides to cover all data. - */ - float FractionalTotalStrides() { - if (this->m_dataSize < this->m_size) { - return 0; - } else { - return ((this->m_dataSize - this->m_size)/ static_cast(this->m_stride)); - } - } protected: T *m_start = nullptr; @@ -146,11 +134,11 @@ namespace audio { }; /* - * Sliding window for ASR will cover the whole of the input, even if + * Sliding window that will cover the whole length of the input, even if * this means the last window is not a full window length. */ template - class ASRSlidingWindow : public SlidingWindow { + class FractionalSlidingWindow : public SlidingWindow { public: using SlidingWindow::SlidingWindow; @@ -161,6 +149,19 @@ namespace audio { bool HasNext() { return this->m_count < 1 + this->FractionalTotalStrides() && (this->NextWindowStartIndex() < this->m_dataSize); } + + /** + * @brief Calculates number of times the window can stride through the given data. + * May not be a whole number. + * @return Number of strides to cover all data. + */ + float FractionalTotalStrides() { + if (this->m_dataSize < this->m_size) { + return 0; + } else { + return ((this->m_dataSize - this->m_size) / static_cast(this->m_stride)); + } + } }; diff --git a/source/application/main/include/UseCaseCommonUtils.hpp b/source/application/main/include/UseCaseCommonUtils.hpp index d328392..0af22f3 100644 --- a/source/application/main/include/UseCaseCommonUtils.hpp +++ b/source/application/main/include/UseCaseCommonUtils.hpp @@ -58,8 +58,13 @@ namespace app { * @param[in] lineBreakForNumElements number of elements * after which line break will be added. **/ - void DumpTensor(TfLiteTensor* tensor, - const size_t lineBreakForNumElements = 16); + void DumpTensor(const TfLiteTensor* tensor, + size_t lineBreakForNumElements = 16); + + + void DumpTensorData(const uint8_t* tensorData, + size_t size, + size_t lineBreakForNumElements = 16); #endif /* VERIFY_TEST_OUTPUT */ /** -- cgit v1.2.1