# TensorFlow Lite C++ minimal example
This example shows how you can build a simple TensorFlow Lite application.
#### Step 1. Install CMake tool
It requires CMake 3.16 or higher. On Ubuntu, you can simply run the following
command.
```sh
sudo apt-get install cmake
```
Or you can follow
[the official cmake installation guide](https://cmake.org/install/)
#### Step 2. Clone TensorFlow repository
```sh
git clone https://github.com/tensorflow/tensorflow.git tensorflow
git checkout origin/r2.10
```
#### Step 3. Create CMake build directory and run CMake tool
```sh
# move current directory to tensorflow_root/tensorflow/lite/examples
mkdir build_yamnet
cd build_yamnet
cmake -DCMAKE_TOOLCHAIN_FILE=/home/yons/data/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake -DTFLITE_ENABLE_XNNPACK=OFF ../tensorflow/lite/examples/yamnet
# enter tensorflow root path, patch different
cd ../
patch -p0 build_yamnet/flatbuffers/include/flatbuffers/util.h flatbuffers_util_h.diff
patch -p0 build_yamnet/flatbuffers/src/util.cpp flatbuffers_util_cpp.diff
patch -p0 build_yamnet/cpuinfo/CMakeLists.txt cpuinfo.diff
# re cmake configuration and build
cd build_yamnet
cmake -DCMAKE_TOOLCHAIN_FILE=/home/yons/data/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake -DTFLITE_ENABLE_XNNPACK=OFF ../tensorflow/lite/examples/yamnet
cmake --build ./ -j20
```
#### Step 4. copy binary file and related file to openHarmony device through device
* make sure that connect to device.
```
hdc list targets
hdc shell
```
```sh
# In the build_yamnet directory
hdc file send yamnet /data
hdc file send yamnet_class_map.txt /data
hdc file send miaow_16k.wav /data
hdc file send golden_whistle.wav /data
hdc file send speech_whistling2.wav /data
# copy libc++_shared.so from ohos-sdk cross compile toolchain
hdc file send libc++_shared.so /data
```
#### Step 5. execute binary programation in OHOS
```
hdc shell
cd data
export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
./yamnet wav_filepath
# 从上面三个文件选一
golden_whistle.wav
miaow_16k.wav
speech_whistling2.wav
```
#### Step 5. result
![result](images/result.PNG)
没有合适的资源?快使用搜索试试~ 我知道了~
在OpenHarmony上,使用tensorflow lite推理Yamnet实现语音分类
需积分: 0 2 下载量 135 浏览量
2022-12-12
23:58:28
上传
评论
收藏 29.85MB GZ 举报
温馨提示
共53个文件
sample:11个
master:4个
wav:3个
在OpenHarmony上,使用tensorflow lite推理Yamnet实现语音分类 包含所需要的Tensorflow lite OHOS 库的编译方式 测试所需要的测试数据以及源码 基于Tensoflow lite c++ sdk接口编写
资源推荐
资源详情
资源评论
收起资源包目录
yamnet_tflite_cpp.tar.gz (53个子文件)
yamnet_tflite_cpp
images
result.PNG 29KB
yamnet.cc 8KB
BUILD 644B
data
libc++_shared.so 1.33MB
golden_whistle.wav 152KB
speech_whistling2.wav 154KB
yamnet 59.95MB
yamnet_class_map.txt 6KB
miaow_16k.wav 210KB
.git
index 1KB
hooks
fsmonitor-watchman.sample 3KB
pre-push.sample 1KB
prepare-commit-msg.sample 1KB
applypatch-msg.sample 478B
pre-commit.sample 2KB
pre-receive.sample 544B
pre-applypatch.sample 424B
commit-msg.sample 896B
pre-rebase.sample 5KB
update.sample 4KB
post-update.sample 189B
config 418B
description 73B
refs
tags
heads
master 41B
remotes
origin
master 41B
branches
logs
refs
heads
master 327B
remotes
origin
master 154B
HEAD 327B
objects
c1
1e43188e62992e89a9777f7db047eaebbc17e2 244B
98
478c1436b37302cc68bdaef214e67e9ec5c399 180KB
36
91ef4fe98948ec20f7beb24af3c00645da4708 253B
90
1a24ee8e858e574b72e3fcd94de1a52cdb3ea8 54B
e0
351d02847ed442a29ede154437707d3000c205 715B
9e
50d2c139a892b3ac829c4b600b4cf077854c8e 15.15MB
69
76a7ab6e6de3965d4626c72115f184e8701879 974B
86
cc7b669c035361fab784a54d71accb779ad022 144B
76
b1ebb417a6991b8c2b49040e955d5b6031eed7 128KB
40
b779c1a95fb32fc6804a94ab82d1f307018adf 365B
info
ad
de13343625fee79558d009a42a3cf68d821cd2 3KB
53
401b5e71f747cec68dae52c663c62cdd32c72a 254B
e4
9a879ccb9f617e28280f82a51845cfa09d76bd 997B
pack
00
1a6a7c5aec4956875a3b9f1a8123a97a7425fc 25KB
0a
1358800e73e9ea5078ef4260f169737fab4350 127B
62
7938626d86f2b612943481b269ade4e39863a4 2KB
c3
e864e7d4886c18bfe8374e86b8db00b494cd16 3KB
d3
e7b73d9cf94f59d1393cbe5027461a43201a1b 56KB
c9
e6e331e8586b84a834cd170cb9d50745f0b49b 438KB
info
exclude 240B
COMMIT_EDITMSG 707B
HEAD 23B
wav_parser.hpp 7KB
CMakeLists.txt 1KB
README.md 2KB
共 53 条
- 1
资源评论
TuT_today
- 粉丝: 139
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功