diff options
author | Éanna Ó Catháin <eanna.ocathain@arm.com> | 2021-04-07 14:35:25 +0100 |
---|---|---|
committer | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2021-05-07 18:12:36 +0100 |
commit | 95b930c940c47e2f9a783cf17c87449cab4633c5 (patch) | |
tree | 3fbc7bc62f245fea6476e84ec9bc80b08f7a7a59 /samples/SpeechRecognition/include/AudioCapture.hpp | |
parent | abee0016b5b5c4129bc8d30f440449d835a6404a (diff) | |
download | armnn-95b930c940c47e2f9a783cf17c87449cab4633c5.tar.gz |
MLECO-1252 ASR sample application using the public ArmNN C++ API.
Change-Id: I98cd505b8772a8c8fa88308121bc94135bb45068
Signed-off-by: Éanna Ó Catháin <eanna.ocathain@arm.com>
Diffstat (limited to 'samples/SpeechRecognition/include/AudioCapture.hpp')
-rw-r--r-- | samples/SpeechRecognition/include/AudioCapture.hpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/samples/SpeechRecognition/include/AudioCapture.hpp b/samples/SpeechRecognition/include/AudioCapture.hpp new file mode 100644 index 0000000000..90c2eccacf --- /dev/null +++ b/samples/SpeechRecognition/include/AudioCapture.hpp @@ -0,0 +1,62 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <string> +#include <iostream> + +#include <math.h> + +#include <vector> + +#include <exception> + +#include "SlidingWindow.hpp" + +namespace asr +{ + +/** +* @brief Class used to capture the audio data loaded from file, and to provide a method of + * extracting correctly positioned and appropriately sized audio windows +* +*/ + class AudioCapture + { + public: + + SlidingWindow<const float> m_window; + int lastReadIdx= 0; + + /** + * @brief Default constructor + */ + AudioCapture() + {}; + + /** + * @brief Function to load the audio data captured from the + * input file to memory. + */ + std::vector<float> LoadAudioFile(std::string filePath); + + /** + * @brief Function to initialize the sliding window. This will set its position in memory, its + * window size and its stride. + */ + void InitSlidingWindow(float* data, size_t dataSize, int minSamples, size_t stride); + + /** + * Checks whether there is another block of audio in memory to read + */ + bool HasNext(); + + /** + * Retrieves the next block of audio if its available + */ + std::vector<float> Next(); + }; +} // namespace asr
\ No newline at end of file |