TinyTrainable
 
Loading...
Searching...
No Matches
audio_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_AUDIO_PROVIDER_H_
17#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_AUDIO_PROVIDER_H_
18
19#include "tensorflow/lite/c/common.h"
20
21// This is an abstraction around an audio source like a microphone, and is
22// expected to return 16-bit PCM sample data for a given point in time. The
23// sample data itself should be used as quickly as possible by the caller, since
24// to allow memory optimizations there are no guarantees that the samples won't
25// be overwritten by new data in the future. In practice, implementations should
26// ensure that there's a reasonable time allowed for clients to access the data
27// before any reuse.
28// The reference implementation can have no platform-specific dependencies, so
29// it just returns an array filled with zeros. For real applications, you should
30// ensure there's a specialized implementation that accesses hardware APIs.
31TfLiteStatus GetAudioSamples(int start_ms, int duration_ms,
32 int* audio_samples_size, int16_t** audio_samples);
33
34// Returns the time that audio data was last captured in milliseconds. There's
35// no contract about what time zero represents, the accuracy, or the granularity
36// of the result. Subsequent calls will generally not return a lower value, but
37// even that's not guaranteed if there's an overflow wraparound.
38// The reference implementation of this function just returns a constantly
39// incrementing value for each call, since it would need a non-portable platform
40// call to access time information. For real applications, you'll need to write
41// your own platform-specific implementation.
42int32_t LatestAudioTimestamp();
43
44// Starts audio capture
45TfLiteStatus InitAudioRecording();
46
47#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_AUDIO_PROVIDER_H_
TfLiteStatus InitAudioRecording()
Definition: arduino_audio_provider.cpp:75
TfLiteStatus GetAudioSamples(int start_ms, int duration_ms, int *audio_samples_size, int16_t **audio_samples)
Definition: arduino_audio_provider.cpp:92
int32_t LatestAudioTimestamp()
Definition: arduino_audio_provider.cpp:169