-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VAD+ASR demo for HarmonyOS (#1573)
- Loading branch information
1 parent
315d8e2
commit f3f8961
Showing
44 changed files
with
1,102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Introduction | ||
|
||
- [./SherpaOnnxHar](./SherpaOnnxHar) It is for building `sherpa_onnx.har`. | ||
If you don't need to change the C++ or Typescript code of sherpa-onnx, then | ||
you can download pre-built `sherpa_onnx.har` from us. Please refer to | ||
our [doc](https://k2-fsa.github.io/sherpa/onnx) for how to download it. | ||
|
||
- [./SherpaOnnxVadAsr](./SherpaOnnxVadAsr) It shows how to use | ||
VAD + Non-streaming ASR for speech recognition. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/node_modules | ||
/oh_modules | ||
/local.properties | ||
/.idea | ||
**/build | ||
/.hvigor | ||
.cxx | ||
/.clangd | ||
/.clang-format | ||
/.clang-tidy | ||
**/.test | ||
/.appanalyzer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"app": { | ||
"bundleName": "com.k2fsa.sherpa.onnx.vad.asr", | ||
"vendor": "example", | ||
"versionCode": 1000000, | ||
"versionName": "1.0.0", | ||
"icon": "$media:app_icon", | ||
"label": "$string:app_name" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
harmony-os/SherpaOnnxVadAsr/AppScope/resources/base/element/string.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"string": [ | ||
{ | ||
"name": "app_name", | ||
"value": "SherpaOnnxVadAsr" | ||
} | ||
] | ||
} |
Binary file added
BIN
+2.71 KB
harmony-os/SherpaOnnxVadAsr/AppScope/resources/base/media/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"app": { | ||
"signingConfigs": [], | ||
"products": [ | ||
{ | ||
"name": "default", | ||
"signingConfig": "default", | ||
"compatibleSdkVersion": "4.0.0(10)", | ||
"runtimeOS": "HarmonyOS", | ||
"buildOption": { | ||
"strictMode": { | ||
"caseSensitiveCheck": true, | ||
} | ||
} | ||
} | ||
], | ||
"buildModeSet": [ | ||
{ | ||
"name": "debug", | ||
}, | ||
{ | ||
"name": "release" | ||
} | ||
] | ||
}, | ||
"modules": [ | ||
{ | ||
"name": "entry", | ||
"srcPath": "./entry", | ||
"targets": [ | ||
{ | ||
"name": "default", | ||
"applyToProducts": [ | ||
"default" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"files": [ | ||
"**/*.ets" | ||
], | ||
"ignore": [ | ||
"**/src/ohosTest/**/*", | ||
"**/src/test/**/*", | ||
"**/src/mock/**/*", | ||
"**/node_modules/**/*", | ||
"**/oh_modules/**/*", | ||
"**/build/**/*", | ||
"**/.preview/**/*" | ||
], | ||
"ruleSet": [ | ||
"plugin:@performance/recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"rules": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/node_modules | ||
/oh_modules | ||
/.preview | ||
/build | ||
/.cxx | ||
/.test | ||
*.har |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Introduction | ||
|
||
Please download ./sherpa_onnx-v1.10.32.har | ||
from <https://huggingface.co/csukuangfj/sherpa-onnx-harmony-os/tree/main/har> | ||
|
||
Hint: For users who have no access to huggingface, please use | ||
<https://hf-mirror.com/csukuangfj/sherpa-onnx-harmony-os/tree/main/har> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"apiType": "stageMode", | ||
"buildOption": { | ||
"sourceOption": { | ||
"workers": [ | ||
'./src/main/ets/workers/NonStreamingAsrWithVadWorker.ets' | ||
] | ||
} | ||
}, | ||
"buildOptionSet": [ | ||
{ | ||
"name": "release", | ||
"arkOptions": { | ||
"obfuscation": { | ||
"ruleOptions": { | ||
"enable": false, | ||
"files": [ | ||
"./obfuscation-rules.txt" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
], | ||
"targets": [ | ||
{ | ||
"name": "default" | ||
}, | ||
{ | ||
"name": "ohosTest", | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { hapTasks } from '@ohos/hvigor-ohos-plugin'; | ||
|
||
export default { | ||
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ | ||
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Define project specific obfuscation rules here. | ||
# You can include the obfuscation configuration files in the current module's build-profile.json5. | ||
# | ||
# For more details, see | ||
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 | ||
|
||
# Obfuscation options: | ||
# -disable-obfuscation: disable all obfuscations | ||
# -enable-property-obfuscation: obfuscate the property names | ||
# -enable-toplevel-obfuscation: obfuscate the names in the global scope | ||
# -compact: remove unnecessary blank spaces and all line feeds | ||
# -remove-log: remove all console.* statements | ||
# -print-namecache: print the name cache that contains the mapping from the old names to new names | ||
# -apply-namecache: reuse the given cache file | ||
|
||
# Keep options: | ||
# -keep-property-name: specifies property names that you want to keep | ||
# -keep-global-name: specifies names that you want to keep in the global scope | ||
|
||
-enable-property-obfuscation | ||
-enable-toplevel-obfuscation | ||
-enable-filename-obfuscation | ||
-enable-export-obfuscation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "entry", | ||
"version": "1.0.0", | ||
"description": "Please describe the basic information.", | ||
"main": "", | ||
"author": "", | ||
"license": "", | ||
"dependencies": {} | ||
} | ||
|
43 changes: 43 additions & 0 deletions
43
harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/entryability/EntryAbility.ets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import AbilityConstant from '@ohos.app.ability.AbilityConstant'; | ||
import hilog from '@ohos.hilog'; | ||
import UIAbility from '@ohos.app.ability.UIAbility'; | ||
import Want from '@ohos.app.ability.Want'; | ||
import window from '@ohos.window'; | ||
|
||
export default class EntryAbility extends UIAbility { | ||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); | ||
} | ||
|
||
onDestroy(): void { | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); | ||
} | ||
|
||
onWindowStageCreate(windowStage: window.WindowStage): void { | ||
// Main window is created, set main page for this ability | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); | ||
|
||
windowStage.loadContent('pages/Index', (err) => { | ||
if (err.code) { | ||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); | ||
return; | ||
} | ||
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); | ||
}); | ||
} | ||
|
||
onWindowStageDestroy(): void { | ||
// Main window is destroyed, release UI related resources | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); | ||
} | ||
|
||
onForeground(): void { | ||
// Ability has brought to foreground | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); | ||
} | ||
|
||
onBackground(): void { | ||
// Ability has back to background | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
harmony-os/SherpaOnnxVadAsr/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import hilog from '@ohos.hilog'; | ||
import BackupExtensionAbility, { BundleVersion } from '@ohos.application.BackupExtensionAbility'; | ||
|
||
export default class EntryBackupAbility extends BackupExtensionAbility { | ||
async onBackup() { | ||
hilog.info(0x0000, 'testTag', 'onBackup ok'); | ||
} | ||
|
||
async onRestore(bundleVersion: BundleVersion) { | ||
hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); | ||
} | ||
} |
Oops, something went wrong.