harmony 鸿蒙@ohos.ai.intelligentVoice (Intelligent Voice)

2023-10-30 浏览 (571)

@ohos.ai.intelligentVoice (Intelligent Voice)

The intelligentVoice module provides the intelligent voice enrollment and voice wakeup functions.

Its functions are implemented by:

  • IntelligentVoiceManager: intelligent voice manager class, which declares the functions provided by the module. Currently, voice enrollment and voice wakeup are supported. Before developing intelligent voice functions, call getIntelligentVoiceManager() to check whether they are supported.
  • EnrollIntelligentVoiceEngine: class that implements voice enrollment. You need to perform voice enrollment before using voice wakeup.
  • WakeupIntelligentVoiceEngine: class that implements voice wakeup. You need to perform voice enrollment before using voice wakeup.

NOTE

  • The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.

  • The APIs provided by this module are system APIs.

Modules to Import

import intelligentVoice from '@ohos.ai.intelligentVoice';

intelligentVoice.getIntelligentVoiceManager

getIntelligentVoiceManager(): IntelligentVoiceManager

Obtains an instance of the intelligent voice manager.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
IntelligentVoiceManagerInstance of the intelligent voice manager.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700101No memory.

Example

import { BusinessError } from '@ohos.base';

let intelligentVoiceManager: intelligentVoice.IntelligentVoiceManager|null = null;
try {
  intelligentVoiceManager = intelligentVoice.getIntelligentVoiceManager();
} catch (err) {
  let error = err as BusinessError;
  console.error(`Get IntelligentVoiceManager failed. Code:${error.code}, message:${error.message}`);
}

intelligentVoice.createEnrollIntelligentVoiceEngine

createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor, callback: AsyncCallback<EnrollIntelligentVoiceEngine>): void

