Fangjun Kuang
Committed by GitHub

Add speaker identification demo for HarmonyOS (#1608)

正在显示 47 个修改的文件 包含 1052 行增加9 行删除
... ... @@ -13,5 +13,8 @@
- [./SherpaOnnxStreamingAsr](./SherpaOnnxStreamingAsr) It shows how to use
streaming ASR models for real-time on-device speech recognition.
- [./SherpaOnnxSpeakerIdentification](./SherpaOnnxSpeakerIdentification) It shows how to use
speaker embedding models for on-device speaker identification.
- [./SherpaOnnxTts](./SherpaOnnxTts) It shows how to run on-device text-to-speech.
Please see the doc at <https://k2-fsa.github.io/sherpa/onnx/harmony-os/tts.html>
... ...
... ... @@ -764,7 +764,7 @@ static Napi::Array SpeakerEmbeddingManagerGetAllSpeakersWrapper(
int32_t num_speakers = SherpaOnnxSpeakerEmbeddingManagerNumSpeakers(manager);
if (num_speakers == 0) {
return {};
return Napi::Array::New(env, num_speakers);
}
const char *const *all_speaker_names =
... ...
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
/.appanalyzer
\ No newline at end of file
... ...
{
"app": {
"bundleName": "com.k2fsa.sherpa.onnx.speaker.identification",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
... ...
{
"string": [
{
"name": "app_name",
"value": "SherpaOnnxSpeakerIdentification"
}
]
}
... ...
{
"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"
]
}
]
}
]
}
\ No newline at end of file
... ...
{
"files": [
"**/*.ets"
],
"ignore": [
"**/src/ohosTest/**/*",
"**/src/test/**/*",
"**/src/mock/**/*",
"**/node_modules/**/*",
"**/oh_modules/**/*",
"**/build/**/*",
"**/.preview/**/*"
],
"ruleSet": [
"plugin:@performance/recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
}
}
\ No newline at end of file
... ...
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
... ...
{
"apiType": "stageMode",
"buildOption": {
"sourceOption": {
"workers": [
'./src/main/ets/workers/SpeakerIdentificationWorker.ets'
]
}
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
}
}
}
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest",
}
]
}
\ No newline at end of file
... ...
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. */
}
... ...
# 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
\ No newline at end of file
... ...
{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"sherpa_onnx": "1.10.33",
}
}
... ...
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');
}
}
... ...
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));
}
}
\ No newline at end of file
... ...
import worker, { MessageEvents } from '@ohos.worker';
import { audio } from '@kit.AudioKit';
import { allAllowed, requestPermissions } from './Permission';
import { Permissions } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
import fs from '@ohos.file.fs';
function flatten(samples: Float32Array[]): Float32Array {
let n = 0;
for (let i = 0; i < samples.length; ++i) {
n += samples[i].length;
}
const ans: Float32Array = new Float32Array(n);
let offset: number = 0;
for (let i = 0; i < samples.length; ++i) {
ans.set(samples[i], offset);
offset += samples[i].length;
}
return ans;
}
function savePcmToWav(filename: string, samples: Int16Array, sampleRate: number) {
const fp = fs.openSync(filename, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
const header = new ArrayBuffer(44);
const view = new DataView(header);
// http://soundfile.sapp.org/doc/WaveFormat/
// F F I R
view.setUint32(0, 0x46464952, true); // chunkID
view.setUint32(4, 36 + samples.length * 2, true); // chunkSize // E V A W
view.setUint32(8, 0x45564157, true); // format // // t m f
view.setUint32(12, 0x20746d66, true); // subchunk1ID
view.setUint32(16, 16, true); // subchunk1Size, 16 for PCM
view.setUint32(20, 1, true); // audioFormat, 1 for PCM
view.setUint16(22, 1, true); // numChannels: 1 channel
view.setUint32(24, sampleRate, true); // sampleRate
view.setUint32(28, sampleRate * 2, true); // byteRate
view.setUint16(32, 2, true); // blockAlign
view.setUint16(34, 16, true); // bitsPerSample
view.setUint32(36, 0x61746164, true); // Subchunk2ID
view.setUint32(40, samples.length * 2, true); // subchunk2Size
fs.writeSync(fp.fd, new Uint8Array(header).buffer, { length: header.byteLength });
fs.writeSync(fp.fd, samples.buffer, { length: samples.buffer.byteLength });
fs.closeSync(fp.fd);
}
function toInt16Samples(samples: Float32Array): Int16Array {
const int16Samples = new Int16Array(samples.length);
for (let i = 0; i < samples.length; ++i) {
let s = samples[i] * 32767;
s = s > 32767 ? 32767 : s;
s = s < -32768 ? -32768 : s;
int16Samples[i] = s;
}
return int16Samples;
}
@Entry
@Component
struct Index {
@State title: string = 'Next-gen Kaldi: Speaker Identification';
@State titleFontSize: number = 18;
private controller: TabsController = new TabsController();
@State currentIndex: number = 0;
@State message: string = 'Hello World';
private workerInstance?: worker.ThreadWorker
private readonly scriptURL: string = 'entry/ets/workers/SpeakerIdentificationWorker.ets'
@State allSpeakerNames: string[] = [];
private inputSpeakerName: string = '';
@State btnSaveAudioEnabled: boolean = false;
@State btnAddEnabled: boolean = false;
private sampleRate: number = 16000;
private sampleList: Float32Array[] = []
private mic?: audio.AudioCapturer;
@State infoHome: string = '';
@State infoAdd: string = '';
@State micBtnCaption: string = 'Start recording';
@State micStarted: boolean = false;
async initMic() {
const permissions: Permissions[] = ["ohos.permission.MICROPHONE"];
let allowed: boolean = await allAllowed(permissions);
if (!allowed) {
console.log("request to access the microphone");
const status: boolean = await requestPermissions(permissions);
if (!status) {
console.error('access to microphone is denied')
this.infoHome = "Failed to get microphone permission. Please retry";
this.infoAdd = this.infoHome;
return;
}
allowed = await allAllowed(permissions);
if (!allowed) {
console.error('failed to get microphone permission');
this.infoHome = "Failed to get microphone permission. Please retry";
this.infoAdd = this.infoHome;
return;
}
} else {
console.log("allowed to access microphone");
}
const audioStreamInfo: audio.AudioStreamInfo = {
samplingRate: this.sampleRate,
channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW,
};
const audioCapturerInfo: audio.AudioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC, capturerFlags: 0
};
const audioCapturerOptions: audio.AudioCapturerOptions = {
streamInfo: audioStreamInfo, capturerInfo: audioCapturerInfo
};
audio.createAudioCapturer(audioCapturerOptions, (err, data) => {
if (err) {
console.error(`error code is ${err.code}, error message is ${err.message}`);
this.infoHome = 'Failed to init microphone';
this.infoAdd = this.infoHome;
} else {
console.info(`init mic successfully`);
this.mic = data;
this.mic.on('readData', this.micCallback);
}
});
}
async aboutToAppear() {
this.workerInstance = new worker.ThreadWorker(this.scriptURL, {
name: 'Speaker identification worker'
});
this.workerInstance.onmessage = (e: MessageEvents) => {
const msgType = e.data['msgType'] as string;
console.log(`received msg from worker: ${msgType}`);
if (msgType == 'manager-all-speaker-names') {
this.allSpeakerNames = e.data['allSpeakers'] as string[];
}
};
this.workerInstance.postMessage({ msgType: 'init-extractor', context: getContext()});
await this.initMic();
}
@Builder
TabBuilder(title: string, targetIndex: number, selectedImg: Resource, normalImg: Resource) {
Column() {
Image(this.currentIndex == targetIndex ? selectedImg : normalImg).size({ width: 25, height: 25 })
Text(title).fontColor(this.currentIndex == targetIndex ? '#28bff1' : '#8a8a8a')
}.width('100%').height(50).justifyContent(FlexAlign.Center).onClick(() => {
this.currentIndex = targetIndex;
this.controller.changeIndex(this.currentIndex);
})
}
build() {
Column() {
Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
TabContent() {
Column({ space: 10 }) {
Button('Home')
}
}.tabBar(this.TabBuilder('Home', 0, $r('app.media.icon_home'), $r('app.media.icon_home')))
TabContent() {
Column({ space: 10 }) {
Text(this.title).fontSize(this.titleFontSize).fontWeight(FontWeight.Bold);
if (this.allSpeakerNames.length == 0) {
Text('Please add speakers first')
} else {
List({ space: 10, initialIndex: 0 }) {
ForEach(this.allSpeakerNames, (item: string, index: number) => {
ListItem() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
Text(item)
.width('100%')
.height(80)
.fontSize(20)
.textAlign(TextAlign.Center)
.borderRadius(10)
.flexShrink(1)
Button('Delete')
.width('30%')
.height(40)
.onClick(() => {
if (index != undefined) {
const name = this.allSpeakerNames[index];
console.log(`Deleting speaker ${name}`);
if (this.workerInstance) {
this.workerInstance.postMessage({
msgType: 'manager-delete-speaker',
name: name
});
}
}
}).stateEffect(true)
Text('')
.width('15%')
.height(80)
}
}
}, (item: string) => item)
}
}
}
}.tabBar(this.TabBuilder('View', 1, $r('app.media.icon_view'), $r('app.media.icon_view')))
TabContent() {
Column({ space: 10 }) {
Text(this.title).fontSize(this.titleFontSize).fontWeight(FontWeight.Bold);
Row({space: 10}) {
Text('Speaker name')
TextInput({placeholder: 'Input speaker name'})
.onChange((value: string)=>{
this.inputSpeakerName = value.trim();
});
}.width('100%')
Row({space: 10}) {
Button(this.micBtnCaption)
.onClick(()=> {
if (this.mic) {
if (this.micStarted) {
this.micStarted = false;
this.micBtnCaption = 'Start recording';
this.mic.stop();
this.infoAdd = '';
if (this.sampleList.length > 0) {
this.btnAddEnabled = true;
this.btnSaveAudioEnabled = true;
}
} else {
this.micStarted = true;
this.micBtnCaption = 'Stop recording';
this.sampleList = [];
this.mic.start();
this.infoAdd = '';
this.btnAddEnabled = false;
this.btnSaveAudioEnabled = false;
}
}
})
Button('Add')
.enabled(this.btnAddEnabled)
.onClick(()=>{
if (this.inputSpeakerName.trim() == '') {
this.infoAdd += 'Please input a speaker name first';
return;
}
const samples = flatten(this.sampleList);
console.log(`number of samples: ${samples.length}, ${samples.length / this.sampleRate}`);
})
Button('Save audio')
.enabled(this.btnSaveAudioEnabled)
.onClick(()=>{
if (this.sampleList.length == 0) {
this.btnSaveAudioEnabled = false;
return;
}
const samples = flatten(this.sampleList);
if (samples.length == 0) {
this.btnSaveAudioEnabled = false;
return;
}
let uri: string = '';
const audioOptions = new picker.AudioSaveOptions(); // audioOptions.newFileNames = ['o.wav'];
const audioViewPicker = new picker.AudioViewPicker();
audioViewPicker.save(audioOptions).then((audioSelectResult: Array<string>) => {
uri = audioSelectResult[0];
savePcmToWav(uri, toInt16Samples(samples), this.sampleRate);
console.log(`Saved to ${uri}`);
this.infoAdd += `\nSaved to ${uri}`;
});
})
}
TextArea({text: this.infoAdd})
.height('100%')
.width('100%')
.focusable(false)
}
}.tabBar(this.TabBuilder('Add', 2, $r('app.media.icon_add'), $r('app.media.icon_add')))
TabContent() {
Column({ space: 10 }) {
Text(this.title).fontSize(this.titleFontSize).fontWeight(FontWeight.Bold);
TextArea({
text: `
Everyting is open-sourced.
It runs locally, without accessing the network
See also https://github.com/k2-fsa/sherpa-onnx
新一代 Kaldi QQ 和微信交流群: 请看
https://k2-fsa.github.io/sherpa/social-groups.html
微信公众号: 新一代 Kaldi
`
}).width('100%').height('100%').focusable(false)
}
}.tabBar(this.TabBuilder('Help', 3, $r('app.media.icon_info'), $r('app.media.icon_info')))
}.scrollable(false)
}.width('100%')
}
private micCallback = (buffer: ArrayBuffer) => {
const view: Int16Array = new Int16Array(buffer);
const samplesFloat: Float32Array = new Float32Array(view.length);
for (let i = 0; i < view.length; ++i) {
samplesFloat[i] = view[i] / 32768.0;
}
this.sampleList.push(samplesFloat);
}
}
\ No newline at end of file
... ...
// This file is modified from
// https://gitee.com/ukSir/hmchat2/blob/master/entry/src/main/ets/utils/permissionMananger.ets
import { abilityAccessCtrl, bundleManager, common, Permissions } from '@kit.AbilityKit';
export function allAllowed(permissions: Permissions[]): boolean {
if (permissions.length == 0) {
return false;
}
const mgr: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
const bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
let tokenID: number = bundleInfo.appInfo.accessTokenId;
return permissions.every(permission => abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ==
mgr.checkAccessTokenSync(tokenID, permission));
}
export async function requestPermissions(permissions: Permissions[]): Promise<boolean> {
const mgr: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
const context: Context = getContext() as common.UIAbilityContext;
const result = await mgr.requestPermissionsFromUser(context, permissions);
return result.authResults.length > 0 && result.authResults.every(authResults => authResults == 0);
}
\ No newline at end of file
... ...
import worker, { ThreadWorkerGlobalScope, MessageEvents, ErrorEvent } from '@ohos.worker';
import {
readWaveFromBinary,
Samples,
SpeakerEmbeddingExtractor,
SpeakerEmbeddingExtractorConfig,
SpeakerEmbeddingManager
} from 'sherpa_onnx';
import { fileIo } from '@kit.CoreFileKit';
const workerPort: ThreadWorkerGlobalScope = worker.workerPort;
let extractor: SpeakerEmbeddingExtractor;
let manager: SpeakerEmbeddingManager;
function readWaveFromRawfile(filename: string, context: Context): Samples {
const data: Uint8Array = context.resourceManager.getRawFileContentSync(filename);
return readWaveFromBinary(data) as Samples;
}
function initExtractor(context: Context): SpeakerEmbeddingExtractor {
const config = new SpeakerEmbeddingExtractorConfig();
config.model = '3dspeaker_speech_eres2net_base_sv_zh-cn_3dspeaker_16k.onnx';
config.numThreads = 2;
config.debug = true;
return new SpeakerEmbeddingExtractor(config, context.resourceManager);
}
function extractEmbedding(samples: Samples): Float32Array {
const stream = extractor.createStream();
stream.acceptWaveform(samples);
return extractor.compute(stream);
}
/**
* Defines the event handler to be called when the worker thread receives a message sent by the host thread.
* The event handler is executed in the worker thread.
*
* @param e message data
*/
workerPort.onmessage = (e: MessageEvents) => {
const msgType = e.data['msgType'] as string;
console.log(`from the main thread, msg-type: ${msgType}`);
if (msgType == 'init-extractor' && !extractor) {
const context: Context = e.data['context'] as Context;
extractor = initExtractor(context);
manager = new SpeakerEmbeddingManager(extractor.dim);
const filename1 = 'sr-data/enroll/fangjun-sr-1.wav';
const samples1 = readWaveFromRawfile(filename1, context);
console.log(`sample rate: ${samples1.sampleRate}`);
let ok = manager.add({ name: 'fangjun0', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun1', v: extractEmbedding(samples1) });
/*
ok = manager.add({ name: 'fangjun2', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun3', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun4', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun5', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun6', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun7', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun8', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun9', v: extractEmbedding(samples1) });
ok = manager.add({ name: 'fangjun10', v: extractEmbedding(samples1) });
*/
if (ok) {
console.log(`Added fangjun`);
let n = manager.getNumSpeakers();
console.log(`number of speakers: ${n}`);
console.log(`speaker names: ${manager.getAllSpeakerNames().join('\n')}`);
}
workerPort.postMessage({
msgType: 'manager-all-speaker-names', allSpeakers: manager.getAllSpeakerNames(),
});
}
if (msgType == 'manager-delete-speaker') {
const name = e.data['name'] as string;
const ok = manager.remove(name);
if (ok) {
console.log(`Removed ${name}.`);
console.log(`Number of speakers: ${manager.getNumSpeakers()}`);
console.log(`Number of speakers2: ${manager.getAllSpeakerNames().length}`);
console.log(JSON.stringify(manager.getAllSpeakerNames()));
workerPort.postMessage({
msgType: 'manager-all-speaker-names', allSpeakers: manager.getAllSpeakerNames(),
});
}
}
}
/**
* Defines the event handler to be called when the worker receives a message that cannot be deserialized.
* The event handler is executed in the worker thread.
*
* @param e message data
*/
workerPort.onmessageerror = (e: MessageEvents) => {
}
/**
* Defines the event handler to be called when an exception occurs during worker execution.
* The event handler is executed in the worker thread.
*
* @param e error message
*/
workerPort.onerror = (e: ErrorEvent) => {
}
\ No newline at end of file
... ...
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:layered_image",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:startIcon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "EntryBackupAbility",
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
"type": "backup",
"exported": false,
"metadata": [
{
"name": "ohos.extension.backup",
"resource": "$profile:backup_config"
}
],
}
],
"requestPermissions": [
{
"name": "ohos.permission.MICROPHONE",
"reason": "$string:mic_reason",
"usedScene": {
"abilities": [
"EntryAbility",
],
"when": "inuse",
}
}
]
}
}
\ No newline at end of file
... ...
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
... ...
{
"string": [
{
"name": "module_desc",
"value": "On-device speaker identification with Next-gen Kaldi"
},
{
"name": "EntryAbility_desc",
"value": "On-device speaker identification with Next-gen Kaldi"
},
{
"name": "EntryAbility_label",
"value": "Speaker identification"
},
{
"name": "mic_reason",
"value": "access the microphone for on-device speaker identification with Next-gen Kaldi"
}
]
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24" version="1.1">
<!-- Generator: Sketch 63.1 (92452) - https://sketch.com -->
<title>Public/ic_public_list_add_light</title>
<desc>Created with Sketch.</desc>
<g id="_Public/ic_public_list_add_light" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M12,1 C18.0751322,1 23,5.92486775 23,12 C23,18.0751322 18.0751322,23 12,23 C5.92486775,23 1,18.0751322 1,12 C1,5.92486775 5.92486775,1 12,1 Z" id="_椭圆形" fill="#0A59F7"/>
<path d="M12.75,17.25 C12.75,17.6642136 12.4142136,18 12,18 C11.5857864,18 11.25,17.6642136 11.25,17.25 L11.25,12.749 L6.75,12.75 C6.33578644,12.75 6,12.4142136 6,12 C6,11.5857864 6.33578644,11.25 6.75,11.25 L11.25,11.249 L11.25,6.75 C11.25,6.33578644 11.5857864,6 12,6 C12.4142136,6 12.75,6.33578644 12.75,6.75 L12.75,17.25 Z M13.75,11.25 L17.25,11.25 C17.6642136,11.25 18,11.5857864 18,12 C18,12.4142136 17.6642136,12.75 17.25,12.75 L13.75,12.75 L13.75,11.25 Z" id="_形状" fill="#FFFFFF"/>
</g>
</svg>
\ No newline at end of file
... ...
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960"><path d="m480-840 440 330-48 64-72-54v380H160v-380l-72 54-48-64zM294-478q0 53 57 113t129 125q72-65 129-125t57-113q0-44-30-73t-72-29q-26 0-47.5 10.5T480-542q-15-17-37.5-27.5T396-580q-42 0-72 29t-30 73m426 278v-360L480-740 240-560v360zm0 0H240z"/></svg>
\ No newline at end of file
... ...
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960"><path d="M440-280h80v-240h-80zm40-320q17 0 28.5-11.5T520-640t-11.5-28.5T480-680t-28.5 11.5T440-640t11.5 28.5T480-600m0 520q-83 0-156-31.5T197-197t-85.5-127T80-480t31.5-156T197-763t127-85.5T480-880t156 31.5T763-763t85.5 127T880-480t-31.5 156T763-197t-127 85.5T480-80m0-80q134 0 227-93t93-227-93-227-227-93-227 93-93 227 93 227 227 93m0-320"/></svg>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24" version="1.1">
<title>Public/ic_public_view_list_filled</title>
<defs>
<path d="M3.75,17.25 C4.44035594,17.25 5,17.8096441 5,18.5 C5,19.1903559 4.44035594,19.75 3.75,19.75 C3.05964406,19.75 2.5,19.1903559 2.5,18.5 C2.5,17.8096441 3.05964406,17.25 3.75,17.25 Z M21,17.5 C21.5522847,17.5 22,17.9477153 22,18.5 C22,19.0522847 21.5522847,19.5 21,19.5 L8,19.5 C7.44771525,19.5 7,19.0522847 7,18.5 C7,17.9477153 7.44771525,17.5 8,17.5 L21,17.5 Z M3.75,10.75 C4.44035594,10.75 5,11.3096441 5,12 C5,12.6903559 4.44035594,13.25 3.75,13.25 C3.05964406,13.25 2.5,12.6903559 2.5,12 C2.5,11.3096441 3.05964406,10.75 3.75,10.75 Z M21,11 C21.5522847,11 22,11.4477153 22,12 C22,12.5522847 21.5522847,13 21,13 L8,13 C7.44771525,13 7,12.5522847 7,12 C7,11.4477153 7.44771525,11 8,11 L21,11 Z M3.75,4.25 C4.44035594,4.25 5,4.80964406 5,5.5 C5,6.19035594 4.44035594,6.75 3.75,6.75 C3.05964406,6.75 2.5,6.19035594 2.5,5.5 C2.5,4.80964406 3.05964406,4.25 3.75,4.25 Z M21,4.5 C21.5522847,4.5 22,4.94771525 22,5.5 C22,6.05228475 21.5522847,6.5 21,6.5 L8,6.5 C7.44771525,6.5 7,6.05228475 7,5.5 C7,4.94771525 7.44771525,4.5 8,4.5 L21,4.5 Z" id="_path-1"/>
</defs>
<g id="_Public/ic_public_view_list_filled" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="_mask-2" fill="white">
<use xlink:href="#_path-1"/>
</mask>
<use id="_形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#_path-1"/>
</g>
</svg>
\ No newline at end of file
... ...
{
"layered-image":
{
"background" : "$media:background",
"foreground" : "$media:foreground"
}
}
\ No newline at end of file
... ...
{
"allowToBackupRestore": true
}
\ No newline at end of file
... ...
{
"string": [
{
"name": "module_desc",
"value": "On-device speaker identification with Next-gen Kaldi"
},
{
"name": "EntryAbility_desc",
"value": "On-device speaker identification with Next-gen Kaldi"
},
{
"name": "EntryAbility_label",
"value": "Speaker identification"
},
{
"name": "mic_reason",
"value": "access the microphone for on-device speaker identification with Next-gen Kaldi"
}
]
}
\ No newline at end of file
... ...
{
"string": [
{
"name": "module_desc",
"value": "新一代Kaldi: 本地说话人识别"
},
{
"name": "EntryAbility_desc",
"value": "新一代Kaldi: 本地说话人识别"
},
{
"name": "EntryAbility_label",
"value": "说话人识别"
},
{
"name": "mic_reason",
"value": "使用新一代Kaldi, 访问麦克风进行本地说话人识别 (不需要联网)"
}
]
}
\ No newline at end of file
... ...
import hilog from '@ohos.hilog';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function abilityTest() {
describe('ActsAbilityTest', () => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
})
})
}
\ No newline at end of file
... ...
import abilityTest from './Ability.test';
export default function testsuite() {
abilityTest();
}
\ No newline at end of file
... ...
{
"module": {
"name": "entry_test",
"type": "feature",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
"deliveryWithInstall": true,
"installationFree": false
}
}
... ...
import localUnitTest from './LocalUnit.test';
export default function testsuite() {
localUnitTest();
}
\ No newline at end of file
... ...
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function localUnitTest() {
describe('localUnitTest', () => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
});
});
}
\ No newline at end of file
... ...
{
"modelVersion": "5.0.0",
"dependencies": {
},
"execution": {
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
},
"logging": {
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
},
"debugging": {
// "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
},
"nodeOptions": {
// "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
// "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
}
}
... ...
import { appTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
... ...
{
"meta": {
"stableOrder": true
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19"
},
"packages": {
"@ohos/hypium@1.0.19": {
"name": "@ohos/hypium",
"version": "1.0.19",
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==",
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har",
"registryType": "ohpm"
}
}
}
\ No newline at end of file
... ...
{
"modelVersion": "5.0.0",
"description": "Please describe the basic information.",
"dependencies": {
},
"devDependencies": {
"@ohos/hypium": "1.0.19"
}
}
... ...
... ... @@ -14,7 +14,7 @@
},
{
"name": "mic_reason",
"value": "access the microhone for on-device real-time speech recognition with Next-gen Kaldi"
"value": "access the microphone for on-device real-time speech recognition with Next-gen Kaldi"
}
]
}
\ No newline at end of file
}
... ...
... ... @@ -14,7 +14,7 @@
},
{
"name": "mic_reason",
"value": "access the microhone for on-device real-time speech recognition with Next-gen Kaldi"
"value": "access the microphone for on-device real-time speech recognition with Next-gen Kaldi"
}
]
}
\ No newline at end of file
}
... ...
... ... @@ -14,7 +14,7 @@
},
{
"name": "mic_reason",
"value": "access the microhone for on-device speech recognition with Next-gen Kaldi"
"value": "access the microphone for on-device speech recognition with Next-gen Kaldi"
}
]
}
\ No newline at end of file
}
... ...
... ... @@ -14,7 +14,7 @@
},
{
"name": "mic_reason",
"value": "access the microhone for on-device speech recognition with Next-gen Kaldi"
"value": "access the microphone for on-device speech recognition with Next-gen Kaldi"
}
]
}
\ No newline at end of file
}
... ...