TinyTrainable
 
Loading...
Searching...
No Matches
feature_provider.h
Go to the documentation of this file.
1/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_FEATURE_PROVIDER_H_
17#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_FEATURE_PROVIDER_H_
18
19#include "tensorflow/lite/c/common.h"
20
21// Binds itself to an area of memory intended to hold the input features for an
22// audio-recognition neural network model, and fills that data area with the
23// features representing the current audio input, for example from a microphone.
24// The audio features themselves are a two-dimensional array, made up of
25// horizontal slices representing the frequencies at one point in time, stacked
26// on top of each other to form a spectrogram showing how those frequencies
27// changed over time.
29 public:
30 // Create the provider, and bind it to an area of memory. This memory should
31 // remain accessible for the lifetime of the provider object, since subsequent
32 // calls will fill it with feature data. The provider does no memory
33 // management of this data.
34 FeatureProvider(int feature_size, int8_t* feature_data);
36
37 // Fills the feature data with information from audio inputs, and returns how
38 // many feature slices were updated.
39 TfLiteStatus PopulateFeatureData(int32_t last_time_in_ms, int32_t time_in_ms,
40 int* how_many_new_slices);
41
42 private:
45 // Make sure we don't try to use cached information if this is the first call
46 // into the provider.
48};
49
50#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_FEATURE_PROVIDER_H_
Definition: feature_provider.h:28
TfLiteStatus PopulateFeatureData(int32_t last_time_in_ms, int32_t time_in_ms, int *how_many_new_slices)
Definition: feature_provider.cpp:35
int feature_size_
Definition: feature_provider.h:43
bool is_first_run_
Definition: feature_provider.h:47
int8_t * feature_data_
Definition: feature_provider.h:44
~FeatureProvider()
Definition: feature_provider.cpp:33