Creates an instance of the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
descriptorEnrollIntelligentVoiceEngineDescriptorYesDescriptor of the intelligent voice enrollment engine.
callbackAsyncCallback<EnrollIntelligentVoiceEngine>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700101No memory.
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let engineDescriptor: intelligentVoice.EnrollIntelligentVoiceEngineDescriptor = {
  wakeupPhrase: 'Xiaohua Xiaohua',
}
let enrollIntelligentVoiceEngine: intelligentVoice.EnrollIntelligentVoiceEngine|null = null;
intelligentVoice.createEnrollIntelligentVoiceEngine(engineDescriptor, (err: BusinessError, data: intelligentVoice.EnrollIntelligentVoiceEngine) => {
  if (err) {
    console.error(`Failed to create enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
  } else {
    console.info(`Succeeded in creating enrollIntelligentVoice engine.`);
    enrollIntelligentVoiceEngine = data;
  }
});

intelligentVoice.createEnrollIntelligentVoiceEngine

createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor): Promise<EnrollIntelligentVoiceEngine>

Creates an instance of the intelligent voice enrollment engine. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
descriptorEnrollIntelligentVoiceEngineDescriptorYesDescriptor of the intelligent voice enrollment engine.

Return value

TypeDescription
Promise<EnrollIntelligentVoiceEngine>Promise used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700101No memory.
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let engineDescriptor: intelligentVoice.EnrollIntelligentVoiceEngineDescriptor = {
  wakeupPhrase:'Xiaohua Xiaohua',
}
let enrollIntelligentVoiceEngine: intelligentVoice.EnrollIntelligentVoiceEngine|null = null;
intelligentVoice.createEnrollIntelligentVoiceEngine(engineDescriptor).then((data: intelligentVoice.EnrollIntelligentVoiceEngine) => {
  enrollIntelligentVoiceEngine = data;
  console.info(`Succeeded in creating enrollIntelligentVoice engine.`);
}).catch((err: BusinessError) => {
  console.error(`Failed to create enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
});

intelligentVoice.createWakeupIntelligentVoiceEngine

createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor, callback: AsyncCallback<WakeupIntelligentVoiceEngine>): void

Creates an instance of the intelligent voice wakeup engine. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
descriptorWakeupIntelligentVoiceEngineDescriptorYesDescriptor of the intelligent voice wakeup engine.
callbackAsyncCallback<WakeupIntelligentVoiceEngine>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700101No memory.
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let wakeupEngineDescriptor: intelligentVoice.WakeupIntelligentVoiceEngineDescriptor = {
  needReconfirm: true,
  wakeupPhrase: 'Xiaohua Xiaohua',
}
let wakeupIntelligentVoiceEngine: intelligentVoice.WakeupIntelligentVoiceEngine|null = null;
intelligentVoice.createWakeupIntelligentVoiceEngine(wakeupEngineDescriptor, (err: BusinessError, data: intelligentVoice.WakeupIntelligentVoiceEngine) => {
  if (err) {
    console.error(`Failed to create wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
  } else {
    console.info(`Succeeded in creating wakeupIntelligentVoice engine.`);
    wakeupIntelligentVoiceEngine = data;
  }
});

intelligentVoice.createWakeupIntelligentVoiceEngine

createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor): Promise<WakeupIntelligentVoiceEngine>

Creates an instance of the intelligent voice wakeup engine. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
descriptorWakeupIntelligentVoiceEngineDescriptorYesDescriptor of the intelligent voice wakeup engine.

Return value

TypeDescription
Promise<WakeupIntelligentVoiceEngine>Promise used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700101No memory.
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let wakeupEngineDescriptor: intelligentVoice.WakeupIntelligentVoiceEngineDescriptor = {
  needReconfirm: true,
  wakeupPhrase: 'Xiaohua Xiaohua',
}
let wakeupIntelligentVoiceEngine: intelligentVoice.WakeupIntelligentVoiceEngine|null = null;
intelligentVoice.createWakeupIntelligentVoiceEngine(wakeupEngineDescriptor).then((data: intelligentVoice.WakeupIntelligentVoiceEngine) => {
  wakeupIntelligentVoiceEngine = data;
  console.info(`Succeeded in creating wakeupIntelligentVoice engine.`);
}).catch((err: BusinessError) => {
  console.error(`Failed to create wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
});

IntelligentVoiceManager

Class that implements intelligent voice management. Before use, you need to call getIntelligentVoiceManager() to obtain an IntelligentVoiceManager object.

getCapabilityInfo

getCapabilityInfo(): Array<IntelligentVoiceEngineType>

Obtains the list of supported intelligent voice engine types.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Array<IntelligentVoiceEngineType>Array of supported intelligent voice engine types.

Example

if (intelligentVoiceManager != null) {
  let info = intelligentVoiceManager.getCapabilityInfo();
}

on('serviceChange')

on(type: 'serviceChange', callback: Callback<ServiceChangeType>): void

Subscribes to service change events. A callback is invoked when the status of the intelligent voice service changes.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
typestringYesEvent type. This field has a fixed value of serviceChange.
callbackCallback<ServiceChangeType>YesCallback for the service status change.

Example

if (intelligentVoiceManager != null) {
  intelligentVoiceManager.on('serviceChange', (serviceChangeType: intelligentVoice.ServiceChangeType) => {});
}

off('serviceChange')

off(type: 'serviceChange', callback?: Callback<ServiceChangeType>): void

Unsubscribes from service change events.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
typestringYesEvent type. This field has a fixed value of serviceChange.
callbackCallback<ServiceChangeType>NoCallback for processing of the service status change event. If this parameter is specified, only the specified callback will be unsubscribed. Otherwise, all callbacks will be unsubscribed.

Example

if (intelligentVoiceManager != null) {
  intelligentVoiceManager.off('serviceChange');
}

ServiceChangeType

Enumerates service status change types.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameValueDescription
SERVICE_UNAVAILABLE0The service is unavailable.

IntelligentVoiceEngineType

Enumerates intelligent voice engine types.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameValueDescription
ENROLL_ENGINE_TYPE0Voice enrollment engine.
WAKEUP_ENGINE_TYPE1Voice wakeup engine.
UPDATE_ENGINE_TYPE2Silent update engine.

EnrollIntelligentVoiceEngineDescriptor

Defines the descriptor of an intelligent voice enrollment engine.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
wakeupPhrasestringYesWakeup phrase.

WakeupIntelligentVoiceEngineDescriptor

Defines the descriptor of an intelligent voice wakeup engine.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
needReconfirmbooleanYesWhether re-confirmation of the wakeup result is needed. The value true indicates that re-confirmation is needed, and the value false indicates the opposite.
wakeupPhrasestringYesWakeup phrase.

EnrollEngineConfig

Defines the enrollment engine configuration.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
languagestringYesLanguage supported by the enrollment engine. Only Chinese is supported currently, and the value is zh.
regionstringYesCountry/region supported by the enrollment engine. Only China is supported currently, and the value is CN.

SensibilityType

Enumerates wakeup sensibility types. A sensibility type maps to a wakeup threshold. A higher sensibility indicates a lower threshold and a higher wakeup probability.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameValueDescription
LOW_SENSIBILITY1Low sensibility.
MIDDLE_SENSIBILITY2Medium sensibility.
HIGH_SENSIBILITY3High sensibility.

WakeupHapInfo

Defines the HAP information for an wakeup application.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
bundleNamestringYesBundle name of the wakeup application.
abilityNamestringYesAbility name of the wakeup application.

WakeupIntelligentVoiceEventType

Enumerates types of intelligent voice wakeup events.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameValueDescription
INTELLIGENT_VOICE_EVENT_WAKEUP_NONE0No wakeup.
INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE1Wakeup recognition completed.

IntelligentVoiceErrorCode

Enumerates error codes of intelligent voice wakeup.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameValueDescription
INTELLIGENT_VOICE_NO_MEMORY22700101Insufficient memory.
INTELLIGENT_VOICE_INVALID_PARAM22700102Invalid parameter.
INTELLIGENT_VOICE_INIT_FAILED22700103Enrollment failed.
INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED22700104Enrollment commit failed.

EnrollResult

Enumerates enrollment results.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameValueDescription
SUCCESS0Enrollment succeeded.
VPR_TRAIN_FAILED-1Voiceprint training failed.
WAKEUP_PHRASE_NOT_MATCH-2Wakeup phrase mismatched.
TOO_NOISY-3Environment too noisy.
TOO_LOUD-4Voice too loud.
INTERVAL_LARGE-5Interval between wakeup phrases too long.
DIFFERENT_PERSON-6Wakeup phrases enrolled by different persons.
UNKNOWN_ERROR-100Unknown error.

EnrollCallbackInfo

Defines the enrollment callback information.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
resultEnrollResultYesEnrollment result.
contextstringYesContext of the enrollment event.

WakeupIntelligentVoiceEngineCallbackInfo

Defines the callback information for the intelligent voice wakeup engine.

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
eventIdWakeupIntelligentVoiceEventTypeYesEvent type of the intelligent voice wakeup engine.
isSuccessbooleanYesWakeup result. The value true indicates that the wakeup is successful, and the value false indicates the opposite.
contextstringYesContext of the wakeup event.

EnrollIntelligentVoiceEngine

Class that implements the intelligent voice enrollment engine. Before use, you need to call createEnrollIntelligentVoiceEngine() to obtain an instance of the intelligent voice enrollment engine.

getSupportedRegions

getSupportedRegions(callback: AsyncCallback<Array<string>>): void

Obtains the list of supported countries/regions. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<Array<string>>YesCallback used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is CN.

Example

import { BusinessError } from '@ohos.base';

let regions: Array<string>|null = null;
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getSupportedRegions((err: BusinessError, data: Array<string>) => {
    if (err) {
      console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
    } else {
      regions = data;
      console.info(`Succeeded in getting supported regions, regions:${regions}.`);
    }
  });
}

getSupportedRegions

getSupportedRegions(): Promise<Array<string>>

Obtains the list of supported countries/regions. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Promise<Array<string>>Promise used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is CN.

Example

import { BusinessError } from '@ohos.base';

let regions: Array<string>|null = null;
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getSupportedRegions().then((data: Array<string>) => {
    regions = data;
    console.info('Succeeded in getting supported regions, regions:${regions}.');
  }).catch((err: BusinessError) => {
    console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
  });
}

init

init(config: EnrollEngineConfig, callback: AsyncCallback<void>): void

Initializes the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
configEnrollEngineConfigYesConfiguration of the intelligent voice enrollment engine.
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.
22700103Init failed.

Example

import { BusinessError } from '@ohos.base';

let config: intelligentVoice.EnrollEngineConfig = {
  language: 'zh',
  region: 'CN',
}
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).init(config, (err: BusinessError) => {
    if (err) {
      console.error(`Failed to initialize enrollIntelligentVoice engine. Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in initialzing enrollIntelligentVoice engine.`);
    }
  });
}

