diff options
author | TensorFlower Gardener <gardener@tensorflow.org> | 2020-02-04 01:41:28 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2020-02-04 01:41:28 -0800 |
commit | 596588cfa1fc862f5585fb7676699b74572d70a8 (patch) | |
tree | 1809d8ede5b1d9e0b4cfffeafeaeaf2ac575ca66 | |
parent | b5586dc42f2797c5282eeb24be62ba0e955a04dc (diff) | |
parent | 7813cb00f35d6fc6d8ad8421021c1535f3e8c029 (diff) | |
download | tensorflow-596588cfa1fc862f5585fb7676699b74572d70a8.tar.gz |
Merge pull request #35125 from suphoff:micro_speech_buffer
PiperOrigin-RevId: 293098580
Change-Id: I10cf1bafb9b8ffe5a2c22ffde57aa0c7882753c1
-rw-r--r-- | tensorflow/lite/micro/examples/micro_speech/main_functions.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tensorflow/lite/micro/examples/micro_speech/main_functions.cc b/tensorflow/lite/micro/examples/micro_speech/main_functions.cc index 0db25999f97..9169e9a5db9 100644 --- a/tensorflow/lite/micro/examples/micro_speech/main_functions.cc +++ b/tensorflow/lite/micro/examples/micro_speech/main_functions.cc @@ -43,6 +43,8 @@ int32_t previous_time = 0; // determined by experimentation. constexpr int kTensorArenaSize = 10 * 1024; uint8_t tensor_arena[kTensorArenaSize]; +uint8_t feature_buffer[kFeatureElementCount]; +uint8_t* model_input_buffer = nullptr; } // namespace // The name of this function is important for Arduino compatibility. @@ -102,12 +104,13 @@ void setup() { error_reporter->Report("Bad input tensor parameters in model"); return; } + model_input_buffer = model_input->data.uint8; // Prepare to access the audio spectrograms from a microphone or other source // that will provide the inputs to the neural network. // NOLINTNEXTLINE(runtime-global-variables) static FeatureProvider static_feature_provider(kFeatureElementCount, - model_input->data.uint8); + feature_buffer); feature_provider = &static_feature_provider; static RecognizeCommands static_recognizer(error_reporter); @@ -134,6 +137,11 @@ void loop() { return; } + // Copy feature buffer to input tensor + for (int i = 0; i < kFeatureElementCount; i++) { + model_input_buffer[i] = feature_buffer[i]; + } + // Run the model on the spectrogram input and make sure it succeeds. TfLiteStatus invoke_status = interpreter->Invoke(); if (invoke_status != kTfLiteOk) { |