• Home
Name Date Size #Lines LOC

..--

AppScope/22-Oct-2025-3532

entry/22-Oct-2025-414,830314,763

hvigor/22-Oct-2025-2322

screenshots/22-Oct-2025-

.gitignoreD22-Oct-2025133 1212

README_zh.mdD22-Oct-20253 KiB7956

build-profile.json5D22-Oct-20251.3 KiB5755

code-linter.json5D22-Oct-2025854 3232

hvigorfile.tsD22-Oct-2025830 225

oh-package.json5D22-Oct-2025868 2826

ohosTest.mdD22-Oct-2025887 128

README_zh.md

1# **基于**Native**接口的MindSpore Lite ASR 应用开发**
2
3### 介绍
4
5本文基于MindSpore Lite提供的[Native API](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md),实现“自动语音识别 ASR”示例程序,来演示端侧部署的流程。
6
7### 效果预览
8
9| 主页                                               |
10| -------------------------------------------------- |
11| <img src="screenshots/MIndSporeLiteCDemoASR.PNG"/> |
12
13#### 使用说明
14
151. 在主界面点击“播放示例音频”按钮,即可播放音频文件;
162. 在主界面点击“识别示例音频”按钮,即可显示出音频的识别结果;
17
18### 工程目录
19
20```
21entry
22├── src/main
23│   ├── ets
24|   |   └── pages
25|   |       └── Index.ets // 首页
26|   |       └── player.ets // 音频播放
27│   ├── cpp
28|   |   └── mslite_napi.cpp // 推理函数
29|   |   └── CMakeLists.txt // 编译脚本
30|   |   └── third_party
31|   |       └── librosa // 音频特征提取库
32|   |       └── libsamplerate // 音频重采样库
33|   |   └── types
34|   |       └── libentry
35|   |           └── Index.t.ts // 将C++动态库封装成JS模块
36│   ├── resources // 资源文件
37|   |   └── rawfile
38|   |       └── tiny-encoder.ms // 存放的模型文件1
39|   |       └── tiny-decoder-main.ms // 存放的模型文件2
40|   |       └── tiny-decoder-loop.ms // 存放的模型文件3
41```
42
43### 具体实现
44
45* 本示例程序中使用的终端图像分类模型文件为[tiny-encoder.ms](entry\src\main\resources\rawfile\tiny-encoder.ms)、[tiny-decoder-main.ms](entry\src\main\resources\rawfile\tiny-decoder-main.ms)、[tiny-decoder-loop.ms](entry\src\main\resources\rawfile\tiny-decoder-loop.ms)。
46* 调用[MindSpore Lite Native API](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md)实现推理。完整代码请参见mslite_napi.cpp47* 编写CMake脚本。链接MindSpore Lite动态库,完整代码请参见CMakeLists.txt48* 使用N-API将C++动态库封装成JS模块,在[index.d.ts](entry/src/main/cpp/types/libentry/index.d.ts) 定义JS接口`runDemo()` 。
49* 调用推理函数并处理结果。完整代码请参见Index.ets50
51### 相关权限
52
53无。
54
55### 依赖
56
57无。
58
59### 约束与限制
60
611.本示例仅支持 HarmonyOS 5.0.0 及以上运行,测试设备:Phone;
62
632.本示例为Stage模型,已适配API version 14版本SDK;
64
653.本示例需要使用DevEco Studio 5.0.2Release及以上版本才可编译运行。
66
67### 下载
68
69如需单独下载本工程,执行如下命令:
70
71```
72git init
73git config core.sparsecheckout true
74echo code/AI/MindSporeLiteCDemoASR/ > .git/info/sparse-checkout
75git remote add origin https://gitee.com/openharmony/applications_app_samples.git
76git pull origin master
77```
78
79