init

init(config: EnrollEngineConfig): Promise<void>

Initializes the intelligent voice enrollment engine. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
configEnrollEngineConfigYesConfiguration of the intelligent voice enrollment engine.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.
22700103Init failed.

Example

import { BusinessError } from '@ohos.base';

let config: intelligentVoice.EnrollEngineConfig = {
  language: 'zh',
  region: 'CN',
}
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).init(config).then(() => {
    console.info(`Succeeded in initializing enrollIntelligentVoice engine.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to initialize enrollIntelligentVoice engine. Code:${err.code}, message:${err.message}`);
  });
}

enrollForResult

enrollForResult(isLast: boolean, callback: AsyncCallback<EnrollCallbackInfo>): void

Obtains the enrollment result. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
isLastbooleanYesWhether this is the last enrollment. The value value indicates the last enrollment, and the value false indicates the opposite.
callbackAsyncCallback<EnrollCallbackInfo>YesCallback used to return the result.

Example

import { BusinessError } from '@ohos.base';

let callbackInfo: intelligentVoice.EnrollCallbackInfo|null = null;
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).enrollForResult(true, (err: BusinessError, data: intelligentVoice.EnrollCallbackInfo) => {
    if (err) {
      console.error(`Failed to enroll for result, Code:${err.code}, message:${err.message}`);
    } else {
      callbackInfo = data;
      console.info(`Succeeded in enrolling for result, info:${callbackInfo}.`);
    }
  });
}

