1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MICRO_MODEL_SETTINGS_H_
17 #define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MICRO_MODEL_SETTINGS_H_
18 
19 // Keeping these as constant expressions allow us to allocate fixed-sized arrays
20 // on the stack for our working memory.
21 
22 // The size of the input time series data we pass to the FFT to produce the
23 // frequency information. This has to be a power of two, and since we're dealing
24 // with 30ms of 16KHz inputs, which means 480 samples, this is the next value.
25 constexpr int kMaxAudioSampleSize = 512;
26 constexpr int kAudioSampleFrequency = 16000;
27 
28 // The following values are derived from values used during model training.
29 // If you change the way you preprocess the input, update all these constants.
30 constexpr int kFeatureSliceSize = 40;
31 constexpr int kFeatureSliceCount = 49;
32 constexpr int kFeatureElementCount = (kFeatureSliceSize * kFeatureSliceCount);
33 constexpr int kFeatureSliceStrideMs = 20;
34 constexpr int kFeatureSliceDurationMs = 30;
35 
36 // Variables for the model's output categories.
37 constexpr int kSilenceIndex = 0;
38 constexpr int kUnknownIndex = 1;
39 // If you modify the output categories, you need to update the following values.
40 constexpr int kCategoryCount = 4;
41 extern const char* kCategoryLabels[kCategoryCount];
42 
43 #endif  // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MICRO_MODEL_SETTINGS_H_
44