• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2018 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_SIMPLE_FEATURES_SIMPLE_MODEL_SETTINGS_H_
17 #define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_SIMPLE_FEATURES_SIMPLE_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 // All of these values are derived from the values used during model training,
29 // if you change your model you'll need to update these constants.
30 constexpr int kAverageWindowSize = 6;
31 constexpr int kFeatureSliceSize =
32     ((kMaxAudioSampleSize / 2) + (kAverageWindowSize - 1)) / kAverageWindowSize;
33 constexpr int kFeatureSliceCount = 49;
34 constexpr int kFeatureElementCount = (kFeatureSliceSize * kFeatureSliceCount);
35 constexpr int kFeatureSliceStrideMs = 20;
36 constexpr int kFeatureSliceDurationMs = 30;
37 
38 constexpr int kCategoryCount = 4;
39 constexpr int kSilenceIndex = 0;
40 constexpr int kUnknownIndex = 1;
41 extern const char* kCategoryLabels[kCategoryCount];
42 
43 #endif  // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_SIMPLE_FEATURES_SIMPLE_MODEL_SETTINGS_H_
44