enrollForResult

enrollForResult(isLast: boolean): Promise<EnrollCallbackInfo>

Obtains the enrollment result. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
isLastbooleanYesWhether this is the last enrollment. The value value indicates the last enrollment, and the value false indicates the opposite.

Return value

TypeDescription
Promise<EnrollCallbackInfo>Promise used to return the result.

Example

import { BusinessError } from '@ohos.base';

let callbackInfo: intelligentVoice.EnrollCallbackInfo|null = null;
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).enrollForResult(true).then((data: intelligentVoice.EnrollCallbackInfo) => {
    callbackInfo = data;
    console.info(`Succeeded in enrolling for result, info:${callbackInfo}.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to enroll for result, Code:${err.code}, message:${err.message}`);
  });
}

stop

stop(callback: AsyncCallback<void>): void

Stops the enrollment. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
callbackAsyncCallback<void>YesCallback used to return the result.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).stop((err: BusinessError) => {
    if (err) {
      console.error(`Failed to stop enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in stopping enrollIntelligentVoice engine.`);
    }
  });
}

stop

stop(): Promise<void>

Stops the enrollment. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Promise<void>Promise that returns no value.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).stop().then(() => {
    console.info(`Succeeded in stopping enrollIntelligentVoice engine.`);
  }).catch((err:BusinessError) => {
    console.error(`Failed to stop enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
  });
}

commit

commit(callback: AsyncCallback<void>): void

Commits the enrollment. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700104Commit enroll failed.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).commit((err: BusinessError) => {
    if (err) {
      console.error(`Failed to commit enroll, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in committing enroll.`);
    }
  });
}

commit

commit(): Promise<void>

Commits the enrollment. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700104Commit enroll failed.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).commit().then(() => {
    console.info(`Succeeded in committing enroll.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to commit enroll, Code:${err.code}, message:${err.message}`);
  });
}

setWakeupHapInfo

setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback<void>): void

Sets the HAP information for the wakeup application. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
infoWakeupHapInfoYesHAP information for the wakeup application.
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let info: intelligentVoice.WakeupHapInfo = {
  bundleName: 'com.wakeup',
  abilityName: 'WakeUpExtAbility',
}
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setWakeupHapInfo(info, (err: BusinessError) => {
    if (err) {
      console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in setting wakeup hap info.`);
    }
  });
}

setWakeupHapInfo

setWakeupHapInfo(info: WakeupHapInfo): Promise<void>

Sets the HAP information for the wakeup application. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let info: intelligentVoice.WakeupHapInfo = {
  bundleName: 'com.wakeup',
  abilityName: 'WakeUpExtAbility',
}
if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setWakeupHapInfo(info).then(() => {
    console.info(`Succeeded in setting wakeup hap info.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
  });
}

setSensibility

setSensibility(sensibility: SensibilityType, callback: AsyncCallback<void>): void

Sets the wakeup sensibility. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
sensibilitySensibilityTypeYesSensibility type.
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY, (err: BusinessError) => {
    if (err) {
      console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in setting sensibility.`);
    }
  });
}

