• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.ai.intelligentVoice (Intelligent Voice)
2
3The **intelligentVoice** module provides the intelligent voice enrollment and voice wakeup functions.
4
5Its functions are implemented by:
6
7- [IntelligentVoiceManager](#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()](#intelligentvoicegetintelligentvoicemanager) to check whether they are supported.
8- [EnrollIntelligentVoiceEngine](#enrollintelligentvoiceengine): class that implements voice enrollment. You need to perform voice enrollment before using voice wakeup.
9- [WakeupIntelligentVoiceEngine](#wakeupintelligentvoiceengine): class that implements voice wakeup. You need to perform voice enrollment before using voice wakeup.
10
11> **NOTE**
12>
13> - 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.
14>
15> - The APIs provided by this module are system APIs.
16
17## Modules to Import
18```ts
19import intelligentVoice from '@ohos.ai.intelligentVoice';
20```
21
22## intelligentVoice.getIntelligentVoiceManager
23
24getIntelligentVoiceManager(): IntelligentVoiceManager
25
26Obtains an instance of the intelligent voice manager.
27
28**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
29
30**System capability**: SystemCapability.AI.IntelligentVoice.Core
31
32**Return value**
33
34| Type                         | Description        |
35| ----------------------------- | ------------ |
36| [IntelligentVoiceManager](#intelligentvoicemanager)| Instance of the intelligent voice manager.|
37
38**Error codes**
39
40For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
41
42| ID| Error Message|
43| ------- | --------------------------------------------|
44| 22700101 | No memory.                              |
45
46**Example**
47
48```ts
49import { BusinessError } from '@ohos.base';
50
51let intelligentVoiceManager: intelligentVoice.IntelligentVoiceManager | null = null;
52try {
53  intelligentVoiceManager = intelligentVoice.getIntelligentVoiceManager();
54} catch (err) {
55  let error = err as BusinessError;
56  console.error(`Get IntelligentVoiceManager failed. Code:${error.code}, message:${error.message}`);
57}
58```
59
60## intelligentVoice.createEnrollIntelligentVoiceEngine
61
62createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor, callback: AsyncCallback<EnrollIntelligentVoiceEngine>): void
63
64Creates an instance of the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result.
65
66**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
67
68**System capability**: SystemCapability.AI.IntelligentVoice.Core
69
70**Parameters**
71
72| Name  | Type                               | Mandatory| Description                  |
73| -------- | ----------------------------------- | ---- | ---------------------- |
74| descriptor    | [EnrollIntelligentVoiceEngineDescriptor](#enrollintelligentvoiceenginedescriptor)                              | Yes  | Descriptor of the intelligent voice enrollment engine.  |
75| callback    | AsyncCallback\<[EnrollIntelligentVoiceEngine](#enrollintelligentvoiceengine)\>         | Yes  | Callback used to return the result.  |
76
77**Error codes**
78
79For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
80
81| ID| Error Message|
82| ------- | --------------------------------------------|
83| 22700101 | No memory.                           |
84| 22700102 | Input parameter value error.                            |
85
86**Example**
87
88```ts
89import { BusinessError } from '@ohos.base';
90
91let engineDescriptor: intelligentVoice.EnrollIntelligentVoiceEngineDescriptor = {
92  wakeupPhrase: 'Xiaohua Xiaohua',
93}
94let enrollIntelligentVoiceEngine: intelligentVoice.EnrollIntelligentVoiceEngine | null = null;
95intelligentVoice.createEnrollIntelligentVoiceEngine(engineDescriptor, (err: BusinessError, data: intelligentVoice.EnrollIntelligentVoiceEngine) => {
96  if (err) {
97    console.error(`Failed to create enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
98  } else {
99    console.info(`Succeeded in creating enrollIntelligentVoice engine.`);
100    enrollIntelligentVoiceEngine = data;
101  }
102});
103```
104
105## intelligentVoice.createEnrollIntelligentVoiceEngine
106
107createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor): Promise&lt;EnrollIntelligentVoiceEngine&gt;
108
109
110Creates an instance of the intelligent voice enrollment engine. This API uses a promise to return the result.
111
112**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
113
114**System capability**: SystemCapability.AI.IntelligentVoice.Core
115
116**Parameters**
117
118| Name  | Type                               | Mandatory| Description                  |
119| -------- | ----------------------------------- | ---- | ---------------------- |
120| descriptor    | [EnrollIntelligentVoiceEngineDescriptor](#enrollintelligentvoiceenginedescriptor)                              | Yes  | Descriptor of the intelligent voice enrollment engine.  |
121
122**Return value**
123
124| Type                                            | Description                          |
125| ----------------------------------------------- | ---------------------------- |
126| Promise\<[EnrollIntelligentVoiceEngine](#enrollintelligentvoiceengine)\>           | Promise used to return the result.                  |
127
128**Error codes**
129
130For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
131
132| ID| Error Message|
133| ------- | --------------------------------------------|
134| 22700101 | No memory.                           |
135| 22700102 | Input parameter value error.                            |
136
137**Example**
138
139```ts
140import { BusinessError } from '@ohos.base';
141
142let engineDescriptor: intelligentVoice.EnrollIntelligentVoiceEngineDescriptor = {
143  wakeupPhrase:'Xiaohua Xiaohua',
144}
145let enrollIntelligentVoiceEngine: intelligentVoice.EnrollIntelligentVoiceEngine | null = null;
146intelligentVoice.createEnrollIntelligentVoiceEngine(engineDescriptor).then((data: intelligentVoice.EnrollIntelligentVoiceEngine) => {
147  enrollIntelligentVoiceEngine = data;
148  console.info(`Succeeded in creating enrollIntelligentVoice engine.`);
149}).catch((err: BusinessError) => {
150  console.error(`Failed to create enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
151});
152```
153
154## intelligentVoice.createWakeupIntelligentVoiceEngine
155
156createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor, callback: AsyncCallback&lt;WakeupIntelligentVoiceEngine&gt;): void
157
158
159Creates an instance of the intelligent voice wakeup engine. This API uses an asynchronous callback to return the result.
160
161**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
162
163**System capability**: SystemCapability.AI.IntelligentVoice.Core
164
165**Parameters**
166
167| Name  | Type                               | Mandatory| Description                  |
168| -------- | ----------------------------------- | ---- | ---------------------- |
169| descriptor    | [WakeupIntelligentVoiceEngineDescriptor](#wakeupintelligentvoiceenginedescriptor)                              | Yes  | Descriptor of the intelligent voice wakeup engine.  |
170| callback    | AsyncCallback\<[WakeupIntelligentVoiceEngine](#wakeupintelligentvoiceengine)\>         | Yes  | Callback used to return the result.  |
171
172**Error codes**
173
174For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
175
176| ID| Error Message|
177| ------- | --------------------------------------------|
178| 22700101 | No memory.                           |
179| 22700102 | Input parameter value error.                            |
180
181**Example**
182
183```ts
184import { BusinessError } from '@ohos.base';
185
186let wakeupEngineDescriptor: intelligentVoice.WakeupIntelligentVoiceEngineDescriptor = {
187  needReconfirm: true,
188  wakeupPhrase: 'Xiaohua Xiaohua',
189}
190let wakeupIntelligentVoiceEngine: intelligentVoice.WakeupIntelligentVoiceEngine | null = null;
191intelligentVoice.createWakeupIntelligentVoiceEngine(wakeupEngineDescriptor, (err: BusinessError, data: intelligentVoice.WakeupIntelligentVoiceEngine) => {
192  if (err) {
193    console.error(`Failed to create wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
194  } else {
195    console.info(`Succeeded in creating wakeupIntelligentVoice engine.`);
196    wakeupIntelligentVoiceEngine = data;
197  }
198});
199```
200
201## intelligentVoice.createWakeupIntelligentVoiceEngine
202
203createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor): Promise&lt;WakeupIntelligentVoiceEngine&gt;
204
205Creates an instance of the intelligent voice wakeup engine. This API uses a promise to return the result.
206
207**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
208
209**System capability**: SystemCapability.AI.IntelligentVoice.Core
210
211**Parameters**
212
213| Name  | Type                               | Mandatory| Description                  |
214| -------- | ----------------------------------- | ---- | ---------------------- |
215| descriptor    | [WakeupIntelligentVoiceEngineDescriptor](#wakeupintelligentvoiceenginedescriptor)                              | Yes  | Descriptor of the intelligent voice wakeup engine.  |
216
217**Return value**
218
219| Type                                            | Description                          |
220| ----------------------------------------------- | ---------------------------- |
221| Promise\<[WakeupIntelligentVoiceEngine](#wakeupintelligentvoiceengine)>           | Promise used to return the result.                  |
222
223**Error codes**
224
225For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
226
227| ID| Error Message|
228| ------- | --------------------------------------------|
229| 22700101 | No memory.                           |
230| 22700102 | Input parameter value error.                            |
231
232**Example**
233
234```ts
235import { BusinessError } from '@ohos.base';
236
237let wakeupEngineDescriptor: intelligentVoice.WakeupIntelligentVoiceEngineDescriptor = {
238  needReconfirm: true,
239  wakeupPhrase: 'Xiaohua Xiaohua',
240}
241let wakeupIntelligentVoiceEngine: intelligentVoice.WakeupIntelligentVoiceEngine | null = null;
242intelligentVoice.createWakeupIntelligentVoiceEngine(wakeupEngineDescriptor).then((data: intelligentVoice.WakeupIntelligentVoiceEngine) => {
243  wakeupIntelligentVoiceEngine = data;
244  console.info(`Succeeded in creating wakeupIntelligentVoice engine.`);
245}).catch((err: BusinessError) => {
246  console.error(`Failed to create wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
247});
248```
249
250## IntelligentVoiceManager
251
252Class that implements intelligent voice management. Before use, you need to call [getIntelligentVoiceManager()](#intelligentvoicegetintelligentvoicemanager) to obtain an **IntelligentVoiceManager** object.
253
254### getCapabilityInfo
255
256getCapabilityInfo(): Array&lt;IntelligentVoiceEngineType&gt;
257
258Obtains the list of supported intelligent voice engine types.
259
260**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
261
262**System capability**: SystemCapability.AI.IntelligentVoice.Core
263
264**Return value**
265
266| Type                                            | Description                          |
267| ----------------------------------------------- | ---------------------------- |
268|  Array\<[IntelligentVoiceEngineType](#intelligentvoiceenginetype)\>            | Array of supported intelligent voice engine types.             |
269
270**Example**
271
272```ts
273if (intelligentVoiceManager != null) {
274  let info = intelligentVoiceManager.getCapabilityInfo();
275}
276```
277
278### on('serviceChange')
279
280on(type: 'serviceChange', callback: Callback&lt;ServiceChangeType&gt;): void
281
282Subscribes to service change events. A callback is invoked when the status of the intelligent voice service changes.
283
284**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
285
286**System capability**: SystemCapability.AI.IntelligentVoice.Core
287
288**Parameters**
289
290| Name    | Type                             | Mandatory| Description                                         |
291| -------- | -------------------------------- | --- | ------------------------------------------- |
292| type     | string                           | Yes  | Event type. This field has a fixed value of **serviceChange**.|
293| callback | Callback\<[ServiceChangeType](#servicechangetype)\> | Yes  | Callback for the service status change.|
294
295**Example**
296
297```ts
298if (intelligentVoiceManager != null) {
299  intelligentVoiceManager.on('serviceChange', (serviceChangeType: intelligentVoice.ServiceChangeType) => {});
300}
301```
302
303### off('serviceChange')
304
305off(type: 'serviceChange', callback?: Callback\<ServiceChangeType\>): void
306
307Unsubscribes from service change events.
308
309**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
310
311**System capability**: SystemCapability.AI.IntelligentVoice.Core
312
313**Parameters**
314
315| Name    | Type                             | Mandatory| Description                                         |
316| -------- | -------------------------------- | --- | ------------------------------------------- |
317| type     | string                           | Yes  | Event type. This field has a fixed value of **serviceChange**.|
318| callback | Callback\<[ServiceChangeType](#servicechangetype)\> | No  | Callback 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. |
319
320**Example**
321
322```ts
323if (intelligentVoiceManager != null) {
324  intelligentVoiceManager.off('serviceChange');
325}
326```
327
328## ServiceChangeType
329
330Enumerates service status change types.
331
332**System capability**: SystemCapability.AI.IntelligentVoice.Core
333
334| Name                      | Value  | Description           |
335| ------------------------- | ---- | ------------    |
336| SERVICE_UNAVAILABLE      | 0    | The service is unavailable.  |
337
338## IntelligentVoiceEngineType
339
340Enumerates intelligent voice engine types.
341
342**System capability**: SystemCapability.AI.IntelligentVoice.Core
343
344| Name                      | Value  | Description           |
345| ------------------------- | ---- | ------------    |
346| ENROLL_ENGINE_TYPE      | 0    | Voice enrollment engine.  |
347| WAKEUP_ENGINE_TYPE      | 1    | Voice wakeup engine.  |
348| UPDATE_ENGINE_TYPE      | 2    | Silent update engine.  |
349
350## EnrollIntelligentVoiceEngineDescriptor
351
352Defines the descriptor of an intelligent voice enrollment engine.
353
354**System capability**: SystemCapability.AI.IntelligentVoice.Core
355
356| Name  | Type                           |     Mandatory    | Description      |
357| ------ | ----------------------------- | -------------- | ---------- |
358| wakeupPhrase | string |        Yes      | Wakeup phrase.|
359
360## WakeupIntelligentVoiceEngineDescriptor
361
362Defines the descriptor of an intelligent voice wakeup engine.
363
364**System capability**: SystemCapability.AI.IntelligentVoice.Core
365
366| Name  | Type                           |     Mandatory    | Description      |
367| ------ | ----------------------------- | -------------- | ---------- |
368| needReconfirm | boolean |        Yes      | Whether re-confirmation of the wakeup result is needed. The value **true** indicates that re-confirmation is needed, and the value **false** indicates the opposite.|
369| wakeupPhrase | string |        Yes      | Wakeup phrase.|
370
371## EnrollEngineConfig
372
373Defines the enrollment engine configuration.
374
375**System capability**: SystemCapability.AI.IntelligentVoice.Core
376
377| Name  | Type                           |     Mandatory    | Description      |
378| ------ | ----------------------------- | -------------- | ---------- |
379| language | string |        Yes      | Language supported by the enrollment engine. Only Chinese is supported currently, and the value is **zh**.|
380| region | string |        Yes      | Country/region supported by the enrollment engine. Only China is supported currently, and the value is **CN**.|
381
382## SensibilityType
383
384Enumerates wakeup sensibility types.
385A sensibility type maps to a wakeup threshold. A higher sensibility indicates a lower threshold and a higher wakeup probability.
386
387**System capability**: SystemCapability.AI.IntelligentVoice.Core
388
389| Name                      | Value  | Description           |
390| ------------------------- | ---- | ------------    |
391| LOW_SENSIBILITY      | 1    | Low sensibility.  |
392| MIDDLE_SENSIBILITY      | 2    | Medium sensibility.  |
393| HIGH_SENSIBILITY      | 3    | High sensibility.  |
394
395## WakeupHapInfo
396
397Defines the HAP information for an wakeup application.
398
399**System capability**: SystemCapability.AI.IntelligentVoice.Core
400
401| Name  | Type                           |     Mandatory    | Description      |
402| ------ | ----------------------------- | -------------- | ---------- |
403| bundleName | string |        Yes      | Bundle name of the wakeup application.|
404| abilityName | string |        Yes      | Ability name of the wakeup application.|
405
406## WakeupIntelligentVoiceEventType
407
408Enumerates types of intelligent voice wakeup events.
409
410**System capability**: SystemCapability.AI.IntelligentVoice.Core
411
412| Name                      | Value  | Description           |
413| ------------------------- | ---- | ------------    |
414| INTELLIGENT_VOICE_EVENT_WAKEUP_NONE      | 0    | No wakeup.  |
415| INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE      | 1    | Wakeup recognition completed.  |
416
417## IntelligentVoiceErrorCode
418
419Enumerates error codes of intelligent voice wakeup.
420
421**System capability**: SystemCapability.AI.IntelligentVoice.Core
422
423| Name                      | Value  | Description           |
424| ------------------------- | ---- | ------------    |
425| INTELLIGENT_VOICE_NO_MEMORY      | 22700101    | Insufficient memory.  |
426| INTELLIGENT_VOICE_INVALID_PARAM      | 22700102    | Invalid parameter. |
427| INTELLIGENT_VOICE_INIT_FAILED      | 22700103    | Enrollment failed.  |
428| INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED      | 22700104    | Enrollment commit failed.  |
429
430## EnrollResult
431
432Enumerates enrollment results.
433
434**System capability**: SystemCapability.AI.IntelligentVoice.Core
435
436| Name                      | Value  | Description           |
437| ------------------------- | ---- | ------------    |
438| SUCCESS      | 0    | Enrollment succeeded.  |
439| VPR_TRAIN_FAILED      | -1    | Voiceprint training failed. |
440| WAKEUP_PHRASE_NOT_MATCH      | -2    | Wakeup phrase mismatched.  |
441| TOO_NOISY      | -3    | Environment too noisy.  |
442| TOO_LOUD      | -4    | Voice too loud.  |
443| INTERVAL_LARGE      | -5    | Interval between wakeup phrases too long.  |
444| DIFFERENT_PERSON      | -6    | Wakeup phrases enrolled by different persons.  |
445| UNKNOWN_ERROR      | -100    | Unknown error.  |
446
447## EnrollCallbackInfo
448
449Defines the enrollment callback information.
450
451**System capability**: SystemCapability.AI.IntelligentVoice.Core
452
453| Name  | Type                           |     Mandatory    | Description      |
454| ------ | ----------------------------- | -------------- | ---------- |
455| result | [EnrollResult](#enrollresult) |        Yes      | Enrollment result.|
456| context | string |        Yes      | Context of the enrollment event.|
457
458## WakeupIntelligentVoiceEngineCallbackInfo
459
460Defines the callback information for the intelligent voice wakeup engine.
461
462**System capability**: SystemCapability.AI.IntelligentVoice.Core
463
464| Name  | Type                           |     Mandatory    | Description      |
465| ------ | ----------------------------- | -------------- | ---------- |
466| eventId | [WakeupIntelligentVoiceEventType](#wakeupintelligentvoiceeventtype) |        Yes      | Event type of the intelligent voice wakeup engine.|
467| isSuccess | boolean |        Yes      | Wakeup result. The value **true** indicates that the wakeup is successful, and the value **false** indicates the opposite.|
468| context | string |        Yes      | Context of the wakeup event.|
469
470## EnrollIntelligentVoiceEngine
471
472Class that implements the intelligent voice enrollment engine. Before use, you need to call [createEnrollIntelligentVoiceEngine()](#intelligentvoicecreateenrollintelligentvoiceengine) to obtain an instance of the intelligent voice enrollment engine.
473
474### getSupportedRegions
475
476getSupportedRegions(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
477
478Obtains the list of supported countries/regions. This API uses an asynchronous callback to return the result.
479
480**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
481
482**System capability**: SystemCapability.AI.IntelligentVoice.Core
483
484**Parameters**
485
486| Name    | Type                             | Mandatory| Description                                         |
487| -------- | -------------------------------- | --- | ------------------------------------------- |
488| callback     | AsyncCallback&lt;Array&lt;string&gt;&gt;         | Yes  | Callback used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is **CN**.|
489
490**Example**
491
492```ts
493import { BusinessError } from '@ohos.base';
494
495let regions: Array<string> | null = null;
496if (enrollIntelligentVoiceEngine != null) {
497  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getSupportedRegions((err: BusinessError, data: Array<string>) => {
498    if (err) {
499      console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
500    } else {
501      regions = data;
502      console.info(`Succeeded in getting supported regions, regions:${regions}.`);
503    }
504  });
505}
506```
507
508### getSupportedRegions
509
510getSupportedRegions(): Promise&lt;Array&lt;string&gt;&gt;
511
512Obtains the list of supported countries/regions. This API uses a promise to return the result.
513
514**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
515
516**System capability**: SystemCapability.AI.IntelligentVoice.Core
517
518**Return value**
519
520| Type                                            | Description                          |
521| ----------------------------------------------- | ---------------------------- |
522|  Promise&lt;Array&lt;string&gt;&gt;            | Promise used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is **CN**.                  |
523
524**Example**
525
526```ts
527import { BusinessError } from '@ohos.base';
528
529let regions: Array<string> | null = null;
530if (enrollIntelligentVoiceEngine != null) {
531  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getSupportedRegions().then((data: Array<string>) => {
532    regions = data;
533    console.info('Succeeded in getting supported regions, regions:${regions}.');
534  }).catch((err: BusinessError) => {
535    console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
536  });
537}
538```
539
540### init
541
542init(config: EnrollEngineConfig, callback: AsyncCallback&lt;void&gt;): void
543
544Initializes the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result.
545
546**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
547
548**System capability**: SystemCapability.AI.IntelligentVoice.Core
549
550**Parameters**
551
552| Name    | Type                             | Mandatory| Description                                         |
553| -------- | -------------------------------- | --- | ------------------------------------------- |
554| config     | [EnrollEngineConfig](#enrollengineconfig)                           | Yes  | Configuration of the intelligent voice enrollment engine.|
555| callback     |AsyncCallback&lt;void&gt;                           | Yes  | Callback used to return the result.|
556
557**Error codes**
558
559For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
560
561| ID| Error Message|
562| ------- | --------------------------------------------|
563| 22700102 | Input parameter value error.                            |
564| 22700103 | Init failed.                           |
565
566**Example**
567
568```ts
569import { BusinessError } from '@ohos.base';
570
571let config: intelligentVoice.EnrollEngineConfig = {
572  language: 'zh',
573  region: 'CN',
574}
575if (enrollIntelligentVoiceEngine != null) {
576  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).init(config, (err: BusinessError) => {
577    if (err) {
578      console.error(`Failed to initialize enrollIntelligentVoice engine. Code:${err.code}, message:${err.message}`);
579    } else {
580      console.info(`Succeeded in initialzing enrollIntelligentVoice engine.`);
581    }
582  });
583}
584```
585
586### init
587
588init(config: EnrollEngineConfig): Promise&lt;void&gt;
589
590Initializes the intelligent voice enrollment engine. This API uses a promise to return the result.
591
592**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
593
594**System capability**: SystemCapability.AI.IntelligentVoice.Core
595
596**Parameters**
597
598| Name    | Type                             | Mandatory| Description                                         |
599| -------- | -------------------------------- | --- | ------------------------------------------- |
600| config     | [EnrollEngineConfig](#enrollengineconfig)                           | Yes  | Configuration of the intelligent voice enrollment engine.|
601
602**Return value**
603
604| Type                                            | Description                          |
605| ----------------------------------------------- | ---------------------------- |
606|  Promise&lt;void&gt;           | Promise that returns no value.                  |
607
608**Error codes**
609
610For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
611
612| ID| Error Message|
613| ------- | --------------------------------------------|
614| 22700102 | Input parameter value error.                            |
615| 22700103 | Init failed.                           |
616
617**Example**
618
619```ts
620import { BusinessError } from '@ohos.base';
621
622let config: intelligentVoice.EnrollEngineConfig = {
623  language: 'zh',
624  region: 'CN',
625}
626if (enrollIntelligentVoiceEngine != null) {
627  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).init(config).then(() => {
628    console.info(`Succeeded in initializing enrollIntelligentVoice engine.`);
629  }).catch((err: BusinessError) => {
630    console.error(`Failed to initialize enrollIntelligentVoice engine. Code:${err.code}, message:${err.message}`);
631  });
632}
633
634```
635
636### enrollForResult
637
638enrollForResult(isLast: boolean, callback: AsyncCallback&lt;EnrollCallbackInfo&gt;): void
639
640Obtains the enrollment result. This API uses an asynchronous callback to return the result.
641
642**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
643
644**System capability**: SystemCapability.AI.IntelligentVoice.Core
645
646**Parameters**
647
648| Name    | Type                             | Mandatory| Description                                         |
649| -------- | -------------------------------- | --- | ------------------------------------------- |
650| isLast     | boolean                           | Yes  | Whether this is the last enrollment. The value **value** indicates the last enrollment, and the value **false** indicates the opposite.|
651| callback     | AsyncCallback&lt;[EnrollCallbackInfo](#enrollcallbackinfo)&gt;                           | Yes  | Callback used to return the result.|
652
653**Example**
654
655```ts
656import { BusinessError } from '@ohos.base';
657
658let callbackInfo: intelligentVoice.EnrollCallbackInfo | null = null;
659if (enrollIntelligentVoiceEngine != null) {
660  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).enrollForResult(true, (err: BusinessError, data: intelligentVoice.EnrollCallbackInfo) => {
661    if (err) {
662      console.error(`Failed to enroll for result, Code:${err.code}, message:${err.message}`);
663    } else {
664      callbackInfo = data;
665      console.info(`Succeeded in enrolling for result, info:${callbackInfo}.`);
666    }
667  });
668}
669```
670
671### enrollForResult
672
673enrollForResult(isLast: boolean): Promise&lt;EnrollCallbackInfo&gt;
674
675Obtains the enrollment result. This API uses a promise to return the result.
676
677**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
678
679**System capability**: SystemCapability.AI.IntelligentVoice.Core
680
681**Parameters**
682
683| Name    | Type                             | Mandatory| Description                                         |
684| -------- | -------------------------------- | --- | ------------------------------------------- |
685| isLast     | boolean                           | Yes  | Whether this is the last enrollment. The value **value** indicates the last enrollment, and the value **false** indicates the opposite.|
686
687**Return value**
688
689| Type                                            | Description                          |
690| ----------------------------------------------- | ---------------------------- |
691|  Promise&lt;[EnrollCallbackInfo](#enrollcallbackinfo)&gt;            | Promise used to return the result.                  |
692
693**Example**
694
695```ts
696import { BusinessError } from '@ohos.base';
697
698let callbackInfo: intelligentVoice.EnrollCallbackInfo | null = null;
699if (enrollIntelligentVoiceEngine != null) {
700  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).enrollForResult(true).then((data: intelligentVoice.EnrollCallbackInfo) => {
701    callbackInfo = data;
702    console.info(`Succeeded in enrolling for result, info:${callbackInfo}.`);
703  }).catch((err: BusinessError) => {
704    console.error(`Failed to enroll for result, Code:${err.code}, message:${err.message}`);
705  });
706}
707```
708
709### stop
710
711stop(callback: AsyncCallback&lt;void&gt;): void
712
713Stops the enrollment. This API uses an asynchronous callback to return the result.
714
715**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
716
717**System capability**: SystemCapability.AI.IntelligentVoice.Core
718
719| Name    | Type                             | Mandatory| Description                                         |
720| -------- | -------------------------------- | --- | ------------------------------------------- |
721| callback     |  AsyncCallback&lt;void&gt;                           | Yes  | Callback used to return the result.|
722
723**Example**
724
725```ts
726import { BusinessError } from '@ohos.base';
727
728if (enrollIntelligentVoiceEngine != null) {
729  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).stop((err: BusinessError) => {
730    if (err) {
731      console.error(`Failed to stop enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
732    } else {
733      console.info(`Succeeded in stopping enrollIntelligentVoice engine.`);
734    }
735  });
736}
737```
738
739### stop
740
741stop(): Promise&lt;void&gt;
742
743Stops the enrollment. This API uses a promise to return the result.
744
745**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
746
747**System capability**: SystemCapability.AI.IntelligentVoice.Core
748
749**Return value**
750
751| Type                                            | Description                          |
752| ----------------------------------------------- | ---------------------------- |
753|  Promise&lt;void&gt;            | Promise that returns no value.                  |
754
755**Example**
756
757```ts
758import { BusinessError } from '@ohos.base';
759
760if (enrollIntelligentVoiceEngine != null) {
761  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).stop().then(() => {
762    console.info(`Succeeded in stopping enrollIntelligentVoice engine.`);
763  }).catch((err:BusinessError) => {
764    console.error(`Failed to stop enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
765  });
766}
767```
768
769### commit
770
771commit(callback: AsyncCallback&lt;void&gt;): void
772
773Commits the enrollment. This API uses an asynchronous callback to return the result.
774
775**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
776
777**System capability**: SystemCapability.AI.IntelligentVoice.Core
778
779**Parameters**
780
781| Name    | Type                             | Mandatory| Description                                         |
782| -------- | -------------------------------- | --- | ------------------------------------------- |
783| callback     | AsyncCallback&lt;void&gt;                           | Yes  | Callback used to return the result.|
784
785**Error codes**
786
787For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
788
789| ID| Error Message|
790| ------- | --------------------------------------------|
791| 22700104 | Commit enroll failed.                           |
792
793**Example**
794
795```ts
796import { BusinessError } from '@ohos.base';
797
798if (enrollIntelligentVoiceEngine != null) {
799  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).commit((err: BusinessError) => {
800    if (err) {
801      console.error(`Failed to commit enroll, Code:${err.code}, message:${err.message}`);
802    } else {
803      console.info(`Succeeded in committing enroll.`);
804    }
805  });
806}
807```
808
809### commit
810
811commit(): Promise&lt;void&gt;
812
813Commits the enrollment. This API uses a promise to return the result.
814
815**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
816
817**System capability**: SystemCapability.AI.IntelligentVoice.Core
818
819**Return value**
820
821| Type                                            | Description                          |
822| ----------------------------------------------- | ---------------------------- |
823|  Promise&lt;void&gt;           | Promise that returns no value.                  |
824
825**Error codes**
826
827For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
828
829| ID| Error Message|
830| ------- | --------------------------------------------|
831| 22700104 | Commit enroll failed.                           |
832
833**Example**
834
835```ts
836import { BusinessError } from '@ohos.base';
837
838if (enrollIntelligentVoiceEngine != null) {
839  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).commit().then(() => {
840    console.info(`Succeeded in committing enroll.`);
841  }).catch((err: BusinessError) => {
842    console.error(`Failed to commit enroll, Code:${err.code}, message:${err.message}`);
843  });
844}
845```
846
847### setWakeupHapInfo
848
849setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback\<void>): void
850
851Sets the HAP information for the wakeup application. This API uses an asynchronous callback to return the result.
852
853**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
854
855**System capability**: SystemCapability.AI.IntelligentVoice.Core
856
857**Parameters**
858
859| Name    | Type                             | Mandatory| Description                                         |
860| -------- | -------------------------------- | --- | ------------------------------------------- |
861| info     | [WakeupHapInfo](#wakeuphapinfo)                           | Yes  | HAP information for the wakeup application.|
862| callback     | AsyncCallback\<void\>                          | Yes  | Callback used to return the result.|
863
864**Error codes**
865
866For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
867
868| ID| Error Message|
869| ------- | --------------------------------------------|
870| 22700102 | Input parameter value error.                            |
871
872**Example**
873
874```ts
875import { BusinessError } from '@ohos.base';
876
877let info: intelligentVoice.WakeupHapInfo = {
878  bundleName: 'com.wakeup',
879  abilityName: 'WakeUpExtAbility',
880}
881if (enrollIntelligentVoiceEngine != null) {
882  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setWakeupHapInfo(info, (err: BusinessError) => {
883    if (err) {
884      console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
885    } else {
886      console.info(`Succeeded in setting wakeup hap info.`);
887    }
888  });
889}
890```
891
892### setWakeupHapInfo
893
894setWakeupHapInfo(info: WakeupHapInfo): Promise\<void\>
895
896Sets the HAP information for the wakeup application. This API uses a promise to return the result.
897
898**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
899
900**System capability**: SystemCapability.AI.IntelligentVoice.Core
901
902**Return value**
903
904| Type                                            | Description                          |
905| ----------------------------------------------- | ---------------------------- |
906|  Promise&lt;void&gt;            | Promise that returns no value.                  |
907
908**Error codes**
909
910For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
911
912| ID| Error Message|
913| ------- | --------------------------------------------|
914| 22700102 | Input parameter value error.                            |
915
916**Example**
917
918```ts
919import { BusinessError } from '@ohos.base';
920
921let info: intelligentVoice.WakeupHapInfo = {
922  bundleName: 'com.wakeup',
923  abilityName: 'WakeUpExtAbility',
924}
925if (enrollIntelligentVoiceEngine != null) {
926  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setWakeupHapInfo(info).then(() => {
927    console.info(`Succeeded in setting wakeup hap info.`);
928  }).catch((err: BusinessError) => {
929    console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
930  });
931}
932```
933
934### setSensibility
935
936setSensibility(sensibility: SensibilityType, callback: AsyncCallback\<void\>): void
937
938Sets the wakeup sensibility. This API uses an asynchronous callback to return the result.
939
940**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
941
942**System capability**: SystemCapability.AI.IntelligentVoice.Core
943
944**Parameters**
945
946| Name    | Type                             | Mandatory| Description                                         |
947| -------- | -------------------------------- | --- | ------------------------------------------- |
948| sensibility     | [SensibilityType](#sensibilitytype)                           | Yes  | Sensibility type.|
949| callback     | AsyncCallback\<void\>                         | Yes  | Callback used to return the result.|
950
951**Error codes**
952
953For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
954
955| ID| Error Message|
956| ------- | --------------------------------------------|
957| 22700102 | Input parameter value error.                            |
958
959**Example**
960
961```ts
962import { BusinessError } from '@ohos.base';
963
964if (enrollIntelligentVoiceEngine != null) {
965  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY, (err: BusinessError) => {
966    if (err) {
967      console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
968    } else {
969      console.info(`Succeeded in setting sensibility.`);
970    }
971  });
972}
973```
974
975### setSensibility
976
977setSensibility(sensibility: SensibilityType): Promise\<void\>
978
979Sets the wakeup sensibility. This API uses a promise to return the result.
980
981**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
982
983**System capability**: SystemCapability.AI.IntelligentVoice.Core
984
985**Parameters**
986
987| Name    | Type                             | Mandatory| Description                                         |
988| -------- | -------------------------------- | --- | ------------------------------------------- |
989| sensibility     | [SensibilityType](#sensibilitytype)                           | Yes  | Sensibility type.|
990
991**Return value**
992
993| Type                                            | Description                          |
994| ----------------------------------------------- | ---------------------------- |
995|  Promise&lt;void&gt;            | Promise that returns no value.                  |
996
997**Error codes**
998
999For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1000
1001| ID| Error Message|
1002| ------- | --------------------------------------------|
1003| 22700102 | Input parameter value error.                            |
1004
1005**Example**
1006
1007```ts
1008import { BusinessError } from '@ohos.base';
1009
1010if (enrollIntelligentVoiceEngine != null) {
1011  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY).then(() => {
1012    console.info(`Succeeded in setting sensibility.`);
1013  }).catch((err: BusinessError) => {
1014    console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
1015  });
1016}
1017```
1018
1019### setParameter
1020
1021setParameter(key: string, value: string, callback: AsyncCallback\<void\>): void
1022
1023Sets specified intelligent voice parameters. This API uses an asynchronous callback to return the result.
1024
1025**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1026
1027**System capability**: SystemCapability.AI.IntelligentVoice.Core
1028
1029**Parameters**
1030
1031| Name    | Type                             | Mandatory| Description                                         |
1032| -------- | -------------------------------- | --- | ------------------------------------------- |
1033| key     | string                           | Yes  | Key.|
1034| value     | string                           | Yes  | Value.|
1035| callback     | AsyncCallback\<void\>                           | Yes  | Callback used to return the result.|
1036
1037**Error codes**
1038
1039For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1040
1041| ID| Error Message|
1042| ------- | --------------------------------------------|
1043| 22700102 | Input parameter value error.                            |
1044
1045**Example**
1046
1047```ts
1048import { BusinessError } from '@ohos.base';
1049
1050if (enrollIntelligentVoiceEngine != null) {
1051  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setParameter('scene', '0', (err: BusinessError) => {
1052    if (err) {
1053      console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
1054    } else {
1055      console.info(`Succeeded in setting parameter`);
1056    }
1057  });
1058}
1059```
1060
1061### setParameter
1062
1063setParameter(key: string, value: string): Promise\<void\>
1064
1065Sets specified intelligent voice parameters. This API uses a promise to return the result.
1066
1067**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1068
1069**System capability**: SystemCapability.AI.IntelligentVoice.Core
1070
1071**Parameters**
1072
1073| Name    | Type                             | Mandatory| Description                                         |
1074| -------- | -------------------------------- | --- | ------------------------------------------- |
1075| key     | string                           | Yes  | Key.|
1076| value     | string                           | Yes  | Value.|
1077
1078**Return value**
1079
1080| Type                                            | Description                          |
1081| ----------------------------------------------- | ---------------------------- |
1082|  Promise&lt;void&gt;            | Promise that returns no value.                  |
1083
1084**Error codes**
1085
1086For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1087
1088| ID| Error Message|
1089| ------- | --------------------------------------------|
1090| 22700102 | Input parameter value error.                            |
1091
1092**Example**
1093
1094```ts
1095import { BusinessError } from '@ohos.base';
1096
1097if (enrollIntelligentVoiceEngine != null) {
1098  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setParameter('scene', '0').then(() => {
1099    console.info(`Succeeded in setting parameter`);
1100  }).catch((err: BusinessError) => {
1101    console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
1102  });
1103}
1104```
1105
1106### getParameter
1107
1108getParameter(key: string, callback: AsyncCallback\<string\>): void
1109
1110Obtains specified intelligent voice parameters. This API uses an asynchronous callback to return the result.
1111
1112**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1113
1114**System capability**: SystemCapability.AI.IntelligentVoice.Core
1115
1116**Parameters**
1117
1118| Name    | Type                             | Mandatory| Description                                         |
1119| -------- | -------------------------------- | --- | ------------------------------------------- |
1120| key     | string                           | Yes  | Key.|
1121| callback     | AsyncCallback\<string\>                           | Yes  | Callback used to return the result.|
1122
1123**Error codes**
1124
1125For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1126
1127| ID| Error Message|
1128| ------- | --------------------------------------------|
1129| 22700102 | Input parameter value error.                            |
1130
1131**Example**
1132
1133```ts
1134import { BusinessError } from '@ohos.base';
1135
1136if (enrollIntelligentVoiceEngine != null) {
1137  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getParameter('key', (err: BusinessError, data: string) => {
1138    if (err) {
1139      console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
1140    } else {
1141      let param: string = data;
1142      console.info(`Succeeded in getting parameter, param:${param}`);
1143    }
1144  });
1145}
1146```
1147
1148### getParameter
1149
1150getParameter(key: string): Promise\<string\>
1151
1152Obtains specified intelligent voice parameters. This API uses a promise to return the result.
1153
1154**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1155
1156**System capability**: SystemCapability.AI.IntelligentVoice.Core
1157
1158**Parameters**
1159
1160| Name    | Type                             | Mandatory| Description                                         |
1161| -------- | -------------------------------- | --- | ------------------------------------------- |
1162| key     | string                           | Yes  | Key.|
1163
1164**Return value**
1165
1166| Type                                            | Description                          |
1167| ----------------------------------------------- | ---------------------------- |
1168|  Promise\<string\>            | Promise used to return the result.                  |
1169
1170**Error codes**
1171
1172For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1173
1174| ID| Error Message|
1175| ------- | --------------------------------------------|
1176| 22700102 | Input parameter value error.                            |
1177
1178**Example**
1179
1180```ts
1181import { BusinessError } from '@ohos.base';
1182
1183if (enrollIntelligentVoiceEngine != null) {
1184  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getParameter('key').then((data: string) => {
1185    let param: string = data;
1186    console.info(`Succeeded in getting parameter, param:${param}`);
1187  }).catch((err: BusinessError) => {
1188    console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
1189  });
1190}
1191```
1192
1193### release
1194
1195release(callback: AsyncCallback&lt;void&gt;): void
1196
1197Releases the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result.
1198
1199**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1200
1201**System capability**: SystemCapability.AI.IntelligentVoice.Core
1202
1203**Parameters**
1204
1205| Name    | Type                             | Mandatory| Description                                         |
1206| -------- | -------------------------------- | --- | ------------------------------------------- |
1207| callback     | AsyncCallback\<void\>                           | Yes  | Callback used to return the result.|
1208
1209**Example**
1210
1211```ts
1212import { BusinessError } from '@ohos.base';
1213
1214if (enrollIntelligentVoiceEngine != null) {
1215  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).release((err: BusinessError) => {
1216    if (err) {
1217      console.error(`Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
1218    } else {
1219      console.info(`Succeeded in releasing enrollIntelligentVoice engine.`);
1220    }
1221  });
1222}
1223```
1224
1225### release
1226
1227release(): Promise&lt;void&gt;
1228
1229Releases the intelligent voice enrollment engine. This API uses a promise to return the result.
1230
1231**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1232
1233**System capability**: SystemCapability.AI.IntelligentVoice.Core
1234
1235**Return value**
1236
1237| Type                                            | Description                          |
1238| ----------------------------------------------- | ---------------------------- |
1239|  Promise&lt;void&gt;            | Promise that returns no value.                 |
1240
1241**Example**
1242
1243```ts
1244import { BusinessError } from '@ohos.base';
1245
1246if (enrollIntelligentVoiceEngine != null) {
1247  (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).release().then(() => {
1248    console.info(`Succeeded in releasing enrollIntelligentVoice engine.`);
1249  }).catch((err: BusinessError) => {
1250    console.error(`Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
1251  });
1252}
1253```
1254
1255## WakeupIntelligentVoiceEngine
1256
1257Class that implements the intelligent voice wakeup engine. Before use, you need to call [createWakeupIntelligentVoiceEngine()](#intelligentvoicecreatewakeupintelligentvoiceengine) to obtain an instance of the intelligent voice wakeup engine.
1258
1259### getSupportedRegions
1260
1261getSupportedRegions(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1262
1263Obtains the list of supported countries/regions. This API uses an asynchronous callback to return the result.
1264
1265**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1266
1267**System capability**: SystemCapability.AI.IntelligentVoice.Core
1268
1269| Name    | Type                             | Mandatory| Description                                         |
1270| -------- | -------------------------------- | --- | ------------------------------------------- |
1271| callback     | AsyncCallback&lt;Array&lt;string&gt;&gt;                           | Yes  | Callback used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is **CN**.|
1272
1273**Example**
1274
1275```ts
1276import { BusinessError } from '@ohos.base';
1277
1278if (wakeupIntelligentVoiceEngine != null) {
1279  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getSupportedRegions((err: BusinessError, data: Array<string>) => {
1280    if (err) {
1281      console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
1282    } else {
1283      let regions: Array<string> = data;
1284      console.info(`Succeeded in getting supported regions, regions:${regions}.`);
1285    }
1286  });
1287}
1288```
1289
1290### getSupportedRegions
1291
1292getSupportedRegions(): Promise&lt;Array&lt;string&gt;&gt;
1293
1294Obtains the list of supported countries/regions. This API uses a promise to return the result.
1295
1296**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1297
1298**System capability**: SystemCapability.AI.IntelligentVoice.Core
1299
1300**Return value**
1301
1302| Type                                            | Description                          |
1303| ----------------------------------------------- | ---------------------------- |
1304|  Promise&lt;Array&lt;string&gt;&gt;            | Promise used to return the result, which is an array of supported countries/regions. Only China is supported currently, and the value is **CN**.                  |
1305
1306**Example**
1307
1308```ts
1309import { BusinessError } from '@ohos.base';
1310
1311if (wakeupIntelligentVoiceEngine != null) {
1312  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getSupportedRegions().then((data: Array<string>) => {
1313    let regions: Array<string> = data;
1314    console.info(`Succeeded in getting supported regions, regions:${regions}.`);
1315  }).catch((err: BusinessError) => {
1316    console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`);
1317  });
1318}
1319```
1320
1321### setWakeupHapInfo
1322
1323setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback\<void\>): void
1324
1325Sets the HAP information for the wakeup application. This API uses an asynchronous callback to return the result.
1326
1327**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1328
1329**System capability**: SystemCapability.AI.IntelligentVoice.Core
1330
1331**Parameters**
1332
1333| Name    | Type                             | Mandatory| Description                                         |
1334| -------- | -------------------------------- | --- | ------------------------------------------- |
1335| info     | [WakeupHapInfo](#wakeuphapinfo)                           | Yes  | HAP information for the wakeup application.|
1336| callback     | AsyncCallback\<void\>                           | Yes  | Callback used to return the result.|
1337
1338**Error codes**
1339
1340For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1341
1342| ID| Error Message|
1343| ------- | --------------------------------------------|
1344| 22700102 | Input parameter value error.                            |
1345
1346**Example**
1347
1348```ts
1349import { BusinessError } from '@ohos.base';
1350
1351let hapInfo: intelligentVoice.WakeupHapInfo = {
1352  bundleName: 'com.wakeup',
1353  abilityName: 'WakeUpExtAbility',
1354}
1355
1356if (wakeupIntelligentVoiceEngine != null) {
1357  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setWakeupHapInfo(hapInfo, (err: BusinessError) => {
1358    if (err) {
1359      console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
1360    } else {
1361      console.info(`Succeeded in setting wakeup hap info.`);
1362    }
1363  });
1364}
1365```
1366
1367### setWakeupHapInfo
1368
1369setWakeupHapInfo(info: WakeupHapInfo): Promise\<void\>
1370
1371Sets the HAP information for the wakeup application. This API uses a promise to return the result.
1372
1373**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1374
1375**System capability**: SystemCapability.AI.IntelligentVoice.Core
1376
1377**Parameters**
1378
1379| Name    | Type                             | Mandatory| Description                                         |
1380| -------- | -------------------------------- | --- | ------------------------------------------- |
1381| info     | [WakeupHapInfo](#wakeuphapinfo)                           | Yes  | HAP information for the wakeup application.|
1382
1383**Return value**
1384
1385| Type                                            | Description                          |
1386| ----------------------------------------------- | ---------------------------- |
1387|  Promise&lt;void&gt;            | Promise that returns no value.                  |
1388
1389**Error codes**
1390
1391For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1392
1393| ID| Error Message|
1394| ------- | --------------------------------------------|
1395| 22700102 | Input parameter value error.                            |
1396
1397**Example**
1398
1399```ts
1400import { BusinessError } from '@ohos.base';
1401
1402let hapInfo: intelligentVoice.WakeupHapInfo = {
1403  bundleName: 'com.wakeup',
1404  abilityName: 'WakeUpExtAbility',
1405}
1406if (wakeupIntelligentVoiceEngine != null) {
1407  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setWakeupHapInfo(hapInfo).then(() => {
1408    console.info(`Succeeded in setting wakeup hap info.`);
1409  }).catch((err: BusinessError) => {
1410    console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`);
1411  });
1412}
1413```
1414
1415### setSensibility
1416
1417setSensibility(sensibility: SensibilityType, callback: AsyncCallback\<void\>): void
1418
1419Sets the wakeup sensibility. This API uses an asynchronous callback to return the result.
1420
1421**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1422
1423**System capability**: SystemCapability.AI.IntelligentVoice.Core
1424
1425**Parameters**
1426
1427| Name    | Type                             | Mandatory| Description                                         |
1428| -------- | -------------------------------- | --- | ------------------------------------------- |
1429| sensibility     | [SensibilityType](#sensibilitytype)                           | Yes  | Sensibility type.|
1430| callback     | AsyncCallback\<void\>                           | Yes  | Callback used to return the result.|
1431
1432**Error codes**
1433
1434For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1435
1436| ID| Error Message|
1437| ------- | --------------------------------------------|
1438| 22700102 | Input parameter value error.                            |
1439
1440**Example**
1441
1442```ts
1443import { BusinessError } from '@ohos.base';
1444
1445if (wakeupIntelligentVoiceEngine != null) {
1446  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY, (err: BusinessError) => {
1447    if (err) {
1448      console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
1449    } else {
1450      console.info(`Succeeded in setting sensibility.`);
1451    }
1452  });
1453}
1454```
1455
1456### setSensibility
1457
1458setSensibility(sensibility: SensibilityType): Promise\<void\>
1459
1460Sets the wakeup sensibility. This API uses a promise to return the result.
1461
1462**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1463
1464**System capability**: SystemCapability.AI.IntelligentVoice.Core
1465
1466**Parameters**
1467
1468| Name    | Type                             | Mandatory| Description                                         |
1469| -------- | -------------------------------- | --- | ------------------------------------------- |
1470| sensibility     | [SensibilityType](#sensibilitytype)                           | Yes  | Sensibility type.|
1471
1472**Return value**
1473
1474| Type                                            | Description                          |
1475| ----------------------------------------------- | ---------------------------- |
1476|  Promise&lt;void&gt;            | Promise that returns no value.                  |
1477
1478**Error codes**
1479
1480For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1481
1482| ID| Error Message|
1483| ------- | --------------------------------------------|
1484| 22700102 | Input parameter value error.                            |
1485
1486**Example**
1487
1488```ts
1489import { BusinessError } from '@ohos.base';
1490
1491if (wakeupIntelligentVoiceEngine != null) {
1492  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY).then(() => {
1493    console.info(`Succeeded in setting sensibility.`);
1494  }).catch((err: BusinessError) => {
1495    console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`);
1496  });
1497}
1498```
1499
1500### setParameter
1501
1502setParameter(key: string, value: string, callback: AsyncCallback\<void\>): void
1503
1504Sets specified intelligent voice parameters. This API uses an asynchronous callback to return the result.
1505
1506**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1507
1508**System capability**: SystemCapability.AI.IntelligentVoice.Core
1509
1510**Parameters**
1511
1512| Name    | Type                             | Mandatory| Description                                         |
1513| -------- | -------------------------------- | --- | ------------------------------------------- |
1514| key     | string                           | Yes  | Key.|
1515| value     | string                           | Yes  | Value.|
1516| callback     | AsyncCallback\<void\>                           | Yes  | Callback used to return the result.|
1517
1518**Error codes**
1519
1520For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1521
1522| ID| Error Message|
1523| ------- | --------------------------------------------|
1524| 22700102 | Input parameter value error.                            |
1525
1526**Example**
1527
1528```ts
1529import { BusinessError } from '@ohos.base';
1530
1531if (wakeupIntelligentVoiceEngine != null) {
1532  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setParameter('scene', '0', (err: BusinessError) => {
1533    if (err) {
1534      console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
1535    } else {
1536      console.info(`Succeeded in setting parameter`);
1537    }
1538  });
1539}
1540```
1541
1542### setParameter
1543
1544setParameter(key: string, value: string): Promise\<void\>
1545
1546Sets specified intelligent voice parameters. This API uses a promise to return the result.
1547
1548**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1549
1550**System capability**: SystemCapability.AI.IntelligentVoice.Core
1551
1552**Parameters**
1553
1554| Name    | Type                             | Mandatory| Description                                         |
1555| -------- | -------------------------------- | --- | ------------------------------------------- |
1556| key     | string                           | Yes  | Key.|
1557| value     | string                           | Yes  | Value.|
1558
1559**Return value**
1560
1561| Type                                            | Description                          |
1562| ----------------------------------------------- | ---------------------------- |
1563|  Promise&lt;void&gt;            | Promise that returns no value.                  |
1564
1565**Error codes**
1566
1567For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1568
1569| ID| Error Message|
1570| ------- | --------------------------------------------|
1571| 22700102 | Input parameter value error.                            |
1572
1573**Example**
1574
1575```ts
1576import { BusinessError } from '@ohos.base';
1577
1578if (wakeupIntelligentVoiceEngine != null) {
1579  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setParameter('scene', '0').then(() => {
1580    console.info(`Succeeded in setting parameter`);
1581  }).catch((err: BusinessError) => {
1582    console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`);
1583  });
1584}
1585```
1586
1587### getParameter
1588
1589getParameter(key: string, callback: AsyncCallback\<string\>): void
1590
1591Obtains specified intelligent voice parameters. This API uses an asynchronous callback to return the result.
1592
1593**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1594
1595**System capability**: SystemCapability.AI.IntelligentVoice.Core
1596
1597**Parameters**
1598
1599| Name    | Type                             | Mandatory| Description                                         |
1600| -------- | -------------------------------- | --- | ------------------------------------------- |
1601| key     | string                           | Yes  | Key.|
1602| callback     | AsyncCallback\<string\>                           | Yes  | Callback used to return the result.|
1603
1604**Error codes**
1605
1606For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1607
1608| ID| Error Message|
1609| ------- | --------------------------------------------|
1610| 22700102 | Input parameter value error.                            |
1611
1612**Example**
1613
1614```ts
1615import { BusinessError } from '@ohos.base';
1616
1617if (wakeupIntelligentVoiceEngine != null) {
1618  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getParameter('key', (err: BusinessError, data: string) => {
1619    if (err) {
1620      console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
1621    } else {
1622      let param: string = data;
1623      console.info(`Succeeded in getting parameter, param:${param}`);
1624    }
1625  });
1626}
1627```
1628
1629### getParameter
1630
1631getParameter(key: string): Promise\<string\>
1632
1633Obtains specified intelligent voice parameters. This API uses a promise to return the result.
1634
1635**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1636
1637**System capability**: SystemCapability.AI.IntelligentVoice.Core
1638
1639**Parameters**
1640
1641| Name    | Type                             | Mandatory| Description                                         |
1642| -------- | -------------------------------- | --- | ------------------------------------------- |
1643| key     | string                           | Yes  | Key.|
1644
1645**Return value**
1646
1647| Type                                            | Description                          |
1648| ----------------------------------------------- | ---------------------------- |
1649|  Promise\<string\>            | Promise used to return the result.                  |
1650
1651**Error codes**
1652
1653For details about the error codes, see [Intelligent Voice Error Codes](../errorcodes/errorcode-intelligentVoice.md).
1654
1655| ID| Error Message|
1656| ------- | --------------------------------------------|
1657| 22700102 | Input parameter value error.                            |
1658
1659**Example**
1660
1661```ts
1662import { BusinessError } from '@ohos.base';
1663
1664if (wakeupIntelligentVoiceEngine != null) {
1665  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getParameter('key').then((data: string) => {
1666    let param: string = data;
1667    console.info(`Succeeded in getting parameter, param:${param}`);
1668  }).catch((err: BusinessError) => {
1669    console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`);
1670  });
1671}
1672```
1673
1674### release
1675
1676release(callback: AsyncCallback\<void\>): void
1677
1678Releases the intelligent voice wakeup engine. This API uses an asynchronous callback to return the result.
1679
1680**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1681
1682**System capability**: SystemCapability.AI.IntelligentVoice.Core
1683
1684**Parameters**
1685
1686| Name    | Type                             | Mandatory| Description                                         |
1687| -------- | -------------------------------- | --- | ------------------------------------------- |
1688| callback     | AsyncCallback\<void\>                           | Yes  | Callback used to return the result.|
1689
1690**Example**
1691
1692```ts
1693import { BusinessError } from '@ohos.base';
1694
1695if (wakeupIntelligentVoiceEngine != null) {
1696  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).release((err: BusinessError) => {
1697    if (err) {
1698      console.error(`Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
1699    } else {
1700      console.info(`Succeeded in releasing wakeupIntelligentVoice engine.`);
1701    }
1702  });
1703}
1704```
1705
1706### release
1707
1708release(): Promise\<void\>
1709
1710Releases the intelligent voice wakeup engine. This API uses a promise to return the result.
1711
1712**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1713
1714**System capability**: SystemCapability.AI.IntelligentVoice.Core
1715
1716**Return value**
1717
1718| Type                                            | Description                          |
1719| ----------------------------------------------- | ---------------------------- |
1720|  Promise&lt;void&gt;            | Promise that returns no value.                  |
1721
1722**Example**
1723
1724```ts
1725import { BusinessError } from '@ohos.base';
1726
1727if (wakeupIntelligentVoiceEngine != null) {
1728  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).release().then(() => {
1729    console.info(`Succeeded in releasing wakeupIntelligentVoice engine.`);
1730  }).catch((err: BusinessError) => {
1731    console.error(`Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`);
1732  });
1733}
1734```
1735
1736### on
1737
1738on(type: 'wakeupIntelligentVoiceEvent', callback: Callback\<WakeupIntelligentVoiceEngineCallbackInfo\>): void
1739
1740Subscribes to wakeup events.
1741
1742**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1743
1744**System capability**: SystemCapability.AI.IntelligentVoice.Core
1745
1746**Parameters**
1747
1748| Name    | Type                             | Mandatory| Description                                         |
1749| -------- | -------------------------------- | --- | ------------------------------------------- |
1750| type     | string          | Yes  | Event type. This field has a fixed value of **wakeupIntelligentVoiceEvent**.|
1751| callback     | Callback\<[WakeupIntelligentVoiceEngineCallbackInfo](#wakeupintelligentvoiceenginecallbackinfo)\>                           | Yes  | Processing of the wakeup event.|
1752
1753**Example**
1754
1755```ts
1756if (wakeupIntelligentVoiceEngine != null) {
1757  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).on('wakeupIntelligentVoiceEvent',
1758    (info: intelligentVoice.WakeupIntelligentVoiceEngineCallbackInfo) => {
1759    let callbackInfo: intelligentVoice.WakeupIntelligentVoiceEngineCallbackInfo = info;
1760    console.info(`wakeup intelligentvoice event, info:${callbackInfo}`);
1761  });
1762}
1763```
1764
1765### off
1766
1767off(type: 'wakeupIntelligentVoiceEvent', callback?: Callback\<WakeupIntelligentVoiceEngineCallbackInfo\>): void;
1768
1769Unsubscribes from wakeup events.
1770
1771**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE
1772
1773**System capability**: SystemCapability.AI.IntelligentVoice.Core
1774
1775**Parameters**
1776
1777| Name    | Type                             | Mandatory| Description                                         |
1778| -------- | -------------------------------- | --- | ------------------------------------------- |
1779| type     |string           | Yes  | Event type. This field has a fixed value of **wakeupIntelligentVoiceEvent**.|
1780| callback     | Callback\<[WakeupIntelligentVoiceEngineCallbackInfo](#wakeupintelligentvoiceenginecallbackinfo)\>                           | No  | Callback for processing of the wakeup event. If this parameter is specified, only the specified callback will be unsubscribed. Otherwise, all callbacks will be unsubscribed. |
1781
1782**Example**
1783
1784```ts
1785if (wakeupIntelligentVoiceEngine != null) {
1786  (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).off('wakeupIntelligentVoiceEvent');
1787}
1788```
1789