Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
码匠许师傅
Tflite Micro
提交
67681479
T
Tflite Micro
项目概览
码匠许师傅
/
Tflite Micro
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tflite Micro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
67681479
编写于
8月 27, 2021
作者:
N
Nat Jeffries
提交者:
GitHub
8月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generate cc and header files for micro_speech. (#429)
上级
1ae8bec3
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
178 addition
and
5263 deletion
+178
-5263
.github/workflows/ci.yml
.github/workflows/ci.yml
+4
-0
.github/workflows/cortex_m.yml
.github/workflows/cortex_m.yml
+2
-0
.github/workflows/riscv.yml
.github/workflows/riscv.yml
+1
-0
.github/workflows/size_check.yml
.github/workflows/size_check.yml
+1
-0
ci/Dockerfile.micro
ci/Dockerfile.micro
+1
-0
tensorflow/lite/micro/examples/micro_speech/.gitignore
tensorflow/lite/micro/examples/micro_speech/.gitignore
+0
-1
tensorflow/lite/micro/examples/micro_speech/BUILD
tensorflow/lite/micro/examples/micro_speech/BUILD
+76
-14
tensorflow/lite/micro/examples/micro_speech/Makefile.inc
tensorflow/lite/micro/examples/micro_speech/Makefile.inc
+32
-33
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock.cc
...w/lite/micro/examples/micro_speech/audio_provider_mock.cc
+4
-4
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock_test.cc
...e/micro/examples/micro_speech/audio_provider_mock_test.cc
+5
-6
tensorflow/lite/micro/examples/micro_speech/main_functions.cc
...orflow/lite/micro/examples/micro_speech/main_functions.cc
+2
-2
tensorflow/lite/micro/examples/micro_speech/micro_features/BUILD
...low/lite/micro/examples/micro_speech/micro_features/BUILD
+0
-10
tensorflow/lite/micro/examples/micro_speech/micro_features/micro_features_generator_test.cc
...ro_speech/micro_features/micro_features_generator_test.cc
+5
-6
tensorflow/lite/micro/examples/micro_speech/micro_features/model.cc
.../lite/micro/examples/micro_speech/micro_features/model.cc
+0
-1596
tensorflow/lite/micro/examples/micro_speech/micro_features/model.h
...w/lite/micro/examples/micro_speech/micro_features/model.h
+0
-27
tensorflow/lite/micro/examples/micro_speech/micro_speech.tflite
...flow/lite/micro/examples/micro_speech/micro_speech.tflite
+0
-0
tensorflow/lite/micro/examples/micro_speech/micro_speech_test.cc
...low/lite/micro/examples/micro_speech/micro_speech_test.cc
+2
-2
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.cc
...lite/micro/examples/micro_speech/no_1000ms_sample_data.cc
+0
-1477
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.h
.../lite/micro/examples/micro_speech/no_1000ms_sample_data.h
+0
-29
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.cc
...w/lite/micro/examples/micro_speech/no_30ms_sample_data.cc
+0
-66
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.h
...ow/lite/micro/examples/micro_speech/no_30ms_sample_data.h
+0
-32
tensorflow/lite/micro/examples/micro_speech/simple_features/simple_features_generator_test.cc
..._speech/simple_features/simple_features_generator_test.cc
+5
-6
tensorflow/lite/micro/examples/micro_speech/testdata/no_1000ms.wav
...w/lite/micro/examples/micro_speech/testdata/no_1000ms.wav
+0
-0
tensorflow/lite/micro/examples/micro_speech/testdata/no_30ms.wav
...low/lite/micro/examples/micro_speech/testdata/no_30ms.wav
+0
-0
tensorflow/lite/micro/examples/micro_speech/testdata/yes_1000ms.wav
.../lite/micro/examples/micro_speech/testdata/yes_1000ms.wav
+0
-0
tensorflow/lite/micro/examples/micro_speech/testdata/yes_30ms.wav
...ow/lite/micro/examples/micro_speech/testdata/yes_30ms.wav
+0
-0
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.cc
...ite/micro/examples/micro_speech/yes_1000ms_sample_data.cc
+0
-1800
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.h
...lite/micro/examples/micro_speech/yes_1000ms_sample_data.h
+0
-29
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.cc
.../lite/micro/examples/micro_speech/yes_30ms_sample_data.cc
+0
-70
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.h
...w/lite/micro/examples/micro_speech/yes_30ms_sample_data.h
+0
-32
tensorflow/lite/micro/tools/ci_build/test_code_style.sh
tensorflow/lite/micro/tools/ci_build/test_code_style.sh
+1
-0
tensorflow/lite/micro/tools/ci_build/test_esp32.sh
tensorflow/lite/micro/tools/ci_build/test_esp32.sh
+1
-0
tensorflow/lite/micro/tools/generate_cc_arrays.py
tensorflow/lite/micro/tools/generate_cc_arrays.py
+36
-21
未找到文件。
.github/workflows/ci.yml
浏览文件 @
67681479
...
...
@@ -38,6 +38,7 @@ jobs:
run
:
|
sudo ci/install_bazel.sh
pip3 install Pillow
pip3 install Wave
-
name
:
Test
run
:
|
tensorflow/lite/micro/tools/ci_build/test_bazel.sh
...
...
@@ -56,6 +57,7 @@ jobs:
-
name
:
Install dependencies
run
:
|
pip3 install Pillow
pip3 install Wave
-
name
:
Test
run
:
|
tensorflow/lite/micro/tools/ci_build/test_bluepill.sh
...
...
@@ -91,6 +93,7 @@ jobs:
-
name
:
Install dependencies
run
:
|
pip3 install Pillow
pip3 install Wave
-
name
:
Test
run
:
|
tensorflow/lite/micro/tools/ci_build/test_project_generation.sh
...
...
@@ -109,6 +112,7 @@ jobs:
-
name
:
Install dependencies
run
:
|
pip3 install Pillow
pip3 install Wave
-
name
:
Test
run
:
|
tensorflow/lite/micro/tools/ci_build/test_makefile.sh
...
...
.github/workflows/cortex_m.yml
浏览文件 @
67681479
...
...
@@ -28,6 +28,7 @@ jobs:
-
name
:
Install dependencies
run
:
|
pip3 install Pillow
pip3 install Wave
-
name
:
Test
run
:
|
tensorflow/lite/micro/tools/ci_build/test_cortex_m_generic.sh
...
...
@@ -45,6 +46,7 @@ jobs:
-
name
:
Install dependencies
run
:
|
pip3 install Pillow
pip3 install Wave
-
name
:
Test
run
:
|
tensorflow/lite/micro/tools/ci_build/test_cortex_m_corstone_300.sh
.github/workflows/riscv.yml
浏览文件 @
67681479
...
...
@@ -24,6 +24,7 @@ jobs:
-
name
:
Install dependencies
run
:
|
pip3 install Pillow
pip3 install Wave
-
name
:
Test
run
:
|
tensorflow/lite/micro/tools/ci_build/test_riscv.sh
.github/workflows/size_check.yml
浏览文件 @
67681479
...
...
@@ -29,6 +29,7 @@ jobs:
-
name
:
Install dependencies
run
:
|
pip3 install Pillow
pip3 install Wave
# If PR has MEM_CHANGE_OK tag, then does not error out on memory footprint
# increase and simply produce a report for reviewer to check.
...
...
ci/Dockerfile.micro
浏览文件 @
67681479
...
...
@@ -36,6 +36,7 @@ RUN pip install yapf
# https://github.com/tensorflow/tflite-micro/pull/337
# https://github.com/tensorflow/tflite-micro/pull/410
RUN pip install Pillow
RUN pip install Wave
RUN pip install six
...
...
tensorflow/lite/micro/examples/micro_speech/.gitignore
已删除
100644 → 0
浏览文件 @
1ae8bec3
*.wav
tensorflow/lite/micro/examples/micro_speech/BUILD
浏览文件 @
67681479
# Description:
# TensorFlow Lite microcontroller example.
load
(
"//tensorflow/lite/micro:build_def.bzl"
,
"generate_cc_arrays"
)
package
(
default_visibility
=
[
"//visibility:public"
],
# Disabling layering_check because of http://b/177257332
...
...
@@ -17,13 +19,73 @@ cc_library(
],
)
generate_cc_arrays
(
name
=
"generated_yes_1000ms_wav_cc"
,
src
=
"testdata/yes_1000ms.wav"
,
out
=
"testdata/yes_1000ms_audio_data.cc"
,
)
generate_cc_arrays
(
name
=
"generated_yes_1000ms_wav_hdr"
,
src
=
"testdata/yes_1000ms.wav"
,
out
=
"testdata/yes_1000ms_audio_data.h"
,
)
generate_cc_arrays
(
name
=
"generated_no_1000ms_wav_cc"
,
src
=
"testdata/no_1000ms.wav"
,
out
=
"testdata/no_1000ms_audio_data.cc"
,
)
generate_cc_arrays
(
name
=
"generated_no_1000ms_wav_hdr"
,
src
=
"testdata/no_1000ms.wav"
,
out
=
"testdata/no_1000ms_audio_data.h"
,
)
generate_cc_arrays
(
name
=
"generated_yes_30ms_wav_cc"
,
src
=
"testdata/yes_30ms.wav"
,
out
=
"testdata/yes_30ms_audio_data.cc"
,
)
generate_cc_arrays
(
name
=
"generated_yes_30ms_wav_hdr"
,
src
=
"testdata/yes_30ms.wav"
,
out
=
"testdata/yes_30ms_audio_data.h"
,
)
generate_cc_arrays
(
name
=
"generated_no_30ms_wav_cc"
,
src
=
"testdata/no_30ms.wav"
,
out
=
"testdata/no_30ms_audio_data.cc"
,
)
generate_cc_arrays
(
name
=
"generated_no_30ms_wav_hdr"
,
src
=
"testdata/no_30ms.wav"
,
out
=
"testdata/no_30ms_audio_data.h"
,
)
generate_cc_arrays
(
name
=
"generated_micro_speech_model_cc"
,
src
=
"micro_speech.tflite"
,
out
=
"micro_speech_model_data.cc"
,
)
generate_cc_arrays
(
name
=
"generated_micro_speech_model_hdr"
,
src
=
"micro_speech.tflite"
,
out
=
"micro_speech_model_data.h"
,
)
cc_library
(
name
=
"m
odel
"
,
name
=
"m
icro_speech_model_data
"
,
srcs
=
[
"
simple_features/model.
cc"
,
"
:generated_micro_speech_model_
cc"
,
],
hdrs
=
[
"
simple_features/model.h
"
,
"
:generated_micro_speech_model_hdr
"
,
],
)
...
...
@@ -45,11 +107,11 @@ cc_test(
"micro_speech_test.cc"
,
],
deps
=
[
":micro_speech_model_data"
,
"//tensorflow/lite/micro:micro_error_reporter"
,
"//tensorflow/lite/micro:micro_framework"
,
"//tensorflow/lite/micro:op_resolvers"
,
"//tensorflow/lite/micro/examples/micro_speech/micro_features:micro_features_test_data"
,
"//tensorflow/lite/micro/examples/micro_speech/micro_features:model"
,
"//tensorflow/lite/micro/testing:micro_test"
,
"//tensorflow/lite/schema:schema_fbs"
,
],
...
...
@@ -58,24 +120,24 @@ cc_test(
cc_library
(
name
=
"audio_sample_test_data"
,
srcs
=
[
"
no_30ms_sample_data.
cc"
,
"
yes_30ms_sample_data.
cc"
,
"
:generated_yes_30ms_wav_
cc"
,
"
:generated_no_30ms_wav_
cc"
,
],
hdrs
=
[
"
no_30ms_sample_data.h
"
,
"
yes_30ms_sample_data.h
"
,
"
:generated_yes_30ms_wav_hdr
"
,
"
:generated_no_30ms_wav_hdr
"
,
],
)
cc_library
(
name
=
"audio_large_sample_test_data"
,
srcs
=
[
"
no_1000ms_sample_data.
cc"
,
"
yes_1000ms_sample_data.
cc"
,
"
:generated_yes_1000ms_wav_
cc"
,
"
:generated_no_1000ms_wav_
cc"
,
],
hdrs
=
[
"
no_1000ms_sample_data.h
"
,
"
yes_1000ms_sample_data.h
"
,
"
:generated_yes_1000ms_wav_hdr
"
,
"
:generated_no_1000ms_wav_hdr
"
,
],
)
...
...
@@ -359,13 +421,13 @@ cc_binary(
":audio_provider"
,
":command_responder"
,
":feature_provider"
,
":micro_speech_model_data"
,
":recognize_commands"
,
"//tensorflow/lite/micro:micro_error_reporter"
,
"//tensorflow/lite/micro:micro_framework"
,
"//tensorflow/lite/micro:op_resolvers"
,
"//tensorflow/lite/micro:system_setup"
,
"//tensorflow/lite/micro/examples/micro_speech/micro_features:micro_model_settings"
,
"//tensorflow/lite/micro/examples/micro_speech/micro_features:model"
,
"//tensorflow/lite/schema:schema_fbs"
,
],
)
...
...
@@ -378,6 +440,7 @@ cc_binary(
"main_functions.h"
,
],
deps
=
[
":micro_speech_model_data"
,
":audio_provider_mock"
,
":command_responder"
,
":feature_provider"
,
...
...
@@ -387,7 +450,6 @@ cc_binary(
"//tensorflow/lite/micro:op_resolvers"
,
"//tensorflow/lite/micro:system_setup"
,
"//tensorflow/lite/micro/examples/micro_speech/micro_features:micro_model_settings"
,
"//tensorflow/lite/micro/examples/micro_speech/micro_features:model"
,
"//tensorflow/lite/schema:schema_fbs"
,
],
)
...
...
tensorflow/lite/micro/examples/micro_speech/Makefile.inc
浏览文件 @
67681479
...
...
@@ -28,28 +28,22 @@ third_party/kissfft/tools/kiss_fftr.h
MICRO_SPEECH_TEST_SRCS
:=
\
tensorflow/lite/micro/examples/micro_speech/micro_speech_test.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/model.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.cc
MICRO_SPEECH_TEST_HDRS
:=
\
tensorflow/lite/micro/examples/micro_speech/micro_features/model.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.h
\
SIMPLE_FEATURES_GENERATOR_TEST_SRCS
:=
\
tensorflow/lite/micro/examples/micro_speech/simple_features/simple_features_generator.cc
\
tensorflow/lite/micro/examples/micro_speech/simple_features/simple_features_generator_test.cc
\
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/simple_features/no_power_spectrum_data.cc
\
tensorflow/lite/micro/examples/micro_speech/simple_features/yes_power_spectrum_data.cc
SIMPLE_FEATURES_GENERATOR_TEST_HDRS
:=
\
tensorflow/lite/micro/examples/micro_speech/simple_features/simple_model_settings.h
\
tensorflow/lite/micro/examples/micro_speech/simple_features/simple_features_generator.h
\
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/simple_features/no_power_spectrum_data.h
\
tensorflow/lite/micro/examples/micro_speech/simple_features/yes_power_spectrum_data.h
...
...
@@ -104,15 +98,11 @@ MICRO_FEATURES_GENERATOR_TEST_SRCS := \
tensorflow/lite/micro/examples/micro_speech/micro_features/micro_features_generator_test.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_feature_data_slice.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_feature_data_slice.cc
\
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.cc
\
$(MICRO_FEATURES_GENERATOR_SRCS)
MICRO_FEATURES_GENERATOR_TEST_HDRS
:=
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_feature_data_slice.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_feature_data_slice.h
\
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.h
\
$(MICRO_FEATURES_GENERATOR_HDRS)
AUDIO_PROVIDER_TEST_SRCS
:=
\
...
...
@@ -127,14 +117,10 @@ tensorflow/lite/micro/examples/micro_speech/audio_provider.h \
AUDIO_PROVIDER_MOCK_TEST_SRCS
:=
\
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock_test.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.cc
\
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock.cc
AUDIO_PROVIDER_MOCK_TEST_HDRS
:=
\
tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h
\
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/audio_provider.h
\
FEATURE_PROVIDER_TEST_SRCS
:=
\
...
...
@@ -151,8 +137,6 @@ $(MICRO_FEATURES_GENERATOR_HDRS)
FEATURE_PROVIDER_MOCK_TEST_SRCS
:=
\
tensorflow/lite/micro/examples/micro_speech/feature_provider_test.cc
\
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock.cc
\
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/feature_provider.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.cc
\
...
...
@@ -160,8 +144,6 @@ $(MICRO_FEATURES_GENERATOR_SRCS)
FEATURE_PROVIDER_MOCK_TEST_HDRS
:=
\
tensorflow/lite/micro/examples/micro_speech/audio_provider.h
\
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/feature_provider.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.h
\
...
...
@@ -190,7 +172,6 @@ tensorflow/lite/micro/examples/micro_speech/audio_provider.cc \
tensorflow/lite/micro/examples/micro_speech/feature_provider.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/model.cc
\
tensorflow/lite/micro/examples/micro_speech/recognize_commands.cc
\
tensorflow/lite/micro/examples/micro_speech/command_responder.cc
\
$(MICRO_FEATURES_GENERATOR_SRCS)
...
...
@@ -200,7 +181,6 @@ tensorflow/lite/micro/examples/micro_speech/audio_provider.h \
tensorflow/lite/micro/examples/micro_speech/feature_provider.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/model.h
\
tensorflow/lite/micro/examples/micro_speech/recognize_commands.h
\
tensorflow/lite/micro/examples/micro_speech/command_responder.h
\
tensorflow/lite/micro/examples/micro_speech/main_functions.h
\
...
...
@@ -210,30 +190,45 @@ MICRO_SPEECH_MOCK_SRCS := \
tensorflow/lite/micro/examples/micro_speech/main.cc
\
tensorflow/lite/micro/examples/micro_speech/main_functions.cc
\
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock.cc
\
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.cc
\
tensorflow/lite/micro/examples/micro_speech/feature_provider.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.cc
\
tensorflow/lite/micro/examples/micro_speech/micro_features/model.cc
\
tensorflow/lite/micro/examples/micro_speech/recognize_commands.cc
\
tensorflow/lite/micro/examples/micro_speech/command_responder.cc
\
$(MICRO_FEATURES_GENERATOR_SRCS)
MICRO_SPEECH_MOCK_HDRS
:=
\
tensorflow/lite/micro/examples/micro_speech/audio_provider.h
\
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.h
\
tensorflow/lite/micro/examples/micro_speech/feature_provider.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/micro_features_generator.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.h
\
tensorflow/lite/micro/examples/micro_speech/micro_features/model.h
\
tensorflow/lite/micro/examples/micro_speech/recognize_commands.h
\
tensorflow/lite/micro/examples/micro_speech/command_responder.h
\
tensorflow/lite/micro/examples/micro_speech/main_functions.h
\
$(MICRO_FEATURES_GENERATOR_HDRS)
MICRO_SPEECH_GENERATOR_INPUTS
:=
\
tensorflow/lite/micro/examples/micro_speech/micro_speech.tflite
\
tensorflow/lite/micro/examples/micro_speech/testdata/no_1000ms.wav
\
tensorflow/lite/micro/examples/micro_speech/testdata/no_30ms.wav
\
tensorflow/lite/micro/examples/micro_speech/testdata/yes_1000ms.wav
\
tensorflow/lite/micro/examples/micro_speech/testdata/yes_30ms.wav
MICRO_SPEECH_GENERATED_SRCS
:=
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/micro_speech_model_data.cc
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/no_1000ms_audio_data.cc
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/no_30ms_audio_data.cc
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/yes_1000ms_audio_data.cc
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/yes_30ms_audio_data.cc
MICRO_SPEECH_GENERATED_HDRS
:=
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/micro_speech_model_data.h
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/no_1000ms_audio_data.h
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/no_30ms_audio_data.h
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/yes_1000ms_audio_data.h
\
$(GENERATED_SRCS_DIR)
tensorflow/lite/micro/examples/micro_speech/testdata/yes_30ms_audio_data.h
#Find any platform - specific rules for this example.
include
$(wildcard tensorflow/lite/micro/examples/micro_speech/*/Makefile.inc)
...
...
@@ -243,15 +238,15 @@ CCFLAGS := $(filter-out $(CC_WARNINGS),$(CCFLAGS))
# Test the code for feature generation.
$(eval
$(call
microlite_test,micro_features_generator_test,\
$(MICRO_FEATURES_GENERATOR_TEST_SRCS),
$(MICRO_FEATURES_GENERATOR_TEST_HDR
S)))
$(MICRO_FEATURES_GENERATOR_TEST_SRCS),
$(MICRO_FEATURES_GENERATOR_TEST_HDRS),$(MICRO_SPEECH_GENERATOR_INPUT
S)))
# Tests loading and running a speech model.
$(eval
$(call
microlite_test,micro_speech_test,\
$(MICRO_SPEECH_TEST_SRCS),$(MICRO_SPEECH_TEST_HDRS)))
$(MICRO_SPEECH_TEST_SRCS),$(MICRO_SPEECH_TEST_HDRS)
,$(MICRO_SPEECH_GENERATOR_INPUTS)
))
# Test the code for feature generation.
$(eval
$(call
microlite_test,simple_features_generator_test,\
$(SIMPLE_FEATURES_GENERATOR_TEST_SRCS),
$(SIMPLE_FEATURES_GENERATOR_TEST_HDR
S)))
$(SIMPLE_FEATURES_GENERATOR_TEST_SRCS),
$(SIMPLE_FEATURES_GENERATOR_TEST_HDRS),$(MICRO_SPEECH_GENERATOR_INPUT
S)))
# Tests the audio provider module.
$(eval
$(call
microlite_test,audio_provider_test,\
...
...
@@ -259,7 +254,7 @@ $(AUDIO_PROVIDER_TEST_SRCS),$(AUDIO_PROVIDER_TEST_HDRS)))
# Tests the audio provider mock module.
$(eval
$(call
microlite_test,audio_provider_mock_test,\
$(AUDIO_PROVIDER_MOCK_TEST_SRCS),$(AUDIO_PROVIDER_MOCK_TEST_HDRS)))
$(AUDIO_PROVIDER_MOCK_TEST_SRCS),$(AUDIO_PROVIDER_MOCK_TEST_HDRS)
,$(MICRO_SPEECH_GENERATOR_INPUTS)
))
# Tests the feature provider module.
$(eval
$(call
microlite_test,feature_provider_test,\
...
...
@@ -267,7 +262,7 @@ $(FEATURE_PROVIDER_TEST_SRCS),$(FEATURE_PROVIDER_TEST_HDRS)))
# Tests the feature provider module using the mock audio provider.
$(eval
$(call
microlite_test,feature_provider_mock_test,\
$(FEATURE_PROVIDER_MOCK_TEST_SRCS),$(FEATURE_PROVIDER_MOCK_TEST_HDRS)))
$(FEATURE_PROVIDER_MOCK_TEST_SRCS),$(FEATURE_PROVIDER_MOCK_TEST_HDRS)
,$(MICRO_SPEECH_GENERATOR_INPUTS)
))
# Tests the command recognizer module.
$(eval
$(call
microlite_test,recognize_commands_test,\
...
...
@@ -279,11 +274,15 @@ $(COMMAND_RESPONDER_TEST_SRCS),$(COMMAND_RESPONDER_TEST_HDRS)))
# Builds a standalone speech command recognizer binary.
$(eval
$(call
microlite_test,micro_speech,\
$(MICRO_SPEECH_SRCS),$(MICRO_SPEECH_HDRS)))
$(MICRO_SPEECH_SRCS),$(MICRO_SPEECH_HDRS)
,$(MICRO_SPEECH_GENERATOR_INPUTS)
))
# Builds a standalone speech command recognizer binary using fake audio input.
$(eval
$(call
microlite_test,micro_speech_mock,\
$(MICRO_SPEECH_MOCK_SRCS),$(MICRO_SPEECH_MOCK_HDRS)))
$(MICRO_SPEECH_MOCK_SRCS),$(MICRO_SPEECH_MOCK_HDRS),$(MICRO_SPEECH_GENERATOR_INPUTS)))
# Add sources and headers generated from $(MICRO_SPEECH_GENERATOR_INPUTS).
MICRO_SPEECH_SRCS
+=
$(MICRO_SPEECH_GENERATED_SRCS)
MICRO_SPEECH_HDRS
+=
$(MICRO_SPEECH_GENERATED_HDRS)
list_micro_speech_example_sources
:
@
echo
$(MICRO_SPEECH_SRCS)
...
...
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock.cc
浏览文件 @
67681479
...
...
@@ -15,8 +15,8 @@ limitations under the License.
#include "tensorflow/lite/micro/examples/micro_speech/audio_provider.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h"
#include "tensorflow/lite/micro/examples/micro_speech/
no_1000ms_sample
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
yes_1000ms_sample
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
testdata/no_1000ms_audio
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
testdata/yes_1000ms_audio
_data.h"
namespace
{
int16_t
g_dummy_audio_data
[
kMaxAudioSampleSize
];
...
...
@@ -36,9 +36,9 @@ TfLiteStatus GetAudioSamples(tflite::ErrorReporter* error_reporter,
const
int
sample_index
=
(
start_sample
+
i
)
%
wraparound
;
int16_t
sample
;
if
((
sample_index
>=
yes_start
)
&&
(
sample_index
<
yes_end
))
{
sample
=
g_yes_1000ms_
sample
_data
[
sample_index
-
yes_start
];
sample
=
g_yes_1000ms_
audio
_data
[
sample_index
-
yes_start
];
}
else
if
((
sample_index
>=
no_start
)
&&
(
sample_index
<
no_end
))
{
sample
=
g_no_1000ms_
sample
_data
[
sample_index
-
no_start
];
sample
=
g_no_1000ms_
audio
_data
[
sample_index
-
no_start
];
}
else
{
sample
=
0
;
}
...
...
tensorflow/lite/micro/examples/micro_speech/audio_provider_mock_test.cc
浏览文件 @
67681479
...
...
@@ -18,8 +18,8 @@ limitations under the License.
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/micro/examples/micro_speech/audio_provider.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h"
#include "tensorflow/lite/micro/examples/micro_speech/
no_1000ms_sample
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
yes_1000ms_sample
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
testdata/no_1000ms_audio
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
testdata/yes_1000ms_audio
_data.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/testing/micro_test.h"
...
...
@@ -37,7 +37,7 @@ TF_LITE_MICRO_TEST(TestAudioProviderMock) {
TF_LITE_MICRO_EXPECT_LE
(
audio_samples_size
,
kMaxAudioSampleSize
);
TF_LITE_MICRO_EXPECT_NE
(
audio_samples
,
nullptr
);
for
(
int
i
=
0
;
i
<
audio_samples_size
;
++
i
)
{
TF_LITE_MICRO_EXPECT_EQ
(
g_yes_1000ms_
sample
_data
[
i
],
audio_samples
[
i
]);
TF_LITE_MICRO_EXPECT_EQ
(
g_yes_1000ms_
audio
_data
[
i
],
audio_samples
[
i
]);
}
get_status
=
...
...
@@ -47,7 +47,7 @@ TF_LITE_MICRO_TEST(TestAudioProviderMock) {
TF_LITE_MICRO_EXPECT_LE
(
audio_samples_size
,
kMaxAudioSampleSize
);
TF_LITE_MICRO_EXPECT_NE
(
audio_samples
,
nullptr
);
for
(
int
i
=
0
;
i
<
audio_samples_size
;
++
i
)
{
TF_LITE_MICRO_EXPECT_EQ
(
g_yes_1000ms_
sample
_data
[
i
+
8000
],
TF_LITE_MICRO_EXPECT_EQ
(
g_yes_1000ms_
audio
_data
[
i
+
8000
],
audio_samples
[
i
]);
}
...
...
@@ -68,8 +68,7 @@ TF_LITE_MICRO_TEST(TestAudioProviderMock) {
TF_LITE_MICRO_EXPECT_LE
(
audio_samples_size
,
kMaxAudioSampleSize
);
TF_LITE_MICRO_EXPECT_NE
(
audio_samples
,
nullptr
);
for
(
int
i
=
0
;
i
<
audio_samples_size
;
++
i
)
{
TF_LITE_MICRO_EXPECT_EQ
(
g_no_1000ms_sample_data
[
i
+
4000
],
audio_samples
[
i
]);
TF_LITE_MICRO_EXPECT_EQ
(
g_no_1000ms_audio_data
[
i
+
4000
],
audio_samples
[
i
]);
}
}
...
...
tensorflow/lite/micro/examples/micro_speech/main_functions.cc
浏览文件 @
67681479
...
...
@@ -19,7 +19,7 @@ limitations under the License.
#include "tensorflow/lite/micro/examples/micro_speech/command_responder.h"
#include "tensorflow/lite/micro/examples/micro_speech/feature_provider.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_
features/model
.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_
speech_model_data
.h"
#include "tensorflow/lite/micro/examples/micro_speech/recognize_commands.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
...
...
@@ -58,7 +58,7 @@ void setup() {
// Map the model into a usable data structure. This doesn't involve any
// copying or parsing, it's a very lightweight operation.
model
=
tflite
::
GetModel
(
g_m
odel
);
model
=
tflite
::
GetModel
(
g_m
icro_speech_model_data
);
if
(
model
->
version
()
!=
TFLITE_SCHEMA_VERSION
)
{
TF_LITE_REPORT_ERROR
(
error_reporter
,
"Model provided is schema version %d not equal "
...
...
tensorflow/lite/micro/examples/micro_speech/micro_features/BUILD
浏览文件 @
67681479
...
...
@@ -16,16 +16,6 @@ cc_library(
],
)
cc_library
(
name
=
"model"
,
srcs
=
[
"model.cc"
,
],
hdrs
=
[
"model.h"
,
],
)
cc_library
(
name
=
"micro_features_test_data"
,
srcs
=
[
...
...
tensorflow/lite/micro/examples/micro_speech/micro_features/micro_features_generator_test.cc
浏览文件 @
67681479
...
...
@@ -18,8 +18,8 @@ limitations under the License.
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/no_feature_data_slice.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/yes_feature_data_slice.h"
#include "tensorflow/lite/micro/examples/micro_speech/
no_30ms_sample
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
yes_30ms_sample
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
testdata/no_30ms_audio
_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/
testdata/yes_30ms_audio
_data.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/testing/micro_test.h"
...
...
@@ -51,9 +51,8 @@ TF_LITE_MICRO_TEST(TestMicroFeaturesGeneratorYes) {
int8_t
yes_calculated_data
[
g_yes_feature_data_slice_size
];
size_t
num_samples_read
;
TfLiteStatus
yes_status
=
GenerateMicroFeatures
(
&
micro_error_reporter
,
g_yes_30ms_sample_data
,
g_yes_30ms_sample_data_size
,
g_yes_feature_data_slice_size
,
yes_calculated_data
,
&
num_samples_read
);
&
micro_error_reporter
,
g_yes_30ms_audio_data
,
g_yes_30ms_audio_data_size
,
g_yes_feature_data_slice_size
,
yes_calculated_data
,
&
num_samples_read
);
TF_LITE_MICRO_EXPECT_EQ
(
kTfLiteOk
,
yes_status
);
for
(
int
i
=
0
;
i
<
g_yes_feature_data_slice_size
;
++
i
)
{
...
...
@@ -86,7 +85,7 @@ TF_LITE_MICRO_TEST(TestMicroFeaturesGeneratorNo) {
int8_t
no_calculated_data
[
g_no_feature_data_slice_size
];
size_t
num_samples_read
;
TfLiteStatus
no_status
=
GenerateMicroFeatures
(
&
micro_error_reporter
,
g_no_30ms_
sample_data
,
g_no_30ms_sample
_data_size
,
&
micro_error_reporter
,
g_no_30ms_
audio_data
,
g_no_30ms_audio
_data_size
,
g_no_feature_data_slice_size
,
no_calculated_data
,
&
num_samples_read
);
TF_LITE_MICRO_EXPECT_EQ
(
kTfLiteOk
,
no_status
);
...
...
tensorflow/lite/micro/examples/micro_speech/micro_features/model.cc
已删除
100644 → 0
浏览文件 @
1ae8bec3
此差异已折叠。
点击以展开。
tensorflow/lite/micro/examples/micro_speech/micro_features/model.h
已删除
100644 → 0
浏览文件 @
1ae8bec3
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This is a standard TensorFlow Lite FlatBuffer model file that has been
// converted into a C data array, so it can be easily compiled into a binary
// for devices that don't have a file system. It was created using the command:
// xxd -i model.tflite > model.cc
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MODEL_H_
#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MODEL_H_
extern
const
unsigned
char
g_model
[];
extern
const
int
g_model_len
;
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_MODEL_H_
tensorflow/lite/micro/examples/micro_speech/micro_speech.tflite
0 → 100644
浏览文件 @
67681479
文件已添加
tensorflow/lite/micro/examples/micro_speech/micro_speech_test.cc
浏览文件 @
67681479
...
...
@@ -13,9 +13,9 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/model.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/micro_speech_model_data.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
...
...
@@ -30,7 +30,7 @@ TF_LITE_MICRO_TEST(TestInvoke) {
// Map the model into a usable data structure. This doesn't involve any
// copying or parsing, it's a very lightweight operation.
const
tflite
::
Model
*
model
=
::
tflite
::
GetModel
(
g_m
odel
);
const
tflite
::
Model
*
model
=
::
tflite
::
GetModel
(
g_m
icro_speech_model_data
);
if
(
model
->
version
()
!=
TFLITE_SCHEMA_VERSION
)
{
TF_LITE_REPORT_ERROR
(
&
micro_error_reporter
,
"Model provided is schema version %d not equal "
...
...
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.cc
已删除
100644 → 0
浏览文件 @
1ae8bec3
此差异已折叠。
点击以展开。
tensorflow/lite/micro/examples/micro_speech/no_1000ms_sample_data.h
已删除
100644 → 0
浏览文件 @
1ae8bec3
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This data was created from the PCM data in a WAV file held in v2 of the
// Speech Commands test dataset, at the path:
// speech_commands_test_set_v0.02/no/f9643d42_nohash_4.wav
// This should contain all 16,000 samples from the one-second file.
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_NO_1000MS_SAMPLE_DATA_H_
#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_NO_1000MS_SAMPLE_DATA_H_
#include <cstdint>
extern
const
int
g_no_1000ms_sample_data_size
;
extern
const
int16_t
g_no_1000ms_sample_data
[];
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_NO_1000MS_SAMPLE_DATA_H_
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.cc
已删除
100644 → 0
浏览文件 @
1ae8bec3
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// See the header for documentation on the meaning of this data.
#include "tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.h"
const
int
g_no_30ms_sample_data_size
=
480
;
const
int16_t
g_no_30ms_sample_data
[
480
]
=
{
5713
,
5735
,
5735
,
5737
,
5701
,
5691
,
5656
,
5633
,
5611
,
5552
,
5475
,
5394
,
5293
,
5177
,
5064
,
4924
,
4737
,
4599
,
4420
,
4237
,
4048
,
3828
,
3623
,
3413
,
3183
,
2915
,
2622
,
2308
,
1980
,
1657
,
1261
,
901
,
549
,
205
,
-
85
,
-
383
,
-
688
,
-
969
,
-
1246
,
-
1530
,
-
1850
,
-
2206
,
-
2561
,
-
2915
,
-
3224
,
-
3482
,
-
3713
,
-
3921
,
-
4107
,
-
4287
,
-
4470
,
-
4660
,
-
4850
,
-
5057
,
-
5239
,
-
5395
,
-
5540
,
-
5619
,
-
5697
,
-
5724
,
-
5697
,
-
5675
,
-
5633
,
-
5590
,
-
5579
,
-
5530
,
-
5486
,
-
5442
,
-
5426
,
-
5391
,
-
5348
,
-
5276
,
-
5197
,
-
5124
,
-
5039
,
-
4925
,
-
4808
,
-
4677
,
-
4581
,
-
4479
,
-
4343
,
-
4218
,
-
4087
,
-
3970
,
-
3858
,
-
3729
,
-
3570
,
-
3384
,
-
3206
,
-
3020
,
-
2839
,
-
2636
,
-
2453
,
-
2287
,
-
2185
,
-
2154
,
-
1926
,
-
1562
,
-
1223
,
-
758
,
-
473
,
-
64
,
395
,
599
,
880
,
814
,
938
,
1172
,
1498
,
1928
,
2127
,
2422
,
2608
,
2841
,
2937
,
2886
,
2815
,
2985
,
3324
,
3757
,
4152
,
4481
,
4652
,
4917
,
4965
,
4766
,
4583
,
4328
,
4503
,
4815
,
5118
,
5408
,
5682
,
5956
,
6082
,
6055
,
5744
,
5426
,
5341
,
5427
,
5606
,
5882
,
6065
,
6226
,
6428
,
6477
,
6385
,
6009
,
5728
,
5552
,
5439
,
5339
,
5200
,
5008
,
4947
,
4835
,
4614
,
4330
,
3887
,
3521
,
3111
,
2460
,
1983
,
1297
,
650
,
279
,
-
353
,
-
720
,
-
1044
,
-
1518
,
-
1668
,
-
2117
,
-
2496
,
-
2743
,
-
3266
,
-
3607
,
-
3790
,
-
4149
,
-
4075
,
-
4042
,
-
4096
,
-
3981
,
-
4138
,
-
4226
,
-
4214
,
-
4503
,
-
4455
,
-
4577
,
-
4642
,
-
4346
,
-
4351
,
-
4270
,
-
4263
,
-
4522
,
-
4521
,
-
4673
,
-
4814
,
-
4731
,
-
4950
,
-
5011
,
-
5004
,
-
5288
,
-
5341
,
-
5566
,
-
5833
,
-
5783
,
-
5929
,
-
5847
,
-
5765
,
-
5828
,
-
5644
,
-
5613
,
-
5615
,
-
5428
,
-
5291
,
-
5014
,
-
4554
,
-
4277
,
-
3964
,
-
3854
,
-
3829
,
-
3612
,
-
3603
,
-
3438
,
-
3137
,
-
2831
,
-
2164
,
-
1438
,
-
939
,
-
330
,
-
156
,
46
,
242
,
73
,
242
,
220
,
239
,
542
,
565
,
739
,
872
,
801
,
857
,
676
,
543
,
586
,
567
,
828
,
1142
,
1490
,
1985
,
2508
,
2982
,
3438
,
3699
,
3939
,
4069
,
4178
,
4420
,
4622
,
4917
,
5338
,
5801
,
6285
,
6658
,
6963
,
7213
,
7233
,
7328
,
7176
,
7038
,
7031
,
6860
,
6957
,
6767
,
6599
,
6523
,
6212
,
6147
,
6063
,
5860
,
6020
,
6015
,
6033
,
6184
,
5722
,
5607
,
5016
,
4337
,
4063
,
3229
,
3080
,
3006
,
2804
,
3035
,
2541
,
2136
,
1879
,
1012
,
401
,
-
575
,
-
1584
,
-
1930
,
-
2278
,
-
2485
,
-
2477
,
-
2712
,
-
2747
,
-
2766
,
-
3320
,
-
3592
,
-
4188
,
-
4669
,
-
4672
,
-
4939
,
-
4789
,
-
4426
,
-
4203
,
-
3674
,
-
3563
,
-
3656
,
-
3759
,
-
4067
,
-
4257
,
-
4522
,
-
4970
,
-
5204
,
-
5237
,
-
5139
,
-
4907
,
-
4911
,
-
4917
,
-
4921
,
-
5007
,
-
5230
,
-
5654
,
-
6122
,
-
6464
,
-
6733
,
-
6948
,
-
7067
,
-
6972
,
-
6800
,
-
6520
,
-
6132
,
-
5830
,
-
5382
,
-
5091
,
-
4797
,
-
4546
,
-
4472
,
-
4362
,
-
4350
,
-
4235
,
-
3851
,
-
3454
,
-
3144
,
-
2735
,
-
2341
,
-
1845
,
-
1262
,
-
958
,
-
549
,
-
166
,
66
,
382
,
366
,
352
,
341
,
85
,
-
13
,
-
176
,
-
303
,
-
235
,
-
341
,
-
309
,
-
227
,
-
249
,
-
50
,
143
,
384
,
874
,
1149
,
1552
,
2155
,
2767
,
3499
,
3994
,
4460
,
4920
,
5288
,
5569
,
5704
,
5881
,
6094
,
6461
,
6653
,
6803
,
7115
,
7311
,
7521
,
7612
,
7443
,
7380
,
7124
,
6742
,
6495
,
5964
,
5656
,
5415
,
5167
,
5656
,
5813
,
6027
,
6401
,
6351
,
6787
,
7019
,
6581
,
6512
,
5965
,
5308
,
5140
,
4336
,
4147
,
3899
,
3398
,
3360
,
2830
,
2624
,
1968
,
1026
,
395
,
-
699
,
-
1424
,
-
2327
,
-
3006
,
-
3192
,
-
3435
,
-
3337
,
-
3686
,
-
3513
,
-
3350
,
-
3502
,
-
3261
,
-
3878
,
-
4005
,
-
4063
,
-
4187
,
-
3767
,
-
3598
,
-
3384
,
-
3300
,
-
3094
,
-
2857
,
-
3023
,
-
3274
,
-
3851
,
-
4352
,
-
4523
,
-
4943
,
-
5477
,
-
5612
,
-
5682
,
-
5733
,
-
5714
,
-
5965
,
-
6110
,
-
5950
,
-
6158
,
-
6548
,
-
6897
,
-
7165
,
-
7281
,
-
7352
,
-
7258
,
-
7185
,
-
6659
,
-
5946
,
-
5470
,
};
tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.h
已删除
100644 → 0
浏览文件 @
1ae8bec3
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This data was created from the PCM data in a WAV file held in v2 of the
// Speech Commands test dataset, at the path:
// speech_commands_test_set_v0.02/no/f9643d42_nohash_4.wav
// The data was extracted starting at an offset of 8,960, which corresponds to
// the 29th spectrogram slice. It's designed to be used to test the
// preprocessing pipeline, to ensure that the expected spectrogram slice is
// produced given this input.
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_NO_30MS_SAMPLE_DATA_H_
#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_NO_30MS_SAMPLE_DATA_H_
#include <cstdint>
extern
const
int
g_no_30ms_sample_data_size
;
extern
const
int16_t
g_no_30ms_sample_data
[];
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_NO_30MS_SAMPLE_DATA_H_
tensorflow/lite/micro/examples/micro_speech/simple_features/simple_features_generator_test.cc
浏览文件 @
67681479
...
...
@@ -16,10 +16,10 @@ limitations under the License.
#include "tensorflow/lite/micro/examples/micro_speech/simple_features/simple_features_generator.h"
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/micro/examples/micro_speech/no_30ms_sample_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/simple_features/no_power_spectrum_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/simple_features/yes_power_spectrum_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/testdata/no_30ms_audio_data.h"
#include "tensorflow/lite/micro/examples/micro_speech/testdata/yes_30ms_audio_data.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/testing/micro_test.h"
...
...
@@ -30,9 +30,8 @@ TF_LITE_MICRO_TEST(TestSimpleFeaturesGenerator) {
uint8_t
yes_calculated_data
[
g_yes_power_spectrum_data_size
];
TfLiteStatus
yes_status
=
GenerateSimpleFeatures
(
&
micro_error_reporter
,
g_yes_30ms_sample_data
,
g_yes_30ms_sample_data_size
,
g_yes_power_spectrum_data_size
,
yes_calculated_data
);
&
micro_error_reporter
,
g_yes_30ms_audio_data
,
g_yes_30ms_audio_data_size
,
g_yes_power_spectrum_data_size
,
yes_calculated_data
);
TF_LITE_MICRO_EXPECT_EQ
(
kTfLiteOk
,
yes_status
);
for
(
int
i
=
0
;
i
<
g_yes_power_spectrum_data_size
;
++
i
)
{
...
...
@@ -47,7 +46,7 @@ TF_LITE_MICRO_TEST(TestSimpleFeaturesGenerator) {
uint8_t
no_calculated_data
[
g_yes_power_spectrum_data_size
];
TfLiteStatus
no_status
=
GenerateSimpleFeatures
(
&
micro_error_reporter
,
g_no_30ms_
sample_data
,
g_no_30ms_sample
_data_size
,
&
micro_error_reporter
,
g_no_30ms_
audio_data
,
g_no_30ms_audio
_data_size
,
g_no_power_spectrum_data_size
,
no_calculated_data
);
TF_LITE_MICRO_EXPECT_EQ
(
kTfLiteOk
,
no_status
);
...
...
tensorflow/lite/micro/examples/micro_speech/testdata/no_1000ms.wav
0 → 100644
浏览文件 @
67681479
文件已添加
tensorflow/lite/micro/examples/micro_speech/testdata/no_30ms.wav
0 → 100644
浏览文件 @
67681479
文件已添加
tensorflow/lite/micro/examples/micro_speech/testdata/yes_1000ms.wav
0 → 100644
浏览文件 @
67681479
文件已添加
tensorflow/lite/micro/examples/micro_speech/testdata/yes_30ms.wav
0 → 100644
浏览文件 @
67681479
文件已添加
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.cc
已删除
100644 → 0
浏览文件 @
1ae8bec3
此差异已折叠。
点击以展开。
tensorflow/lite/micro/examples/micro_speech/yes_1000ms_sample_data.h
已删除
100644 → 0
浏览文件 @
1ae8bec3
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This data was created from the PCM data in a WAV file held in v2 of the
// Speech Commands test dataset, at the path:
// speech_commands_test_set_v0.02/yes/f2e59fea_nohash_1.wav
// This should contain all 16,000 samples from the one-second file.
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_YES_1000MS_SAMPLE_DATA_H_
#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_YES_1000MS_SAMPLE_DATA_H_
#include <cstdint>
extern
const
int
g_yes_1000ms_sample_data_size
;
extern
const
int16_t
g_yes_1000ms_sample_data
[];
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_YES_1000MS_SAMPLE_DATA_H_
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.cc
已删除
100644 → 0
浏览文件 @
1ae8bec3
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// See the header for documentation on the meaning of this data.
#include "tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.h"
const
int
g_yes_30ms_sample_data_size
=
480
;
const
int16_t
g_yes_30ms_sample_data
[
480
]
=
{
-
876
,
-
470
,
510
,
803
,
170
,
-
787
,
-
1568
,
-
1893
,
-
1598
,
-
1027
,
-
992
,
-
1803
,
-
2610
,
-
2484
,
-
1905
,
-
2113
,
-
3113
,
-
3399
,
-
2267
,
-
1261
,
-
2007
,
-
3637
,
-
3909
,
-
2340
,
-
893
,
-
1158
,
-
2272
,
-
2486
,
-
1639
,
-
915
,
-
777
,
-
596
,
-
91
,
196
,
85
,
210
,
875
,
1373
,
1247
,
1219
,
1958
,
2718
,
2328
,
1196
,
1008
,
2350
,
3677
,
3269
,
1503
,
366
,
922
,
2264
,
2810
,
1996
,
608
,
-
168
,
75
,
680
,
811
,
395
,
-
56
,
-
318
,
-
607
,
-
966
,
-
1108
,
-
925
,
-
613
,
-
368
,
-
369
,
-
919
,
-
1926
,
-
2460
,
-
1685
,
-
300
,
155
,
-
611
,
-
1524
,
-
2204
,
-
3227
,
-
3859
,
-
2037
,
1622
,
2382
,
-
2583
,
-
8448
,
-
7544
,
-
84
,
4814
,
915
,
-
6423
,
-
7558
,
-
1746
,
2515
,
-
59
,
-
4587
,
-
3858
,
1260
,
3625
,
187
,
-
4148
,
-
3500
,
1542
,
5467
,
4780
,
1256
,
-
1127
,
-
403
,
2481
,
5332
,
6346
,
5014
,
2536
,
1216
,
2467
,
5039
,
6238
,
5070
,
3381
,
3269
,
4173
,
3905
,
2248
,
1586
,
3299
,
5240
,
4362
,
1004
,
-
1382
,
-
489
,
2113
,
3168
,
1620
,
-
742
,
-
1824
,
-
1435
,
-
897
,
-
1058
,
-
1500
,
-
1545
,
-
1398
,
-
1965
,
-
3266
,
-
4136
,
-
3756
,
-
2609
,
-
1804
,
-
1986
,
-
3087
,
-
4599
,
-
5296
,
-
4051
,
-
1731
,
-
781
,
-
2228
,
-
4092
,
-
3977
,
-
2325
,
-
1353
,
-
1568
,
-
1490
,
-
428
,
178
,
-
672
,
-
1650
,
-
1058
,
749
,
2039
,
2079
,
1540
,
897
,
310
,
572
,
2266
,
4265
,
4265
,
1869
,
-
231
,
559
,
3332
,
4752
,
3229
,
768
,
101
,
1364
,
2463
,
1984
,
819
,
411
,
723
,
675
,
-
162
,
-
923
,
-
743
,
-
32
,
185
,
-
516
,
-
1653
,
-
2359
,
-
2103
,
-
986
,
42
,
-
205
,
-
1702
,
-
2870
,
-
2337
,
-
809
,
-
221
,
-
982
,
-
1544
,
-
946
,
-
598
,
-
2117
,
-
4291
,
-
4100
,
-
857
,
1948
,
338
,
-
4799
,
-
7972
,
-
5403
,
173
,
2371
,
-
1063
,
-
5533
,
-
5578
,
-
1777
,
605
,
-
985
,
-
3249
,
-
2213
,
1184
,
2691
,
560
,
-
2356
,
-
2288
,
1233
,
5244
,
6441
,
4004
,
370
,
-
663
,
2555
,
7404
,
9282
,
6573
,
2612
,
1836
,
4662
,
7467
,
7393
,
5421
,
4262
,
4741
,
5362
,
4705
,
3163
,
2397
,
3337
,
4887
,
4810
,
2254
,
-
749
,
-
1316
,
772
,
2706
,
2016
,
-
573
,
-
2552
,
-
2746
,
-
2012
,
-
1647
,
-
1978
,
-
2579
,
-
3105
,
-
3473
,
-
3911
,
-
4484
,
-
4891
,
-
4795
,
-
4163
,
-
3543
,
-
3538
,
-
4275
,
-
5356
,
-
5743
,
-
4637
,
-
2614
,
-
1301
,
-
1825
,
-
3341
,
-
4011
,
-
2937
,
-
751
,
1007
,
1245
,
235
,
-
639
,
-
61
,
1626
,
2864
,
2967
,
2734
,
3013
,
3329
,
2914
,
2312
,
2666
,
3839
,
4308
,
3162
,
1453
,
768
,
1255
,
1887
,
2006
,
1715
,
1031
,
-
297
,
-
1660
,
-
1690
,
-
277
,
813
,
-
30
,
-
2137
,
-
3370
,
-
2854
,
-
1553
,
-
593
,
-
413
,
-
1146
,
-
2567
,
-
3440
,
-
2369
,
-
205
,
379
,
-
1258
,
-
2315
,
-
812
,
262
,
-
3205
,
-
8576
,
-
7894
,
738
,
7492
,
1951
,
-
11595
,
-
17098
,
-
6934
,
7139
,
8065
,
-
4575
,
-
14199
,
-
8946
,
3606
,
7504
,
-
547
,
-
8242
,
-
5113
,
4406
,
8113
,
2134
,
-
5040
,
-
4089
,
4157
,
10934
,
10158
,
4167
,
-
565
,
-
192
,
4428
,
9765
,
12201
,
9861
,
4512
,
1225
,
3451
,
8483
,
10133
,
6497
,
2574
,
3333
,
6806
,
6986
,
2487
,
-
1214
,
623
,
5416
,
6647
,
2204
,
-
3289
,
-
4556
,
-
1565
,
1544
,
1525
,
-
1236
,
-
4293
,
-
5695
,
-
5174
,
-
3995
,
-
3403
,
-
3449
,
-
3750
,
-
4505
,
-
6014
,
-
7296
,
-
6523
,
-
3849
,
-
2096
,
-
3288
,
-
5722
,
-
6004
,
-
3581
,
-
1497
,
-
1960
,
-
3330
,
-
2800
,
-
434
,
964
,
-
111
,
-
1739
,
-
1136
,
1736
,
4151
,
3736
,
1274
,
-
451
,
469
,
3386
,
5833
,
5898
,
3646
,
1085
,
272
,
1743
,
4061
,
5108
,
3837
,
1490
,
246
,
967
,
1866
,
859
,
-
1069
,
-
974
,
1542
,
2835
,
47
,
-
4285
,
-
5068
,
-
1567
,
1781
,
1223
,
-
1997
,
-
4227
,
-
3747
,
-
1720
,
41
,
245
,
-
1228
,
-
2972
,
-
2673
,
22
,
1980
,
-
930
,
-
7721
,
-
11271
,
-
5725
,
4974
,
8484
,
-
2007
,
-
16979
,
-
19255
,
-
4670
,
11057
,
9690
,
-
6417
,
-
17537
,
-
10841
,
4262
,
9292
,
};
tensorflow/lite/micro/examples/micro_speech/yes_30ms_sample_data.h
已删除
100644 → 0
浏览文件 @
1ae8bec3
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This data was created from the PCM data in a WAV file held in v2 of the
// Speech Commands test dataset, at the path:
// speech_commands_test_set_v0.02/yes/f2e59fea_nohash_1.wav
// The data was extracted starting at an offset of 8,000, which corresponds to
// the 26th spectrogram slice. It's designed to be used to test the
// preprocessing pipeline, to ensure that the expected spectrogram slice is
// produced given this input.
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_YES_30MS_SAMPLE_DATA_H_
#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_YES_30MS_SAMPLE_DATA_H_
#include <cstdint>
extern
const
int
g_yes_30ms_sample_data_size
;
extern
const
int16_t
g_yes_30ms_sample_data
[];
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_YES_30MS_SAMPLE_DATA_H_
tensorflow/lite/micro/tools/ci_build/test_code_style.sh
浏览文件 @
67681479
...
...
@@ -57,6 +57,7 @@ micro/tools/make/downloads/pigweed/pw_presubmit/py/pw_presubmit/pigweed_presubmi
-e
"
\.
tflite"
\
-e
"
\.
tpl"
\
-e
"
\.
txt"
\
-e
"
\.
wav"
\
--output-directory
/tmp
LICENSE_CHECK_RESULT
=
$?
...
...
tensorflow/lite/micro/tools/ci_build/test_esp32.sh
浏览文件 @
67681479
...
...
@@ -26,6 +26,7 @@ pwd
source
tensorflow/lite/micro/tools/ci_build/helper_functions.sh
pip3
install
Pillow
pip3
install
Wave
TARGET
=
esp
TARGET_ARCH
=
xtensa-esp32
...
...
tensorflow/lite/micro/tools/generate_cc_arrays.py
浏览文件 @
67681479
...
...
@@ -22,33 +22,33 @@ from __future__ import print_function
from
PIL
import
Image
import
argparse
import
os
import
wave
def
generate_file
(
out_fname
,
array_name
,
out_string
,
size
):
def
generate_file
(
out_fname
,
array_name
,
array_type
,
out_string
,
size
):
''' Write the out string containing an array of values to a variable in a cc
file, and create a header file defining the same array. '''
os
.
makedirs
(
os
.
path
.
dirname
(
out_fname
),
exist_ok
=
True
)
if
out_fname
.
endswith
(
'.cc'
):
out_cc_file
=
open
(
out_fname
,
'w'
)
# Log cc file name for Make to include in the build.
out_cc_file
.
write
(
'#include "'
+
out_fname
.
split
(
"genfiles/"
)[
-
1
].
replace
(
'.cc'
,
'.h'
)
+
'"
\n\n
'
)
out_cc_file
.
write
(
'alignas(16) const unsigned char '
+
array_name
+
'[] = {'
)
out_cc_file
.
write
(
'#include "{}"
\n\n
'
.
format
(
out_fname
.
split
(
"genfiles/"
)[
-
1
].
replace
(
'.cc'
,
'.h'
)))
out_cc_file
.
write
(
'alignas(16) const {} {}[] = {{'
.
format
(
array_type
,
array_name
))
out_cc_file
.
write
(
out_string
)
out_cc_file
.
write
(
'};
\n
'
)
out_cc_file
.
write
(
'const unsigned int
'
+
array_name
+
'_size = '
+
str
(
size
)
+
';'
)
out_cc_file
.
write
(
'const unsigned int
{}_size = {};'
.
format
(
array_name
,
str
(
size
))
)
out_cc_file
.
close
()
elif
out_fname
.
endswith
(
'.h'
):
out_hdr_file
=
open
(
out_fname
,
'w'
)
out_hdr_file
.
write
(
'extern const
unsigned char '
+
array_name
+
'[];
\n
'
)
out_hdr_file
.
write
(
'extern const unsigned int '
+
array_name
+
'_size'
+
';'
)
out_hdr_file
.
write
(
'extern const
{} {}[];
\n
'
.
format
(
array_type
,
array_name
))
out_hdr_file
.
write
(
'extern const unsigned int {}_size;'
.
format
(
array_name
)
)
out_hdr_file
.
close
()
else
:
raise
ValueError
(
'
input file must be .tflite, .bmp
'
)
raise
ValueError
(
'
generated file must be end with .cc or .h
'
)
def
generate_array
(
input_fname
):
...
...
@@ -70,16 +70,26 @@ def generate_array(input_fname):
for
byte
in
image_bytes
:
out_string
+=
hex
(
byte
)
+
","
return
[
len
(
image_bytes
),
out_string
]
elif
input_fname
.
endswith
(
'.wav'
):
wav_file
=
wave
.
open
(
input_fname
,
mode
=
'r'
)
out_string
=
""
for
i
in
range
(
wav_file
.
getnframes
()):
frame
=
wav_file
.
readframes
(
1
)
out_string
+=
str
(
int
.
from_bytes
(
frame
,
byteorder
=
'little'
,
signed
=
True
))
+
","
return
[
wav_file
.
getnframes
(),
out_string
]
else
:
raise
ValueError
(
'input file must be .tflite, .bmp'
)
raise
ValueError
(
'input file must be .tflite, .bmp
or .wav
'
)
def
array_name
(
input_fname
):
base_array_name
=
'g_'
+
input_fname
.
split
(
'.'
)[
0
].
split
(
'/'
)[
-
1
]
if
input_fname
.
endswith
(
'.tflite'
):
return
base_array_name
+
'_model_data'
return
[
base_array_name
+
'_model_data'
,
'unsigned char'
]
elif
input_fname
.
endswith
(
'.bmp'
):
return
base_array_name
+
'_image_data'
return
[
base_array_name
+
'_image_data'
,
'unsigned char'
]
elif
input_fname
.
endswith
(
'.wav'
):
return
[
base_array_name
+
'_audio_data'
,
'short'
]
def
main
():
...
...
@@ -99,8 +109,9 @@ def main():
if
args
.
output
.
endswith
(
'.cc'
)
or
args
.
output
.
endswith
(
'.h'
):
assert
(
len
(
args
.
inputs
)
==
1
)
size
,
cc_array
=
generate_array
(
args
.
inputs
[
0
])
generated_array_name
=
array_name
(
args
.
inputs
[
0
])
generate_file
(
args
.
output
,
generated_array_name
,
cc_array
,
size
)
generated_array_name
,
array_type
=
array_name
(
args
.
inputs
[
0
])
generate_file
(
args
.
output
,
generated_array_name
,
array_type
,
cc_array
,
size
)
else
:
# Deduplicate inputs to prevent duplicate generated files (ODR issue).
for
input_file
in
list
(
dict
.
fromkeys
(
args
.
inputs
)):
...
...
@@ -109,17 +120,21 @@ def main():
output_base_fname
=
output_base_fname
+
'_model_data'
elif
input_file
.
endswith
(
'.bmp'
):
output_base_fname
=
output_base_fname
+
'_image_data'
elif
input_file
.
endswith
(
'.wav'
):
output_base_fname
=
output_base_fname
+
'_audio_data'
else
:
raise
ValueError
(
'input file must be .tflite, .bmp'
)
raise
ValueError
(
'input file must be .tflite, .bmp
or .wav
'
)
output_cc_fname
=
output_base_fname
+
'.cc'
# Print output cc filename for Make to include it in the build.
print
(
output_cc_fname
)
output_hdr_fname
=
output_base_fname
+
'.h'
size
,
cc_array
=
generate_array
(
input_file
)
generated_array_name
=
array_name
(
input_file
)
generate_file
(
output_cc_fname
,
generated_array_name
,
cc_array
,
size
)
generate_file
(
output_hdr_fname
,
generated_array_name
,
cc_array
,
size
)
generated_array_name
,
array_type
=
array_name
(
input_file
)
generate_file
(
output_cc_fname
,
generated_array_name
,
array_type
,
cc_array
,
size
)
generate_file
(
output_hdr_fname
,
generated_array_name
,
array_type
,
cc_array
,
size
)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录