setSensibility

setSensibility(sensibility: SensibilityType): Promise<void>

Sets the wakeup sensibility. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
sensibilitySensibilityTypeYesSensibility type.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY).then(() => {
    console.info(`Succeeded in setting sensibility.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
  });
}

setParameter

setParameter(key: string, value: string, callback: AsyncCallback<void>): void

Sets specified intelligent voice parameters. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.
valuestringYesValue.
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setParameter('scene', '0', (err: BusinessError) => {
    if (err) {
      console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in setting parameter`);
    }
  });
}

setParameter

setParameter(key: string, value: string): Promise<void>

Sets specified intelligent voice parameters. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.
valuestringYesValue.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setParameter('scene', '0').then(() => {
    console.info(`Succeeded in setting parameter`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
  });
}

getParameter

getParameter(key: string, callback: AsyncCallback<string>): void

Obtains specified intelligent voice parameters. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.
callbackAsyncCallback<string>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getParameter('key', (err: BusinessError, data: string) => {
    if (err) {
      console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
    } else {
      let param: string = data;
      console.info(`Succeeded in getting parameter, param:${param}`);
    }
  });
}

getParameter

getParameter(key: string): Promise<string>

Obtains specified intelligent voice parameters. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.

Return value

TypeDescription
Promise<string>Promise used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getParameter('key').then((data: string) => {
    let param: string = data;
    console.info(`Succeeded in getting parameter, param:${param}`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
  });
}

release

release(callback: AsyncCallback<void>): void

Releases the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<void>YesCallback used to return the result.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).release((err: BusinessError) => {
    if (err) {
      console.error(`Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in releasing enrollIntelligentVoice engine.`);
    }
  });
}

release

release(): Promise<void>

Releases the intelligent voice enrollment engine. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Promise<void>Promise that returns no value.

Example

import { BusinessError } from '@ohos.base';

if (enrollIntelligentVoiceEngine != null) {
  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).release().then(() => {
    console.info(`Succeeded in releasing enrollIntelligentVoice engine.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
  });
}

WakeupIntelligentVoiceEngine

Class that implements the intelligent voice wakeup engine. Before use, you need to call createWakeupIntelligentVoiceEngine() to obtain an instance of the intelligent voice wakeup engine.

getSupportedRegions

getSupportedRegions(callback: AsyncCallback<Array<string>>): void

Obtains the list of supported countries/regions. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

NameTypeMandatoryDescription
callbackAsyncCallback<Array<string>>YesCallback used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is CN.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getSupportedRegions((err: BusinessError, data: Array<string>) => {
    if (err) {
      console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
    } else {
      let regions: Array<string> = data;
      console.info(`Succeeded in getting supported regions, regions:${regions}.`);
    }
  });
}

getSupportedRegions

getSupportedRegions(): Promise<Array<string>>

Obtains the list of supported countries/regions. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Promise<Array<string>>Promise used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is CN.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getSupportedRegions().then((data: Array<string>) => {
    let regions: Array<string> = data;
    console.info(`Succeeded in getting supported regions, regions:${regions}.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
  });
}

setWakeupHapInfo

setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback<void>): void

Sets the HAP information for the wakeup application. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
infoWakeupHapInfoYesHAP information for the wakeup application.
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let hapInfo: intelligentVoice.WakeupHapInfo = {
  bundleName: 'com.wakeup',
  abilityName: 'WakeUpExtAbility',
}

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setWakeupHapInfo(hapInfo, (err: BusinessError) => {
    if (err) {
      console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in setting wakeup hap info.`);
    }
  });
}

setWakeupHapInfo

setWakeupHapInfo(info: WakeupHapInfo): Promise<void>

Sets the HAP information for the wakeup application. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
infoWakeupHapInfoYesHAP information for the wakeup application.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

let hapInfo: intelligentVoice.WakeupHapInfo = {
  bundleName: 'com.wakeup',
  abilityName: 'WakeUpExtAbility',
}
if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setWakeupHapInfo(hapInfo).then(() => {
    console.info(`Succeeded in setting wakeup hap info.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
  });
}

setSensibility

setSensibility(sensibility: SensibilityType, callback: AsyncCallback<void>): void

