Skip to content

Commit

Permalink
Change micro_speech example (#2249)
Browse files Browse the repository at this point in the history
@tensorflow/micro 

Create Python examples that use Signal Ops Library.
Create Python examples for micro_speech model prediction.
Update README documentation.
Update images.
Add additional speech sample files (silence, noise) to testdata directory.
Add audio preprocessing models to models  directory.
Update Bazel BUILD files.
Update Makefiles
Add micro_speech to project generation examples for bluepill
Disable micro_speech_test for Hexagon (b/302404477)

bug=fixes  #2248
  • Loading branch information
ddavis-2015 authored Oct 12, 2023
1 parent 778d6f8 commit d5a83db
Show file tree
Hide file tree
Showing 76 changed files with 1,665 additions and 6,038 deletions.
2 changes: 1 addition & 1 deletion python/tflite_micro/signal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ py_library(
"ops/__init__.py",
],
srcs_version = "PY3",
visibility = ["//python/tflite_micro/signal/utils:__subpackages__"],
visibility = ["//visibility:public"],
deps = [
":delay_op",
":energy_op",
Expand Down
2 changes: 2 additions & 0 deletions python/tflite_micro/signal/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pybind_extension(
py_library(
name = "util",
srcs = ["util.py"],
visibility = ["//visibility:public"],
deps = [
requirement("tensorflow-cpu"),
"//python/tflite_micro:runtime",
Expand Down Expand Up @@ -71,4 +72,5 @@ py_test(
"nomsan",
"noubsan",
],
visibility = ["//visibility:public"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ int16_t PcanGainLookupFunction(const float strength, const float offset,

py::list WideDynamicFuncLut(float strength, float offset, int input_bits,
int gain_bits) {
int16_t* gain_lut = new int16_t[kWideDynamicFunctionLUTSize];
int16_t gain_lut_storage[kWideDynamicFunctionLUTSize];
int16_t* gain_lut = gain_lut_storage;

gain_lut[0] =
PcanGainLookupFunction(strength, offset, gain_bits, input_bits, 0);
Expand All @@ -52,7 +53,7 @@ py::list WideDynamicFuncLut(float strength, float offset, int input_bits,
// loop below a lot simpler.
gain_lut -= 6;

for (int interval = 2; interval <= kWideDynamicFunctionBits; ++interval) {
for (size_t interval = 2; interval <= kWideDynamicFunctionBits; ++interval) {
const uint32_t x0 = static_cast<uint32_t>(1) << (interval - 1);
const uint32_t x1 = x0 + (x0 >> 1);
const uint32_t x2 =
Expand Down Expand Up @@ -80,10 +81,9 @@ py::list WideDynamicFuncLut(float strength, float offset, int input_bits,
gain_lut += 6;

py::list lut_list = py::list();
for (int i = 0; i < kWideDynamicFunctionLUTSize; i++) {
for (size_t i = 0; i < kWideDynamicFunctionLUTSize; i++) {
lut_list.append(gain_lut[i]);
}
free(gain_lut);

return lut_list;
}
Expand Down
Loading

0 comments on commit d5a83db

Please sign in to comment.