Skip to content

Commit ee0f04f

Browse files
committed
2 parents c1542ba + 6b2aca1 commit ee0f04f

File tree

2 files changed

+17
-32
lines changed

2 files changed

+17
-32
lines changed

src/AudioTools/AudioLibs/TfLiteAudioStream.h

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Configure FFT to output 16 bit fixed point.
44
#define FIXED_POINT 16
55

6+
//#include <MicroTFLite.h>
67
#include <TensorFlowLite.h>
78
#include <cmath>
89
#include <cstdint>
@@ -13,7 +14,6 @@
1314
#include "tensorflow/lite/experimental/microfrontend/lib/frontend_util.h"
1415
#include "tensorflow/lite/micro/all_ops_resolver.h"
1516
#include "tensorflow/lite/micro/kernels/micro_ops.h"
16-
#include "tensorflow/lite/micro/micro_error_reporter.h"
1717
#include "tensorflow/lite/micro/micro_interpreter.h"
1818
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
1919
#include "tensorflow/lite/micro/system_setup.h"
@@ -55,25 +55,6 @@ class TfLiteWriter {
5555
virtual bool begin(TfLiteAudioStreamBase *parent) = 0;
5656
virtual bool write(const int16_t sample) = 0;
5757
};
58-
/**
59-
* @brief Error Reporter using the Audio Tools Logger
60-
* @ingroup tflite
61-
* @author Phil Schatzmann
62-
* @copyright GPLv3
63-
*/
64-
class TfLiteAudioErrorReporter : public tflite::ErrorReporter {
65-
public:
66-
virtual ~TfLiteAudioErrorReporter() {}
67-
virtual int Report(const char* format, va_list args) override {
68-
int result = snprintf(msg, 200, format, args);
69-
LOGE(msg);
70-
return result;
71-
}
72-
73-
protected:
74-
char msg[200];
75-
} my_error_reporter;
76-
tflite::ErrorReporter* error_reporter = &my_error_reporter;
7758

7859
/**
7960
* @brief Configuration settings for TfLiteAudioStream
@@ -96,7 +77,7 @@ struct TfLiteConfig {
9677
// Create an area of memory to use for input, output, and intermediate arrays.
9778
// The size of this will depend on the model you’re using, and may need to be
9879
// determined by experimentation.
99-
int kTensorArenaSize = 10 * 1024;
80+
size_t kTensorArenaSize = 10 * 1024;
10081

10182
// Keeping these as constant expressions allow us to allocate fixed-sized
10283
// arrays on the stack for our working memory.
@@ -980,14 +961,12 @@ class TfLiteAudioStream : public TfLiteAudioStreamBase {
980961
TRACEI();
981962
if (cfg.useAllOpsResolver) {
982963
tflite::AllOpsResolver resolver;
983-
static tflite::MicroInterpreter static_interpreter(
984-
p_model, resolver, p_tensor_arena, cfg.kTensorArenaSize,
985-
error_reporter);
964+
static tflite::MicroInterpreter static_interpreter{
965+
p_model, resolver, p_tensor_arena, cfg.kTensorArenaSize};
986966
p_interpreter = &static_interpreter;
987967
} else {
988968
// NOLINTNEXTLINE(runtime-global-variables)
989-
static tflite::MicroMutableOpResolver<4> micro_op_resolver(
990-
error_reporter);
969+
static tflite::MicroMutableOpResolver<4> micro_op_resolver{};
991970
if (micro_op_resolver.AddDepthwiseConv2D() != kTfLiteOk) {
992971
return false;
993972
}
@@ -1001,9 +980,8 @@ class TfLiteAudioStream : public TfLiteAudioStreamBase {
1001980
return false;
1002981
}
1003982
// Build an p_interpreter to run the model with.
1004-
static tflite::MicroInterpreter static_interpreter(
1005-
p_model, micro_op_resolver, p_tensor_arena, cfg.kTensorArenaSize,
1006-
error_reporter);
983+
static tflite::MicroInterpreter static_interpreter{
984+
p_model, micro_op_resolver, p_tensor_arena, cfg.kTensorArenaSize};
1007985
p_interpreter = &static_interpreter;
1008986
}
1009987
}

src/AudioTools/CoreAudio/AudioHttp/URLStream.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ class URLStream : public AbstractURLStream {
9696
total_read = 0;
9797
active = result == 200;
9898
LOGI("==> http status: %d", result);
99+
#if USE_AUDIO_LOGGING
99100
custom_log_level.reset();
100-
101+
#endif
101102
return active;
102103
}
103104

@@ -121,8 +122,9 @@ class URLStream : public AbstractURLStream {
121122
total_read = 0;
122123
active = result == 200;
123124
LOGI("==> http status: %d", result);
125+
#if USE_AUDIO_LOGGING
124126
custom_log_level.reset();
125-
127+
#endif
126128
return active;
127129
}
128130

@@ -247,14 +249,17 @@ class URLStream : public AbstractURLStream {
247249
return request.available() > 0;
248250
}
249251

252+
#if USE_AUDIO_LOGGING
250253
/// Defines the class specific custom log level
251254
void setLogLevel(AudioLogger::LogLevel level) { custom_log_level.set(level); }
252-
255+
#endif
253256
const char* urlStr() { return url_str.c_str(); }
254257

255258
protected:
256259
HttpRequest request;
260+
#if USE_AUDIO_LOGGING
257261
CustomLogLevel custom_log_level;
262+
#endif
258263
Str url_str;
259264
Url url;
260265
long size;
@@ -282,7 +287,9 @@ class URLStream : public AbstractURLStream {
282287

283288
bool preProcess(const char* urlStr, const char* acceptMime) {
284289
TRACED();
290+
#if USE_AUDIO_LOGGING
285291
custom_log_level.set();
292+
#endif
286293
url_str = urlStr;
287294
url.setUrl(url_str.c_str());
288295
int result = -1;

0 commit comments

Comments
 (0)