Sets the wakeup sensibility. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
sensibilitySensibilityTypeYesSensibility type.
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY, (err: BusinessError) => {
    if (err) {
      console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in setting sensibility.`);
    }
  });
}

setSensibility

setSensibility(sensibility: SensibilityType): Promise<void>

Sets the wakeup sensibility. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
sensibilitySensibilityTypeYesSensibility type.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY).then(() => {
    console.info(`Succeeded in setting sensibility.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
  });
}

setParameter

setParameter(key: string, value: string, callback: AsyncCallback<void>): void

Sets specified intelligent voice parameters. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.
valuestringYesValue.
callbackAsyncCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setParameter('scene', '0', (err: BusinessError) => {
    if (err) {
      console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in setting parameter`);
    }
  });
}

setParameter

setParameter(key: string, value: string): Promise<void>

Sets specified intelligent voice parameters. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.
valuestringYesValue.

Return value

TypeDescription
Promise<void>Promise that returns no value.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setParameter('scene', '0').then(() => {
    console.info(`Succeeded in setting parameter`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
  });
}

getParameter

getParameter(key: string, callback: AsyncCallback<string>): void

Obtains specified intelligent voice parameters. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.
callbackAsyncCallback<string>YesCallback used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getParameter('key', (err: BusinessError, data: string) => {
    if (err) {
      console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
    } else {
      let param: string = data;
      console.info(`Succeeded in getting parameter, param:${param}`);
    }
  });
}

getParameter

getParameter(key: string): Promise<string>

Obtains specified intelligent voice parameters. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
keystringYesKey.

Return value

TypeDescription
Promise<string>Promise used to return the result.

Error codes

For details about the error codes, see Intelligent Voice Error Codes.

IDError Message
22700102Input parameter value error.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getParameter('key').then((data: string) => {
    let param: string = data;
    console.info(`Succeeded in getting parameter, param:${param}`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
  });
}

release

release(callback: AsyncCallback<void>): void

Releases the intelligent voice wakeup engine. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
callbackAsyncCallback<void>YesCallback used to return the result.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).release((err: BusinessError) => {
    if (err) {
      console.error(`Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
    } else {
      console.info(`Succeeded in releasing wakeupIntelligentVoice engine.`);
    }
  });
}

release

release(): Promise<void>

Releases the intelligent voice wakeup engine. This API uses a promise to return the result.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Return value

TypeDescription
Promise<void>Promise that returns no value.

Example

import { BusinessError } from '@ohos.base';

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).release().then(() => {
    console.info(`Succeeded in releasing wakeupIntelligentVoice engine.`);
  }).catch((err: BusinessError) => {
    console.error(`Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
  });
}

on

on(type: 'wakeupIntelligentVoiceEvent', callback: Callback<WakeupIntelligentVoiceEngineCallbackInfo>): void

Subscribes to wakeup events.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
typestringYesEvent type. This field has a fixed value of wakeupIntelligentVoiceEvent.
callbackCallback<WakeupIntelligentVoiceEngineCallbackInfo>YesProcessing of the wakeup event.

Example

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).on('wakeupIntelligentVoiceEvent',
    (info: intelligentVoice.WakeupIntelligentVoiceEngineCallbackInfo) => {
    let callbackInfo: intelligentVoice.WakeupIntelligentVoiceEngineCallbackInfo = info;
    console.info(`wakeup intelligentvoice event, info:${callbackInfo}`);
  });
}

off

off(type: 'wakeupIntelligentVoiceEvent', callback?: Callback<WakeupIntelligentVoiceEngineCallbackInfo>): void;

Unsubscribes from wakeup events.

Required permissions: ohos.permission.MANAGE_INTELLIGENT_VOICE

System capability: SystemCapability.AI.IntelligentVoice.Core

Parameters

NameTypeMandatoryDescription
typestringYesEvent type. This field has a fixed value of wakeupIntelligentVoiceEvent.
callbackCallback<WakeupIntelligentVoiceEngineCallbackInfo>NoCallback for processing of the wakeup event. If this parameter is specified, only the specified callback will be unsubscribed. Otherwise, all callbacks will be unsubscribed.

Example

if (wakeupIntelligentVoiceEngine != null) {
  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).off('wakeupIntelligentVoiceEvent');
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/02818d27f13e4e59bb1768f6e155219e