1# @ohos.ai.intelligentVoice (Intelligent Voice) (System API) 2 3The **intelligentVoice** module provides the intelligent voice enrollment and voice wakeup functions. <!--Del-->Currently, the features are related to chips and are not supported on OpenHarmony yet.<!--DelEnd--> 4 5Its features 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> - The kit to which **@ohos.ai.intelligentVoice** belongs has been changed from MindSpore Lite Kit to Basic Services Kit. You need to use the new module name **@kit.BasicServicesKit** when importing the module. Otherwise, the APIs of this module cannot be used. 18 19## Modules to Import 20```ts 21import { intelligentVoice } from '@kit.BasicServicesKit'; 22``` 23 24## intelligentVoice.getIntelligentVoiceManager 25 26getIntelligentVoiceManager(): IntelligentVoiceManager 27 28Obtains an instance of the intelligent voice manager. 29 30**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 31 32**System capability**: SystemCapability.AI.IntelligentVoice.Core 33 34**Return value** 35 36| Type | Description | 37| ----------------------------- | ------------ | 38| [IntelligentVoiceManager](#intelligentvoicemanager)| Instance of the intelligent voice manager.| 39 40**Error codes** 41 42For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 43 44| ID| Error Message| 45| ------- | --------------------------------------------| 46| 201 | Permission denied. | 47| 202 | Not system application. | 48| 22700101 | No memory. | 49 50**Example** 51 52```ts 53import { BusinessError } from '@kit.BasicServicesKit'; 54 55let intelligentVoiceManager: intelligentVoice.IntelligentVoiceManager | null = null; 56try { 57 intelligentVoiceManager = intelligentVoice.getIntelligentVoiceManager(); 58} catch (err) { 59 let error = err as BusinessError; 60 console.error(`Get IntelligentVoiceManager failed. Code:${error.code}, message:${error.message}`); 61} 62``` 63 64## intelligentVoice.getWakeupManager<sup>12+</sup> 65 66getWakeupManager(): WakeupManager 67 68Obtains an instance of the **WakeupManager** class. 69 70**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 71 72**System capability**: SystemCapability.AI.IntelligentVoice.Core 73 74**Return value** 75 76| Type | Description | 77| ----------------------------- | ------------ | 78| [WakeupManager](#wakeupmanager12) | Instance of the intelligent voice manager.| 79 80**Error codes** 81 82For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 83 84| ID| Error Message| 85| ------- | --------------------------------------------| 86| 201 | Permission denied. | 87| 202 | Not system application. | 88| 22700101 | No memory. | 89| 22700107 | System error. | 90 91**Example** 92 93```ts 94import { BusinessError } from '@kit.BasicServicesKit'; 95 96let wakeupManager: intelligentVoice.WakeupManager | null = null; 97try { 98 wakeupManager = intelligentVoice.getWakeupManager(); 99} catch (err) { 100 let error = err as BusinessError; 101 console.error(`Get WakeupManager failed. Code:${error.code}, message:${error.message}`); 102} 103``` 104 105## intelligentVoice.createEnrollIntelligentVoiceEngine 106 107createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor, callback: AsyncCallback<EnrollIntelligentVoiceEngine>): void 108 109Creates an instance of the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result. 110 111**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 112 113**System capability**: SystemCapability.AI.IntelligentVoice.Core 114 115**Parameters** 116 117| Name | Type | Mandatory| Description | 118| -------- | ----------------------------------- | ---- | ---------------------- | 119| descriptor | [EnrollIntelligentVoiceEngineDescriptor](#enrollintelligentvoiceenginedescriptor) | Yes | Descriptor of the intelligent voice enrollment engine. | 120| callback | AsyncCallback\<[EnrollIntelligentVoiceEngine](#enrollintelligentvoiceengine)\> | Yes | Callback used to return the result. | 121 122**Error codes** 123 124For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 125 126| ID| Error Message| 127| ------- | --------------------------------------------| 128| 201 | Permission denied. | 129| 202 | Not system application. | 130| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 131| 22700101 | No memory. | 132| 22700102 | Invalid parameter. | 133 134**Example** 135 136```ts 137import { BusinessError } from '@kit.BasicServicesKit'; 138 139let engineDescriptor: intelligentVoice.EnrollIntelligentVoiceEngineDescriptor = { 140 wakeupPhrase: 'Xiaohua Xiaohua', 141} 142let enrollIntelligentVoiceEngine: intelligentVoice.EnrollIntelligentVoiceEngine | null = null; 143intelligentVoice.createEnrollIntelligentVoiceEngine(engineDescriptor, (err: BusinessError, data: intelligentVoice.EnrollIntelligentVoiceEngine) => { 144 if (err) { 145 console.error(`Failed to create enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 146 } else { 147 console.info(`Succeeded in creating enrollIntelligentVoice engine.`); 148 enrollIntelligentVoiceEngine = data; 149 } 150}); 151``` 152 153## intelligentVoice.createEnrollIntelligentVoiceEngine 154 155createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor): Promise<EnrollIntelligentVoiceEngine> 156 157 158Creates an instance of the intelligent voice enrollment engine. This API uses a promise to return the result. 159 160**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 161 162**System capability**: SystemCapability.AI.IntelligentVoice.Core 163 164**Parameters** 165 166| Name | Type | Mandatory| Description | 167| -------- | ----------------------------------- | ---- | ---------------------- | 168| descriptor | [EnrollIntelligentVoiceEngineDescriptor](#enrollintelligentvoiceenginedescriptor) | Yes | Descriptor of the intelligent voice enrollment engine. | 169 170**Return value** 171 172| Type | Description | 173| ----------------------------------------------- | ---------------------------- | 174| Promise\<[EnrollIntelligentVoiceEngine](#enrollintelligentvoiceengine)\> | Callback used to return the result. | 175 176**Error codes** 177 178For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 179 180| ID| Error Message| 181| ------- | --------------------------------------------| 182| 201 | Permission denied. | 183| 202 | Not system application. | 184| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 185| 22700101 | No memory. | 186| 22700102 | Invalid parameter. | 187 188**Example** 189 190```ts 191import { BusinessError } from '@kit.BasicServicesKit'; 192 193let engineDescriptor: intelligentVoice.EnrollIntelligentVoiceEngineDescriptor = { 194 wakeupPhrase: 'Xiaohua Xiaohua', 195} 196let enrollIntelligentVoiceEngine: intelligentVoice.EnrollIntelligentVoiceEngine | null = null; 197intelligentVoice.createEnrollIntelligentVoiceEngine(engineDescriptor).then((data: intelligentVoice.EnrollIntelligentVoiceEngine) => { 198 enrollIntelligentVoiceEngine = data; 199 console.info(`Succeeded in creating enrollIntelligentVoice engine.`); 200}).catch((err: BusinessError) => { 201 console.error(`Failed to create enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 202}); 203``` 204 205## intelligentVoice.createWakeupIntelligentVoiceEngine 206 207createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor, callback: AsyncCallback<WakeupIntelligentVoiceEngine>): void 208 209 210Creates an instance of the intelligent voice wakeup engine. This API uses an asynchronous callback to return the result. 211 212**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 213 214**System capability**: SystemCapability.AI.IntelligentVoice.Core 215 216**Parameters** 217 218| Name | Type | Mandatory| Description | 219| -------- | ----------------------------------- | ---- | ---------------------- | 220| descriptor | [WakeupIntelligentVoiceEngineDescriptor](#wakeupintelligentvoiceenginedescriptor) | Yes | Descriptor of the intelligent voice wakeup engine. | 221| callback | AsyncCallback\<[WakeupIntelligentVoiceEngine](#wakeupintelligentvoiceengine)\> | Yes | Callback used to return the result. | 222 223**Error codes** 224 225For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 226 227| ID| Error Message| 228| ------- | --------------------------------------------| 229| 201 | Permission denied. | 230| 202 | Not system application. | 231| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 232| 22700101 | No memory. | 233| 22700102 | Invalid parameter. | 234 235**Example** 236 237```ts 238import { BusinessError } from '@kit.BasicServicesKit'; 239 240let wakeupEngineDescriptor: intelligentVoice.WakeupIntelligentVoiceEngineDescriptor = { 241 needReconfirm: true, 242 wakeupPhrase: 'Xiaohua Xiaohua', 243} 244let wakeupIntelligentVoiceEngine: intelligentVoice.WakeupIntelligentVoiceEngine | null = null; 245intelligentVoice.createWakeupIntelligentVoiceEngine(wakeupEngineDescriptor, (err: BusinessError, data: intelligentVoice.WakeupIntelligentVoiceEngine) => { 246 if (err) { 247 console.error(`Failed to create wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 248 } else { 249 console.info(`Succeeded in creating wakeupIntelligentVoice engine.`); 250 wakeupIntelligentVoiceEngine = data; 251 } 252}); 253``` 254 255## intelligentVoice.createWakeupIntelligentVoiceEngine 256 257createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor): Promise<WakeupIntelligentVoiceEngine> 258 259Creates an instance of the intelligent voice wakeup engine. This API uses a promise to return the result. 260 261**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 262 263**System capability**: SystemCapability.AI.IntelligentVoice.Core 264 265**Parameters** 266 267| Name | Type | Mandatory| Description | 268| -------- | ----------------------------------- | ---- | ---------------------- | 269| descriptor | [WakeupIntelligentVoiceEngineDescriptor](#wakeupintelligentvoiceenginedescriptor) | Yes | Descriptor of the intelligent voice wakeup engine. | 270 271**Return value** 272 273| Type | Description | 274| ----------------------------------------------- | ---------------------------- | 275| Promise\<[WakeupIntelligentVoiceEngine](#wakeupintelligentvoiceengine)> | Callback used to return the result. | 276 277**Error codes** 278 279For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 280 281| ID| Error Message| 282| ------- | --------------------------------------------| 283| 201 | Permission denied. | 284| 202 | Not system application. | 285| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 286| 22700101 | No memory. | 287| 22700102 | Invalid parameter. | 288 289**Example** 290 291```ts 292import { BusinessError } from '@kit.BasicServicesKit'; 293 294let wakeupEngineDescriptor: intelligentVoice.WakeupIntelligentVoiceEngineDescriptor = { 295 needReconfirm: true, 296 wakeupPhrase: 'Xiaohua Xiaohua', 297} 298let wakeupIntelligentVoiceEngine: intelligentVoice.WakeupIntelligentVoiceEngine | null = null; 299intelligentVoice.createWakeupIntelligentVoiceEngine(wakeupEngineDescriptor).then((data: intelligentVoice.WakeupIntelligentVoiceEngine) => { 300 wakeupIntelligentVoiceEngine = data; 301 console.info(`Succeeded in creating wakeupIntelligentVoice engine.`); 302}).catch((err: BusinessError) => { 303 console.error(`Failed to create wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 304}); 305``` 306 307## IntelligentVoiceManager 308 309Class that implements intelligent voice management. Before use, you need to call [getIntelligentVoiceManager()](#intelligentvoicegetintelligentvoicemanager) to obtain an **IntelligentVoiceManager** object. 310 311### getCapabilityInfo 312 313getCapabilityInfo(): Array<IntelligentVoiceEngineType> 314 315Obtains the list of supported intelligent voice engine types. 316 317**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 318 319**System capability**: SystemCapability.AI.IntelligentVoice.Core 320 321**Return value** 322 323| Type | Description | 324| ----------------------------------------------- | ---------------------------- | 325| Array\<[IntelligentVoiceEngineType](#intelligentvoiceenginetype)\> | Array of supported intelligent voice engine types. | 326 327**Error codes** 328 329For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 330 331| ID| Error Message| 332| ------- | --------------------------------------------| 333| 201 | Permission denied. | 334| 202 | Not system application. | 335 336**Example** 337 338```ts 339if (intelligentVoiceManager != null) { 340 let info = intelligentVoiceManager.getCapabilityInfo(); 341} 342``` 343 344### on('serviceChange') 345 346on(type: 'serviceChange', callback: Callback<ServiceChangeType>): void 347 348Subscribes to service change events. A callback is invoked when the status of the intelligent voice service changes. 349 350**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 351 352**System capability**: SystemCapability.AI.IntelligentVoice.Core 353 354**Parameters** 355 356| Name | Type | Mandatory| Description | 357| -------- | -------------------------------- | --- | ------------------------------------------- | 358| type | string | Yes | Event type. This field has a fixed value of **serviceChange**.| 359| callback | Callback\<[ServiceChangeType](#servicechangetype)\> | Yes | Callback for the service status change.| 360 361**Error codes** 362 363For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 364 365| ID| Error Message| 366| ------- | --------------------------------------------| 367| 201 | Permission denied. | 368| 202 | Not system application. | 369 370**Example** 371 372```ts 373if (intelligentVoiceManager != null) { 374 intelligentVoiceManager.on('serviceChange', (serviceChangeType: intelligentVoice.ServiceChangeType) => {}); 375} 376``` 377 378### off('serviceChange') 379 380off(type: 'serviceChange', callback?: Callback\<ServiceChangeType\>): void 381 382Unsubscribes from service change events. 383 384**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 385 386**System capability**: SystemCapability.AI.IntelligentVoice.Core 387 388**Parameters** 389 390| Name | Type | Mandatory| Description | 391| -------- | -------------------------------- | --- | ------------------------------------------- | 392| type | string | Yes | Event type. This field has a fixed value of **serviceChange**.| 393| 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. | 394 395**Error codes** 396 397For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 398 399| ID| Error Message| 400| ------- | --------------------------------------------| 401| 201 | Permission denied. | 402| 202 | Not system application. | 403 404**Example** 405 406```ts 407if (intelligentVoiceManager != null) { 408 intelligentVoiceManager.off('serviceChange'); 409} 410``` 411 412## WakeupManager<sup>12+</sup> 413 414Represents the **WakeupManager** class. Before using this class, you need to obtain an instance by calling [getWakeupManager()](#intelligentvoicegetwakeupmanager12). 415 416### setParameter<sup>12+</sup> 417 418setParameter(key: string, value: string): Promise\<void\> 419 420Sets the specified wakeup parameter. This API uses a promise to return the result. 421 422**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 423 424**System capability**: SystemCapability.AI.IntelligentVoice.Core 425 426**Parameters** 427 428| Name | Type | Mandatory| Description | 429| -------- | -------------------------------- | --- | ------------------------------------------- | 430| key | string | Yes | Key, which corresponds to the wakeup keyword. Currently, only **wakeup_phrase** is supported.| 431| value | string | Yes | Value.| 432 433**Return value** 434 435| Type | Description | 436| ----------------------------------------------- | ---------------------------- | 437| Promise<void> | Promise that returns no value. | 438 439**Error codes** 440 441For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 442 443| ID| Error Message| 444| ------- | --------------------------------------------| 445| 201 | Permission denied. | 446| 202 | Not system application. | 447| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 448| 22700102 | Invalid parameter. | 449| 22700107 | System error. | 450 451**Example** 452 453```ts 454import { BusinessError } from '@kit.BasicServicesKit'; 455 456if (wakeupManager != null) { 457 (wakeupManager as intelligentVoice.WakeupManager).setParameter('wakeup_phrase', 'xiaohuaxiaohua').then(() => { 458 console.info(`Succeeded in setting parameter`); 459 }).catch((err: BusinessError) => { 460 console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`); 461 }); 462} 463``` 464 465### getParameter<sup>12+</sup> 466 467getParameter(key: string): Promise\<string\> 468 469Obtains specified intelligent voice parameters. This API uses a promise to return the result. 470 471**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 472 473**System capability**: SystemCapability.AI.IntelligentVoice.Core 474 475**Parameters** 476 477| Name | Type | Mandatory| Description | 478| -------- | -------------------------------- | --- | ------------------------------------------- | 479| key | string | Yes | Key, which corresponds to the registration information. Currently, only **isEnrolled** is supported.| 480 481**Return value** 482 483| Type | Description | 484| ----------------------------------------------- | ---------------------------- | 485| Promise\<string\> | Promise used to return the result. The value **true** indicates registered, and the value **false** indicates the opposite. | 486 487**Error codes** 488 489For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 490 491| ID| Error Message| 492| ------- | --------------------------------------------| 493| 201 | Permission denied. | 494| 202 | Not system application. | 495| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 496| 22700102 | Invalid parameter. | 497| 22700107 | System error. | 498 499**Example** 500 501```ts 502import { BusinessError } from '@kit.BasicServicesKit'; 503 504if (wakeupManager != null) { 505 (wakeupManager as intelligentVoice.WakeupManager).getParameter('isEnrolled').then((data: string) => { 506 let param: string = data; 507 console.info(`Succeeded in getting parameter, param:${param}`); 508 }).catch((err: BusinessError) => { 509 console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`); 510 }); 511} 512``` 513 514### getUploadFiles<sup>12+</sup> 515 516getUploadFiles(maxCount: number): Promise<Array<UploadFile>> 517 518Obtain the saved wakeup keyword files. This API uses a promise to return the result. 519 520**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 521 522**System capability**: SystemCapability.AI.IntelligentVoice.Core 523 524**Parameters** 525 526| Name | Type | Mandatory| Description | 527| -------- | -------------------------------- | --- | ------------------------------------------- | 528| maxCount | number | Yes | Number of obtained files.| 529 530**Return value** 531 532| Type | Description | 533| ----------------------------------------------- | ---------------------------- | 534| Promise<Array<[UploadFile](#uploadfile12)>> | Promise used to return the obtained files. | 535 536**Error codes** 537 538For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 539 540| ID| Error Message| 541| ------- | --------------------------------------------| 542| 201 | Permission denied. | 543| 202 | Not system application. | 544| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 545| 22700101 | No memory. | 546| 22700102 | Invalid parameter. | 547| 22700107 | System error. | 548 549**Example** 550 551```ts 552import { BusinessError } from '@kit.BasicServicesKit'; 553 554if (wakeupManager != null) { 555 (wakeupManager as intelligentVoice.WakeupManager).getUploadFiles(2).then((data: Array<intelligentVoice.UploadFile>) => { 556 let param: Array<intelligentVoice.UploadFile> = data; 557 console.info(`Succeeded in getting upload files, param:${param}`); 558 }).catch((err: BusinessError) => { 559 console.error(`Failed to get upload files, Code:${err.code}, message:${err.message}`); 560 }); 561} 562``` 563 564 565### getWakeupSourceFiles<sup>12+</sup> 566 567getWakeupSourceFiles(): Promise<Array<WakeupSourceFile>> 568 569Obtains wakeup resource files, such as registration corpus and path. This API uses a promise to return the result. 570 571**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 572 573**System capability**: SystemCapability.AI.IntelligentVoice.Core 574 575**Return value** 576 577| Type | Description | 578| ----------------------------------------------- | ---------------------------- | 579| Promise<Array<[WakeupSourceFile](#wakeupsourcefile12)>> | Promise used to return the wakeup resource file. | 580 581**Error codes** 582 583For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 584 585| ID| Error Message| 586| ------- | --------------------------------------------| 587| 201 | Permission denied. | 588| 202 | Not system application. | 589| 22700101 | No memory. | 590| 22700107 | System error. | 591 592**Example** 593 594```ts 595import { BusinessError } from '@kit.BasicServicesKit'; 596 597if (wakeupManager != null) { 598 (wakeupManager as intelligentVoice.WakeupManager).getWakeupSourceFiles().then( 599 (data: Array<intelligentVoice.WakeupSourceFile>) => { 600 let param: Array<intelligentVoice.WakeupSourceFile> = data; 601 console.info(`Succeeded in getting wakeup source files, param:${param}`); 602 }).catch((err: BusinessError) => { 603 console.error(`Failed to get wakeup source files, Code:${err.code}, message:${err.message}`); 604 }); 605} 606``` 607 608### enrollWithWakeupFilesForResult<sup>12+</sup> 609 610enrollWithWakeupFilesForResult(wakeupFiles: Array\<WakeupSourceFile\>, wakeupInfo: string): Promise\<EnrollResult\> 611 612Registers with wakeup resource files to obtain wakeup word evaluation results. This API uses a promise to return the result. 613 614**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 615 616**System capability**: SystemCapability.AI.IntelligentVoice.Core 617 618**Parameters** 619 620| Name | Type | Mandatory| Description | 621| -------- | -------------------------------- | --- | ------------------------------------------- | 622| wakeupFiles | Array\<[WakeupSourceFile](#wakeupsourcefile12)\> | Yes | Wakeup resource files.| 623| wakeupInfo | string | Yes | Wakeup information, including the type and version of the source and target devices.| 624 625**Return value** 626 627| Type | Description | 628| ----------------------------------------------- | ---------------------------- | 629| Promise<[EnrollResult](#enrollresult)> | Promise used to return the result. | 630 631**Error codes** 632 633For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 634 635| ID| Error Message| 636| ------- | --------------------------------------------| 637| 201 | Permission denied. | 638| 202 | Not system application. | 639| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 640| 22700101 | No memory. | 641| 22700102 | Invalid parameter. | 642| 22700107 | System error. | 643 644**Example** 645 646```ts 647import { BusinessError } from '@kit.BasicServicesKit'; 648 649let filesInfo: Array<intelligentVoice.WakeupSourceFile> = []; 650filesInfo[0] = {filePath: "", fileContent: new ArrayBuffer(100)}; 651let wakeupInfo: string = "version: 123" 652 653if (wakeupManager != null) { 654 (wakeupManager as intelligentVoice.WakeupManager).enrollWithWakeupFilesForResult( 655 filesInfo, wakeupInfo).then( 656 (data: intelligentVoice.EnrollResult) => { 657 let param: intelligentVoice.EnrollResult = data; 658 console.info(`Succeeded in enrolling with wakeup files for result, param:${param}`); 659 }).catch((err: BusinessError) => { 660 console.error(`Failed to enroll with wakeup files for result, Code:${err.code}, message:${err.message}`); 661 }); 662} 663``` 664 665### clearUserData<sup>12+</sup> 666 667clearUserData(): Promise<void> 668 669Clears user data. This API uses a promise to return the result. 670 671**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 672 673**System capability**: SystemCapability.AI.IntelligentVoice.Core 674 675**Return value** 676 677| Type | Description | 678| ----------------------------------------------- | ---------------------------- | 679| Promise<void> | Promise that returns no value. | 680 681**Error codes** 682 683For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 684 685| ID| Error Message| 686| ------- | --------------------------------------------| 687| 201 | Permission denied. | 688| 202 | Not system application. | 689| 22700107 | System error. | 690 691**Example** 692 693```ts 694import { BusinessError } from '@kit.BasicServicesKit'; 695 696if (wakeupManager != null) { 697 (wakeupManager as intelligentVoice.WakeupManager).clearUserData().then(() => { 698 console.info(`Succeeded in clearing user data.`); 699 }).catch((err: BusinessError) => { 700 console.error(`Failed to clear user data, Code:${err.code}, message:${err.message}`); 701 }); 702} 703``` 704 705## UploadFileType<sup>12+</sup> 706 707Enumerates upload file types. 708 709**System capability**: SystemCapability.AI.IntelligentVoice.Core 710 711| Name | Value | Description | 712| ------------------------- | ---- | ------------ | 713| ENROLL_FILE | 0 | Registration file. | 714| WAKEUP_FILE | 1 | Wakeup file. | 715 716## UploadFile<sup>12+</sup> 717 718Defines an upload file, including the file type, file description, and content. 719 720**System capability**: SystemCapability.AI.IntelligentVoice.Core 721 722| Name | Type | Mandatory | Description | 723| ------ | ----------------------------- | -------------- | ---------- | 724| type | [UploadFileType](#uploadfiletype12) | Yes | File type.| 725| filesDescription | string | Yes | File description.| 726| filesContent | Array\<ArrayBuffer\> | Yes | File content.| 727 728## WakeupSourceFile<sup>12+</sup> 729 730Defines a wakeup resource file. 731 732**System capability**: SystemCapability.AI.IntelligentVoice.Core 733 734| Name | Type | Mandatory | Description | 735| ------ | ----------------------------- | -------------- | ---------- | 736| filePath | string | Yes | File path.| 737| fileContent | ArrayBuffer | Yes | File content.| 738 739## EvaluationResultCode<sup>12+</sup> 740 741Enumerates result codes for custom wakeup keywords. 742 743**System capability**: SystemCapability.AI.IntelligentVoice.Core 744 745| Name | Value | Description | 746| ------------------------- | ---- | ------------ | 747| UNKNOWN | 0 | Unknown error. | 748| PASS | 1 | Passed. | 749| WORD_EMPTY | 2 | Empty word. | 750| CHINESE_ONLY | 3 | Chinese only. | 751| INVALID_LENGTH | 4 | Invalid length. | 752| UNUSUAL_WORD | 5 | Unusual word. | 753| CONSECUTIVE_SAME_WORD | 6 | Consecutive same words. | 754| TOO_FEW_PHONEMES | 7 | Too few phonemes. | 755| TOO_MANY_PHONEMES | 8 | Too many phonemes. | 756| COMMON_INSTRUCTION | 9 | Common instructions included. | 757| COMMON_SPOKEN_LANGUAGE | 10 | Common spoken language included. | 758| SENSITIVE_WORD | 11 | Sensitive words included. | 759| NO_INITIAL_CONSONANT | 12 | Two consecutive words without initial consonants. | 760| REPEATED_PHONEME | 13 | Duplicate phonemes included. | 761 762## EvaluationResult<sup>12+</sup> 763 764Defines the wakeup word evaluation result. 765 766**System capability**: SystemCapability.AI.IntelligentVoice.Core 767 768| Name | Type | Mandatory | Description | 769| ------ | ----------------------------- | -------------- | ---------- | 770| score | number | Yes | Evaluation score of a custom wakeup keyword. The value ranges from 0 to 5.| 771| resultCode | [EvaluationResultCode](#evaluationresultcode12) | Yes | Evaluation result code.| 772 773## ServiceChangeType 774 775Enumerates service status change types. 776 777**System capability**: SystemCapability.AI.IntelligentVoice.Core 778 779| Name | Value | Description | 780| ------------------------- | ---- | ------------ | 781| SERVICE_UNAVAILABLE | 0 | The service is unavailable. | 782 783## IntelligentVoiceEngineType 784 785Enumerates intelligent voice engine types. 786 787**System capability**: SystemCapability.AI.IntelligentVoice.Core 788 789| Name | Value | Description | 790| ------------------------- | ---- | ------------ | 791| ENROLL_ENGINE_TYPE | 0 | Voice enrollment engine. | 792| WAKEUP_ENGINE_TYPE | 1 | Voice wakeup engine. | 793| UPDATE_ENGINE_TYPE | 2 | Silent update engine. | 794 795## EnrollIntelligentVoiceEngineDescriptor 796 797Defines the descriptor of an intelligent voice enrollment engine. 798 799**System capability**: SystemCapability.AI.IntelligentVoice.Core 800 801| Name | Type | Mandatory | Description | 802| ------ | ----------------------------- | -------------- | ---------- | 803| wakeupPhrase | string | Yes | Wakeup phrase.| 804 805## WakeupIntelligentVoiceEngineDescriptor 806 807Defines the descriptor of an intelligent voice wakeup engine. 808 809**System capability**: SystemCapability.AI.IntelligentVoice.Core 810 811| Name | Type | Mandatory | Description | 812| ------ | ----------------------------- | -------------- | ---------- | 813| 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.| 814| wakeupPhrase | string | Yes | Wakeup phrase.| 815 816## EnrollEngineConfig 817 818Defines the enrollment engine configuration. 819 820**System capability**: SystemCapability.AI.IntelligentVoice.Core 821 822| Name | Type | Mandatory | Description | 823| ------ | ----------------------------- | -------------- | ---------- | 824| language | string | Yes | Language supported by the enrollment engine. Only Chinese is supported currently, and the value is **zh**.| 825| region | string | Yes | Country/region supported by the enrollment engine. Only China is supported currently, and the value is **CN**.| 826 827## SensibilityType 828 829Enumerates wakeup sensibility types. 830A sensibility type maps to a wakeup threshold. A higher sensibility indicates a lower threshold and a higher wakeup probability. 831 832**System capability**: SystemCapability.AI.IntelligentVoice.Core 833 834| Name | Value | Description | 835| ------------------------- | ---- | ------------ | 836| LOW_SENSIBILITY | 1 | Low sensibility. | 837| MIDDLE_SENSIBILITY | 2 | Medium sensibility. | 838| HIGH_SENSIBILITY | 3 | High sensibility. | 839 840## WakeupHapInfo 841 842Defines the HAP information for a wakeup application. 843 844**System capability**: SystemCapability.AI.IntelligentVoice.Core 845 846| Name | Type | Mandatory | Description | 847| ------ | ----------------------------- | -------------- | ---------- | 848| bundleName | string | Yes | Bundle name of the wakeup application.| 849| abilityName | string | Yes | Ability name of the wakeup application.| 850 851## WakeupIntelligentVoiceEventType 852 853Enumerates types of intelligent voice wakeup events. 854 855**System capability**: SystemCapability.AI.IntelligentVoice.Core 856 857| Name | Value | Description | 858| ------------------------- | ---- | ------------ | 859| INTELLIGENT_VOICE_EVENT_WAKEUP_NONE | 0 | No wakeup. | 860| INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE | 1 | Wakeup recognition completed. | 861| INTELLIGENT_VOICE_EVENT_HEADSET_RECOGNIZE_COMPLETE<sup>12+</sup> | 2 | Headset wakeup recognition completed. | 862 863## IntelligentVoiceErrorCode 864 865Enumerates error codes of intelligent voice wakeup. 866 867**System capability**: SystemCapability.AI.IntelligentVoice.Core 868 869| Name | Value | Description | 870| ------------------------- | ---- | ------------ | 871| INTELLIGENT_VOICE_NO_MEMORY | 22700101 | Insufficient memory. | 872| INTELLIGENT_VOICE_INVALID_PARAM | 22700102 | Invalid parameter. | 873| INTELLIGENT_VOICE_INIT_FAILED | 22700103 | Enrollment failed. | 874| INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED | 22700104 | Enrollment commit failed. | 875| INTELLIGENT_VOICE_START_CAPTURER_FAILED<sup>12+</sup> | 22700105 | Failed to start reading streams. | 876| INTELLIGENT_VOICE_READ_FAILED<sup>12+</sup> | 22700106 | Failed to read streams. | 877| INTELLIGENT_VOICE_SYSTEM_ERROR<sup>12+</sup> | 22700107 | System error. | 878 879## CapturerChannel<sup>12+</sup> 880 881Enumerates capturer channels. 882 883**System capability**: SystemCapability.AI.IntelligentVoice.Core 884 885| Name | Value | Description | 886| ------------------------- | ---- | ------------ | 887| CAPTURER_CHANNEL_1 | 0x1 << 0 | Audio channel 1. | 888| CAPTURER_CHANNEL_2 | 0x1 << 1 | Audio channel 2. | 889| CAPTURER_CHANNEL_3 | 0x1 << 2 | Audio channel 3. | 890| CAPTURER_CHANNEL_4 | 0x1 << 3 | Audio channel 4. | 891 892## EnrollResult 893 894Enumerates enrollment results. 895 896**System capability**: SystemCapability.AI.IntelligentVoice.Core 897 898| Name | Value | Description | 899| ------------------------- | ---- | ------------ | 900| SUCCESS | 0 | Enrollment succeeded. | 901| VPR_TRAIN_FAILED | -1 | Voiceprint training failed. | 902| WAKEUP_PHRASE_NOT_MATCH | -2 | Wakeup phrase mismatched. | 903| TOO_NOISY | -3 | Environment too noisy. | 904| TOO_LOUD | -4 | Voice too loud. | 905| INTERVAL_LARGE | -5 | Interval between wakeup phrases too long. | 906| DIFFERENT_PERSON | -6 | Wakeup phrases enrolled by different persons. | 907| UNKNOWN_ERROR | -100 | Unknown error. | 908 909## EnrollCallbackInfo 910 911Defines the enrollment callback information. 912 913**System capability**: SystemCapability.AI.IntelligentVoice.Core 914 915| Name | Type | Mandatory | Description | 916| ------ | ----------------------------- | -------------- | ---------- | 917| result | [EnrollResult](#enrollresult) | Yes | Enrollment result.| 918| context | string | Yes | Context of the enrollment event.| 919 920## WakeupIntelligentVoiceEngineCallbackInfo 921 922Defines the callback information for the intelligent voice wakeup engine. 923 924**System capability**: SystemCapability.AI.IntelligentVoice.Core 925 926| Name | Type | Mandatory | Description | 927| ------ | ----------------------------- | -------------- | ---------- | 928| eventId | [WakeupIntelligentVoiceEventType](#wakeupintelligentvoiceeventtype) | Yes | Event type of the intelligent voice wakeup engine.| 929| isSuccess | boolean | Yes | Wakeup result. The value **true** indicates that the wakeup is successful, and the value **false** indicates the opposite.| 930| context | string | Yes | Context of the wakeup event.| 931 932## EnrollIntelligentVoiceEngine 933 934Class 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. 935 936### getSupportedRegions 937 938getSupportedRegions(callback: AsyncCallback<Array<string>>): void 939 940Obtains the list of supported countries/regions. This API uses an asynchronous callback to return the result. 941 942**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 943 944**System capability**: SystemCapability.AI.IntelligentVoice.Core 945 946**Parameters** 947 948| Name | Type | Mandatory| Description | 949| -------- | -------------------------------- | --- | ------------------------------------------- | 950| callback | AsyncCallback<Array<string>> | 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**.| 951 952**Error codes** 953 954For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 955 956| ID| Error Message| 957| ------- | --------------------------------------------| 958| 201 | Permission denied. | 959| 202 | Not system application. | 960 961**Example** 962 963```ts 964import { BusinessError } from '@kit.BasicServicesKit'; 965 966let regions: Array<string> | null = null; 967if (enrollIntelligentVoiceEngine != null) { 968 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getSupportedRegions((err: BusinessError, data: Array<string>) => { 969 if (err) { 970 console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`); 971 } else { 972 regions = data; 973 console.info(`Succeeded in getting supported regions, regions:${regions}.`); 974 } 975 }); 976} 977``` 978 979### getSupportedRegions 980 981getSupportedRegions(): Promise<Array<string>> 982 983Obtains the list of supported countries/regions. This API uses a promise to return the result. 984 985**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 986 987**System capability**: SystemCapability.AI.IntelligentVoice.Core 988 989**Return value** 990 991| Type | Description | 992| ----------------------------------------------- | ---------------------------- | 993| 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**. | 994 995**Error codes** 996 997For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 998 999| ID| Error Message| 1000| ------- | --------------------------------------------| 1001| 201 | Permission denied. | 1002| 202 | Not system application. | 1003 1004**Example** 1005 1006```ts 1007import { BusinessError } from '@kit.BasicServicesKit'; 1008 1009let regions: Array<string> | null = null; 1010if (enrollIntelligentVoiceEngine != null) { 1011 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getSupportedRegions().then((data: Array<string>) => { 1012 regions = data; 1013 console.info('Succeeded in getting supported regions, regions:${regions}.'); 1014 }).catch((err: BusinessError) => { 1015 console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`); 1016 }); 1017} 1018``` 1019 1020### init 1021 1022init(config: EnrollEngineConfig, callback: AsyncCallback<void>): void 1023 1024Initializes the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result. 1025 1026**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1027 1028**System capability**: SystemCapability.AI.IntelligentVoice.Core 1029 1030**Parameters** 1031 1032| Name | Type | Mandatory| Description | 1033| -------- | -------------------------------- | --- | ------------------------------------------- | 1034| config | [EnrollEngineConfig](#enrollengineconfig) | Yes | Configuration of the intelligent voice enrollment engine.| 1035| callback |AsyncCallback<void> | Yes | Callback used to return the result.| 1036 1037**Error codes** 1038 1039For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1040 1041| ID| Error Message| 1042| ------- | --------------------------------------------| 1043| 201 | Permission denied. | 1044| 202 | Not system application. | 1045| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1046| 22700102 | Invalid parameter. | 1047| 22700103 | Init failed. | 1048 1049**Example** 1050 1051```ts 1052import { BusinessError } from '@kit.BasicServicesKit'; 1053 1054let config: intelligentVoice.EnrollEngineConfig = { 1055 language: 'zh', 1056 region: 'CN', 1057} 1058if (enrollIntelligentVoiceEngine != null) { 1059 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).init(config, (err: BusinessError) => { 1060 if (err) { 1061 console.error(`Failed to initialize enrollIntelligentVoice engine. Code:${err.code}, message:${err.message}`); 1062 } else { 1063 console.info(`Succeeded in initialzing enrollIntelligentVoice engine.`); 1064 } 1065 }); 1066} 1067``` 1068 1069### init 1070 1071init(config: EnrollEngineConfig): Promise<void> 1072 1073Initializes the intelligent voice enrollment engine. This API uses a promise to return the result. 1074 1075**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1076 1077**System capability**: SystemCapability.AI.IntelligentVoice.Core 1078 1079**Parameters** 1080 1081| Name | Type | Mandatory| Description | 1082| -------- | -------------------------------- | --- | ------------------------------------------- | 1083| config | [EnrollEngineConfig](#enrollengineconfig) | Yes | Configuration of the intelligent voice enrollment engine.| 1084 1085**Return value** 1086 1087| Type | Description | 1088| ----------------------------------------------- | ---------------------------- | 1089| Promise<void> | Promise that returns no value. | 1090 1091**Error codes** 1092 1093For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1094 1095| ID| Error Message| 1096| ------- | --------------------------------------------| 1097| 201 | Permission denied. | 1098| 202 | Not system application. | 1099| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1100| 22700102 | Invalid parameter. | 1101| 22700103 | Init failed. | 1102 1103**Example** 1104 1105```ts 1106import { BusinessError } from '@kit.BasicServicesKit'; 1107 1108let config: intelligentVoice.EnrollEngineConfig = { 1109 language: 'zh', 1110 region: 'CN', 1111} 1112if (enrollIntelligentVoiceEngine != null) { 1113 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).init(config).then(() => { 1114 console.info(`Succeeded in initializing enrollIntelligentVoice engine.`); 1115 }).catch((err: BusinessError) => { 1116 console.error(`Failed to initialize enrollIntelligentVoice engine. Code:${err.code}, message:${err.message}`); 1117 }); 1118} 1119 1120``` 1121 1122### enrollForResult 1123 1124enrollForResult(isLast: boolean, callback: AsyncCallback<EnrollCallbackInfo>): void 1125 1126Obtains the enrollment result. This API uses an asynchronous callback to return the result. 1127 1128**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1129 1130**System capability**: SystemCapability.AI.IntelligentVoice.Core 1131 1132**Parameters** 1133 1134| Name | Type | Mandatory| Description | 1135| -------- | -------------------------------- | --- | ------------------------------------------- | 1136| isLast | boolean | Yes | Whether this is the last enrollment. The value **true** indicates the last enrollment, and the value **false** indicates the opposite.| 1137| callback | AsyncCallback<[EnrollCallbackInfo](#enrollcallbackinfo)> | Yes | Callback used to return the result.| 1138 1139**Error codes** 1140 1141For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1142 1143| ID| Error Message| 1144| ------- | --------------------------------------------| 1145| 201 | Permission denied. | 1146| 202 | Not system application. | 1147| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1148 1149**Example** 1150 1151```ts 1152import { BusinessError } from '@kit.BasicServicesKit'; 1153 1154let callbackInfo: intelligentVoice.EnrollCallbackInfo | null = null; 1155if (enrollIntelligentVoiceEngine != null) { 1156 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).enrollForResult(true, (err: BusinessError, data: intelligentVoice.EnrollCallbackInfo) => { 1157 if (err) { 1158 console.error(`Failed to enroll for result, Code:${err.code}, message:${err.message}`); 1159 } else { 1160 callbackInfo = data; 1161 console.info(`Succeeded in enrolling for result, info:${callbackInfo}.`); 1162 } 1163 }); 1164} 1165``` 1166 1167### enrollForResult 1168 1169enrollForResult(isLast: boolean): Promise<EnrollCallbackInfo> 1170 1171Obtains the enrollment result. This API uses a promise to return the result. 1172 1173**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1174 1175**System capability**: SystemCapability.AI.IntelligentVoice.Core 1176 1177**Parameters** 1178 1179| Name | Type | Mandatory| Description | 1180| -------- | -------------------------------- | --- | ------------------------------------------- | 1181| isLast | boolean | Yes | Whether this is the last enrollment. The value **true** indicates the last enrollment, and the value **false** indicates the opposite.| 1182 1183**Return value** 1184 1185| Type | Description | 1186| ----------------------------------------------- | ---------------------------- | 1187| Promise<[EnrollCallbackInfo](#enrollcallbackinfo)> | Promise used to return the result. | 1188 1189**Error codes** 1190 1191For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1192 1193| ID| Error Message| 1194| ------- | --------------------------------------------| 1195| 201 | Permission denied. | 1196| 202 | Not system application. | 1197| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1198 1199**Example** 1200 1201```ts 1202import { BusinessError } from '@kit.BasicServicesKit'; 1203 1204let callbackInfo: intelligentVoice.EnrollCallbackInfo | null = null; 1205if (enrollIntelligentVoiceEngine != null) { 1206 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).enrollForResult(true).then((data: intelligentVoice.EnrollCallbackInfo) => { 1207 callbackInfo = data; 1208 console.info(`Succeeded in enrolling for result, info:${callbackInfo}.`); 1209 }).catch((err: BusinessError) => { 1210 console.error(`Failed to enroll for result, Code:${err.code}, message:${err.message}`); 1211 }); 1212} 1213``` 1214 1215### stop 1216 1217stop(callback: AsyncCallback<void>): void 1218 1219Stops the enrollment. This API uses an asynchronous callback to return the result. 1220 1221**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1222 1223**System capability**: SystemCapability.AI.IntelligentVoice.Core 1224 1225| Name | Type | Mandatory| Description | 1226| -------- | -------------------------------- | --- | ------------------------------------------- | 1227| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1228 1229**Error codes** 1230 1231For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1232 1233| ID| Error Message| 1234| ------- | --------------------------------------------| 1235| 201 | Permission denied. | 1236| 202 | Not system application. | 1237 1238**Example** 1239 1240```ts 1241import { BusinessError } from '@kit.BasicServicesKit'; 1242 1243if (enrollIntelligentVoiceEngine != null) { 1244 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).stop((err: BusinessError) => { 1245 if (err) { 1246 console.error(`Failed to stop enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 1247 } else { 1248 console.info(`Succeeded in stopping enrollIntelligentVoice engine.`); 1249 } 1250 }); 1251} 1252``` 1253 1254### stop 1255 1256stop(): Promise<void> 1257 1258Stops the enrollment. This API uses a promise to return the result. 1259 1260**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1261 1262**System capability**: SystemCapability.AI.IntelligentVoice.Core 1263 1264**Return value** 1265 1266| Type | Description | 1267| ----------------------------------------------- | ---------------------------- | 1268| Promise<void> | Promise that returns no value. | 1269 1270**Error codes** 1271 1272For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1273 1274| ID| Error Message| 1275| ------- | --------------------------------------------| 1276| 201 | Permission denied. | 1277| 202 | Not system application. | 1278 1279**Example** 1280 1281```ts 1282import { BusinessError } from '@kit.BasicServicesKit'; 1283 1284if (enrollIntelligentVoiceEngine != null) { 1285 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).stop().then(() => { 1286 console.info(`Succeeded in stopping enrollIntelligentVoice engine.`); 1287 }).catch((err:BusinessError) => { 1288 console.error(`Failed to stop enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 1289 }); 1290} 1291``` 1292 1293### commit 1294 1295commit(callback: AsyncCallback<void>): void 1296 1297Commits the enrollment. This API uses an asynchronous callback to return the result. 1298 1299**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1300 1301**System capability**: SystemCapability.AI.IntelligentVoice.Core 1302 1303**Parameters** 1304 1305| Name | Type | Mandatory| Description | 1306| -------- | -------------------------------- | --- | ------------------------------------------- | 1307| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1308 1309**Error codes** 1310 1311For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1312 1313| ID| Error Message| 1314| ------- | --------------------------------------------| 1315| 201 | Permission denied. | 1316| 202 | Not system application. | 1317| 22700104 | Failed to commit the enrollment. | 1318 1319**Example** 1320 1321```ts 1322import { BusinessError } from '@kit.BasicServicesKit'; 1323 1324if (enrollIntelligentVoiceEngine != null) { 1325 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).commit((err: BusinessError) => { 1326 if (err) { 1327 console.error(`Failed to commit enroll, Code:${err.code}, message:${err.message}`); 1328 } else { 1329 console.info(`Succeeded in committing enroll.`); 1330 } 1331 }); 1332} 1333``` 1334 1335### commit 1336 1337commit(): Promise<void> 1338 1339Commits the enrollment. This API uses a promise to return the result. 1340 1341**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1342 1343**System capability**: SystemCapability.AI.IntelligentVoice.Core 1344 1345**Return value** 1346 1347| Type | Description | 1348| ----------------------------------------------- | ---------------------------- | 1349| Promise<void> | Promise that returns no value. | 1350 1351**Error codes** 1352 1353For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1354 1355| ID| Error Message| 1356| ------- | --------------------------------------------| 1357| 201 | Permission denied. | 1358| 202 | Not system application. | 1359| 22700104 | Failed to commit the enrollment. | 1360 1361**Example** 1362 1363```ts 1364import { BusinessError } from '@kit.BasicServicesKit'; 1365 1366if (enrollIntelligentVoiceEngine != null) { 1367 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).commit().then(() => { 1368 console.info(`Succeeded in committing enroll.`); 1369 }).catch((err: BusinessError) => { 1370 console.error(`Failed to commit enroll, Code:${err.code}, message:${err.message}`); 1371 }); 1372} 1373``` 1374 1375### setWakeupHapInfo 1376 1377setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback\<void>): void 1378 1379Sets the HAP information for the wakeup application. This API uses an asynchronous callback to return the result. 1380 1381**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1382 1383**System capability**: SystemCapability.AI.IntelligentVoice.Core 1384 1385**Parameters** 1386 1387| Name | Type | Mandatory| Description | 1388| -------- | -------------------------------- | --- | ------------------------------------------- | 1389| info | [WakeupHapInfo](#wakeuphapinfo) | Yes | HAP information for the wakeup application.| 1390| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1391 1392**Error codes** 1393 1394For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1395 1396| ID| Error Message| 1397| ------- | --------------------------------------------| 1398| 201 | Permission denied. | 1399| 202 | Not system application. | 1400| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1401| 22700102 | Invalid parameter. | 1402 1403**Example** 1404 1405```ts 1406import { BusinessError } from '@kit.BasicServicesKit'; 1407 1408let info: intelligentVoice.WakeupHapInfo = { 1409 bundleName: 'com.wakeup', 1410 abilityName: 'WakeUpExtAbility', 1411} 1412if (enrollIntelligentVoiceEngine != null) { 1413 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setWakeupHapInfo(info, (err: BusinessError) => { 1414 if (err) { 1415 console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`); 1416 } else { 1417 console.info(`Succeeded in setting wakeup hap info.`); 1418 } 1419 }); 1420} 1421``` 1422 1423### setWakeupHapInfo 1424 1425setWakeupHapInfo(info: WakeupHapInfo): Promise\<void\> 1426 1427Sets the HAP information for the wakeup application. This API uses a promise to return the result. 1428 1429**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1430 1431**System capability**: SystemCapability.AI.IntelligentVoice.Core 1432 1433**Parameters** 1434 1435| Name | Type | Mandatory| Description | 1436| -------- | -------------------------------- | --- | ------------------------------------------- | 1437| info | [WakeupHapInfo](#wakeuphapinfo) | Yes | HAP information for the wakeup application.| 1438 1439**Return value** 1440 1441| Type | Description | 1442| ----------------------------------------------- | ---------------------------- | 1443| Promise<void> | Promise that returns no value. | 1444 1445**Error codes** 1446 1447For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1448 1449| ID| Error Message| 1450| ------- | --------------------------------------------| 1451| 201 | Permission denied. | 1452| 202 | Not system application. | 1453| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1454| 22700102 | Invalid parameter. | 1455 1456**Example** 1457 1458```ts 1459import { BusinessError } from '@kit.BasicServicesKit'; 1460 1461let info: intelligentVoice.WakeupHapInfo = { 1462 bundleName: 'com.wakeup', 1463 abilityName: 'WakeUpExtAbility', 1464} 1465if (enrollIntelligentVoiceEngine != null) { 1466 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setWakeupHapInfo(info).then(() => { 1467 console.info(`Succeeded in setting wakeup hap info.`); 1468 }).catch((err: BusinessError) => { 1469 console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`); 1470 }); 1471} 1472``` 1473 1474### setSensibility 1475 1476setSensibility(sensibility: SensibilityType, callback: AsyncCallback\<void\>): void 1477 1478Sets the wakeup sensibility. This API uses an asynchronous callback to return the result. 1479 1480**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1481 1482**System capability**: SystemCapability.AI.IntelligentVoice.Core 1483 1484**Parameters** 1485 1486| Name | Type | Mandatory| Description | 1487| -------- | -------------------------------- | --- | ------------------------------------------- | 1488| sensibility | [SensibilityType](#sensibilitytype) | Yes | Sensibility type.| 1489| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1490 1491**Error codes** 1492 1493For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1494 1495| ID| Error Message| 1496| ------- | --------------------------------------------| 1497| 201 | Permission denied. | 1498| 202 | Not system application. | 1499| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1500| 22700102 | Invalid parameter. | 1501 1502**Example** 1503 1504```ts 1505import { BusinessError } from '@kit.BasicServicesKit'; 1506 1507if (enrollIntelligentVoiceEngine != null) { 1508 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY, (err: BusinessError) => { 1509 if (err) { 1510 console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`); 1511 } else { 1512 console.info(`Succeeded in setting sensibility.`); 1513 } 1514 }); 1515} 1516``` 1517 1518### setSensibility 1519 1520setSensibility(sensibility: SensibilityType): Promise\<void\> 1521 1522Sets the wakeup sensibility. This API uses a promise to return the result. 1523 1524**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1525 1526**System capability**: SystemCapability.AI.IntelligentVoice.Core 1527 1528**Parameters** 1529 1530| Name | Type | Mandatory| Description | 1531| -------- | -------------------------------- | --- | ------------------------------------------- | 1532| sensibility | [SensibilityType](#sensibilitytype) | Yes | Sensibility type.| 1533 1534**Return value** 1535 1536| Type | Description | 1537| ----------------------------------------------- | ---------------------------- | 1538| Promise<void> | Promise that returns no value. | 1539 1540**Error codes** 1541 1542For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1543 1544| ID| Error Message| 1545| ------- | --------------------------------------------| 1546| 201 | Permission denied. | 1547| 202 | Not system application. | 1548| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1549| 22700102 | Invalid parameter. | 1550 1551**Example** 1552 1553```ts 1554import { BusinessError } from '@kit.BasicServicesKit'; 1555 1556if (enrollIntelligentVoiceEngine != null) { 1557 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY).then(() => { 1558 console.info(`Succeeded in setting sensibility.`); 1559 }).catch((err: BusinessError) => { 1560 console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`); 1561 }); 1562} 1563``` 1564 1565### setParameter 1566 1567setParameter(key: string, value: string, callback: AsyncCallback\<void\>): void 1568 1569Sets specified intelligent voice parameters. This API uses an asynchronous callback to return the result. 1570 1571**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1572 1573**System capability**: SystemCapability.AI.IntelligentVoice.Core 1574 1575**Parameters** 1576 1577| Name | Type | Mandatory| Description | 1578| -------- | -------------------------------- | --- | ------------------------------------------- | 1579| key | string | Yes | Key.| 1580| value | string | Yes | Value.| 1581| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1582 1583**Error codes** 1584 1585For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1586 1587| ID| Error Message| 1588| ------- | --------------------------------------------| 1589| 201 | Permission denied. | 1590| 202 | Not system application. | 1591| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1592| 22700102 | Invalid parameter. | 1593 1594**Example** 1595 1596```ts 1597import { BusinessError } from '@kit.BasicServicesKit'; 1598 1599if (enrollIntelligentVoiceEngine != null) { 1600 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setParameter('scene', '0', (err: BusinessError) => { 1601 if (err) { 1602 console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`); 1603 } else { 1604 console.info(`Succeeded in setting parameter`); 1605 } 1606 }); 1607} 1608``` 1609 1610### setParameter 1611 1612setParameter(key: string, value: string): Promise\<void\> 1613 1614Sets specified intelligent voice parameters. This API uses a promise to return the result. 1615 1616**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1617 1618**System capability**: SystemCapability.AI.IntelligentVoice.Core 1619 1620**Parameters** 1621 1622| Name | Type | Mandatory| Description | 1623| -------- | -------------------------------- | --- | ------------------------------------------- | 1624| key | string | Yes | Key.| 1625| value | string | Yes | Value.| 1626 1627**Return value** 1628 1629| Type | Description | 1630| ----------------------------------------------- | ---------------------------- | 1631| Promise<void> | Promise that returns no value. | 1632 1633**Error codes** 1634 1635For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1636 1637| ID| Error Message| 1638| ------- | --------------------------------------------| 1639| 201 | Permission denied. | 1640| 202 | Not system application. | 1641| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1642| 22700102 | Invalid parameter. | 1643 1644**Example** 1645 1646```ts 1647import { BusinessError } from '@kit.BasicServicesKit'; 1648 1649if (enrollIntelligentVoiceEngine != null) { 1650 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).setParameter('scene', '0').then(() => { 1651 console.info(`Succeeded in setting parameter`); 1652 }).catch((err: BusinessError) => { 1653 console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`); 1654 }); 1655} 1656``` 1657 1658### getParameter 1659 1660getParameter(key: string, callback: AsyncCallback\<string\>): void 1661 1662Obtains specified intelligent voice parameters. This API uses an asynchronous callback to return the result. 1663 1664**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1665 1666**System capability**: SystemCapability.AI.IntelligentVoice.Core 1667 1668**Parameters** 1669 1670| Name | Type | Mandatory| Description | 1671| -------- | -------------------------------- | --- | ------------------------------------------- | 1672| key | string | Yes | Key.| 1673| callback | AsyncCallback\<string\> | Yes | Callback used to return the result.| 1674 1675**Error codes** 1676 1677For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1678 1679| ID| Error Message| 1680| ------- | --------------------------------------------| 1681| 201 | Permission denied. | 1682| 202 | Not system application. | 1683| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1684| 22700102 | Invalid parameter. | 1685 1686**Example** 1687 1688```ts 1689import { BusinessError } from '@kit.BasicServicesKit'; 1690 1691if (enrollIntelligentVoiceEngine != null) { 1692 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getParameter('key', (err: BusinessError, data: string) => { 1693 if (err) { 1694 console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`); 1695 } else { 1696 let param: string = data; 1697 console.info(`Succeeded in getting parameter, param:${param}`); 1698 } 1699 }); 1700} 1701``` 1702 1703### getParameter 1704 1705getParameter(key: string): Promise\<string\> 1706 1707Obtains specified intelligent voice parameters. This API uses a promise to return the result. 1708 1709**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1710 1711**System capability**: SystemCapability.AI.IntelligentVoice.Core 1712 1713**Parameters** 1714 1715| Name | Type | Mandatory| Description | 1716| -------- | -------------------------------- | --- | ------------------------------------------- | 1717| key | string | Yes | Key.| 1718 1719**Return value** 1720 1721| Type | Description | 1722| ----------------------------------------------- | ---------------------------- | 1723| Promise\<string\> | Promise used to return the result. | 1724 1725**Error codes** 1726 1727For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1728 1729| ID| Error Message| 1730| ------- | --------------------------------------------| 1731| 201 | Permission denied. | 1732| 202 | Not system application. | 1733| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1734| 22700102 | Invalid parameter. | 1735 1736**Example** 1737 1738```ts 1739import { BusinessError } from '@kit.BasicServicesKit'; 1740 1741if (enrollIntelligentVoiceEngine != null) { 1742 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).getParameter('key').then((data: string) => { 1743 let param: string = data; 1744 console.info(`Succeeded in getting parameter, param:${param}`); 1745 }).catch((err: BusinessError) => { 1746 console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`); 1747 }); 1748} 1749``` 1750 1751### evaluateForResult<sup>12+</sup> 1752 1753evaluateForResult(word: string): Promise\<EvaluationResult\> 1754 1755Evaluates whether a custom wakeup keyword is effective. This API uses a promise to return the result. 1756 1757**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1758 1759**System capability**: SystemCapability.AI.IntelligentVoice.Core 1760 1761**Parameters** 1762 1763| Name | Type | Mandatory| Description | 1764| -------- | -------------------------------- | --- | ------------------------------------------- | 1765| word | string | Yes | Custom wakeup keyword.| 1766 1767**Return value** 1768 1769| Type | Description | 1770| ----------------------------------------------- | ---------------------------- | 1771| Promise<[EvaluationResult](#evaluationresult12)> | Promise used to return the result. | 1772 1773**Error codes** 1774 1775For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1776 1777| ID| Error Message| 1778| ------- | --------------------------------------------| 1779| 201 | Permission denied. | 1780| 202 | Not system application. | 1781| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1782| 22700107 | System error. | 1783 1784**Example** 1785 1786```ts 1787import { BusinessError } from '@kit.BasicServicesKit'; 1788 1789if (enrollIntelligentVoiceEngine != null) { 1790 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).evaluateForResult('word').then( 1791 (data: intelligentVoice.EvaluationResult) => { 1792 let param: intelligentVoice.EvaluationResult = data; 1793 console.info(`Succeeded in evaluating, param:${param}`); 1794 }).catch((err: BusinessError) => { 1795 console.error(`Failed to evaluate, Code:${err.code}, message:${err.message}`); 1796 }); 1797} 1798``` 1799 1800### release 1801 1802release(callback: AsyncCallback<void>): void 1803 1804Releases the intelligent voice enrollment engine. This API uses an asynchronous callback to return the result. 1805 1806**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1807 1808**System capability**: SystemCapability.AI.IntelligentVoice.Core 1809 1810**Parameters** 1811 1812| Name | Type | Mandatory| Description | 1813| -------- | -------------------------------- | --- | ------------------------------------------- | 1814| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1815 1816**Error codes** 1817 1818For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1819 1820| ID| Error Message| 1821| ------- | --------------------------------------------| 1822| 201 | Permission denied. | 1823| 202 | Not system application. | 1824 1825**Example** 1826 1827```ts 1828import { BusinessError } from '@kit.BasicServicesKit'; 1829 1830if (enrollIntelligentVoiceEngine != null) { 1831 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).release((err: BusinessError) => { 1832 if (err) { 1833 console.error(`Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 1834 } else { 1835 console.info(`Succeeded in releasing enrollIntelligentVoice engine.`); 1836 } 1837 }); 1838} 1839``` 1840 1841### release 1842 1843release(): Promise<void> 1844 1845Releases the intelligent voice enrollment engine. This API uses a promise to return the result. 1846 1847**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1848 1849**System capability**: SystemCapability.AI.IntelligentVoice.Core 1850 1851**Return value** 1852 1853| Type | Description | 1854| ----------------------------------------------- | ---------------------------- | 1855| Promise<void> | Promise that returns no value. | 1856 1857**Error codes** 1858 1859For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1860 1861| ID| Error Message| 1862| ------- | --------------------------------------------| 1863| 201 | Permission denied. | 1864| 202 | Not system application. | 1865 1866**Example** 1867 1868```ts 1869import { BusinessError } from '@kit.BasicServicesKit'; 1870 1871if (enrollIntelligentVoiceEngine != null) { 1872 (enrollIntelligentVoiceEngine as intelligentVoice.EnrollIntelligentVoiceEngine).release().then(() => { 1873 console.info(`Succeeded in releasing enrollIntelligentVoice engine.`); 1874 }).catch((err: BusinessError) => { 1875 console.error(`Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 1876 }); 1877} 1878``` 1879 1880## WakeupIntelligentVoiceEngine 1881 1882Class 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. 1883 1884### getSupportedRegions 1885 1886getSupportedRegions(callback: AsyncCallback<Array<string>>): void 1887 1888Obtains the list of supported countries/regions. This API uses an asynchronous callback to return the result. 1889 1890**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1891 1892**System capability**: SystemCapability.AI.IntelligentVoice.Core 1893 1894| Name | Type | Mandatory| Description | 1895| -------- | -------------------------------- | --- | ------------------------------------------- | 1896| callback | AsyncCallback<Array<string>> | 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**.| 1897 1898**Error codes** 1899 1900For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1901 1902| ID| Error Message| 1903| ------- | --------------------------------------------| 1904| 201 | Permission denied. | 1905| 202 | Not system application. | 1906 1907**Example** 1908 1909```ts 1910import { BusinessError } from '@kit.BasicServicesKit'; 1911 1912if (wakeupIntelligentVoiceEngine != null) { 1913 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getSupportedRegions((err: BusinessError, data: Array<string>) => { 1914 if (err) { 1915 console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`); 1916 } else { 1917 let regions: Array<string> = data; 1918 console.info(`Succeeded in getting supported regions, regions:${regions}.`); 1919 } 1920 }); 1921} 1922``` 1923 1924### getSupportedRegions 1925 1926getSupportedRegions(): Promise<Array<string>> 1927 1928Obtains the list of supported countries/regions. This API uses a promise to return the result. 1929 1930**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1931 1932**System capability**: SystemCapability.AI.IntelligentVoice.Core 1933 1934**Return value** 1935 1936| Type | Description | 1937| ----------------------------------------------- | ---------------------------- | 1938| 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**. | 1939 1940**Error codes** 1941 1942For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1943 1944| ID| Error Message| 1945| ------- | --------------------------------------------| 1946| 201 | Permission denied. | 1947| 202 | Not system application. | 1948 1949**Example** 1950 1951```ts 1952import { BusinessError } from '@kit.BasicServicesKit'; 1953 1954if (wakeupIntelligentVoiceEngine != null) { 1955 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getSupportedRegions().then((data: Array<string>) => { 1956 let regions: Array<string> = data; 1957 console.info(`Succeeded in getting supported regions, regions:${regions}.`); 1958 }).catch((err: BusinessError) => { 1959 console.error(`Failed to get supported regions, Code:${err.code}, message:${err.message}`); 1960 }); 1961} 1962``` 1963 1964### setWakeupHapInfo 1965 1966setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback\<void\>): void 1967 1968Sets the HAP information for the wakeup application. This API uses an asynchronous callback to return the result. 1969 1970**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 1971 1972**System capability**: SystemCapability.AI.IntelligentVoice.Core 1973 1974**Parameters** 1975 1976| Name | Type | Mandatory| Description | 1977| -------- | -------------------------------- | --- | ------------------------------------------- | 1978| info | [WakeupHapInfo](#wakeuphapinfo) | Yes | HAP information for the wakeup application.| 1979| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1980 1981**Error codes** 1982 1983For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 1984 1985| ID| Error Message| 1986| ------- | --------------------------------------------| 1987| 201 | Permission denied. | 1988| 202 | Not system application. | 1989| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 1990| 22700102 | Invalid parameter. | 1991 1992**Example** 1993 1994```ts 1995import { BusinessError } from '@kit.BasicServicesKit'; 1996 1997let hapInfo: intelligentVoice.WakeupHapInfo = { 1998 bundleName: 'com.wakeup', 1999 abilityName: 'WakeUpExtAbility', 2000} 2001 2002if (wakeupIntelligentVoiceEngine != null) { 2003 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setWakeupHapInfo(hapInfo, (err: BusinessError) => { 2004 if (err) { 2005 console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`); 2006 } else { 2007 console.info(`Succeeded in setting wakeup hap info.`); 2008 } 2009 }); 2010} 2011``` 2012 2013### setWakeupHapInfo 2014 2015setWakeupHapInfo(info: WakeupHapInfo): Promise\<void\> 2016 2017Sets the HAP information for the wakeup application. This API uses a promise to return the result. 2018 2019**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2020 2021**System capability**: SystemCapability.AI.IntelligentVoice.Core 2022 2023**Parameters** 2024 2025| Name | Type | Mandatory| Description | 2026| -------- | -------------------------------- | --- | ------------------------------------------- | 2027| info | [WakeupHapInfo](#wakeuphapinfo) | Yes | HAP information for the wakeup application.| 2028 2029**Return value** 2030 2031| Type | Description | 2032| ----------------------------------------------- | ---------------------------- | 2033| Promise<void> | Promise that returns no value. | 2034 2035**Error codes** 2036 2037For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2038 2039| ID| Error Message| 2040| ------- | --------------------------------------------| 2041| 201 | Permission denied. | 2042| 202 | Not system application. | 2043| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2044| 22700102 | Invalid parameter. | 2045 2046**Example** 2047 2048```ts 2049import { BusinessError } from '@kit.BasicServicesKit'; 2050 2051let hapInfo: intelligentVoice.WakeupHapInfo = { 2052 bundleName: 'com.wakeup', 2053 abilityName: 'WakeUpExtAbility', 2054} 2055if (wakeupIntelligentVoiceEngine != null) { 2056 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setWakeupHapInfo(hapInfo).then(() => { 2057 console.info(`Succeeded in setting wakeup hap info.`); 2058 }).catch((err: BusinessError) => { 2059 console.error(`Failed to set wakeup hap info, Code:${err.code}, message:${err.message}`); 2060 }); 2061} 2062``` 2063 2064### setSensibility 2065 2066setSensibility(sensibility: SensibilityType, callback: AsyncCallback\<void\>): void 2067 2068Sets the wakeup sensibility. This API uses an asynchronous callback to return the result. 2069 2070**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2071 2072**System capability**: SystemCapability.AI.IntelligentVoice.Core 2073 2074**Parameters** 2075 2076| Name | Type | Mandatory| Description | 2077| -------- | -------------------------------- | --- | ------------------------------------------- | 2078| sensibility | [SensibilityType](#sensibilitytype) | Yes | Sensibility type.| 2079| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2080 2081**Error codes** 2082 2083For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2084 2085| ID| Error Message| 2086| ------- | --------------------------------------------| 2087| 201 | Permission denied. | 2088| 202 | Not system application. | 2089| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2090| 22700102 | Invalid parameter. | 2091 2092**Example** 2093 2094```ts 2095import { BusinessError } from '@kit.BasicServicesKit'; 2096 2097if (wakeupIntelligentVoiceEngine != null) { 2098 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY, (err: BusinessError) => { 2099 if (err) { 2100 console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`); 2101 } else { 2102 console.info(`Succeeded in setting sensibility.`); 2103 } 2104 }); 2105} 2106``` 2107 2108### setSensibility 2109 2110setSensibility(sensibility: SensibilityType): Promise\<void\> 2111 2112Sets the wakeup sensibility. This API uses a promise to return the result. 2113 2114**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2115 2116**System capability**: SystemCapability.AI.IntelligentVoice.Core 2117 2118**Parameters** 2119 2120| Name | Type | Mandatory| Description | 2121| -------- | -------------------------------- | --- | ------------------------------------------- | 2122| sensibility | [SensibilityType](#sensibilitytype) | Yes | Sensibility type.| 2123 2124**Return value** 2125 2126| Type | Description | 2127| ----------------------------------------------- | ---------------------------- | 2128| Promise<void> | Promise that returns no value. | 2129 2130**Error codes** 2131 2132For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2133 2134| ID| Error Message| 2135| ------- | --------------------------------------------| 2136| 201 | Permission denied. | 2137| 202 | Not system application. | 2138| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2139| 22700102 | Invalid parameter. | 2140 2141**Example** 2142 2143```ts 2144import { BusinessError } from '@kit.BasicServicesKit'; 2145 2146if (wakeupIntelligentVoiceEngine != null) { 2147 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setSensibility(intelligentVoice.SensibilityType.LOW_SENSIBILITY).then(() => { 2148 console.info(`Succeeded in setting sensibility.`); 2149 }).catch((err: BusinessError) => { 2150 console.error(`Failed to set sensibility, Code:${err.code}, message:${err.message}`); 2151 }); 2152} 2153``` 2154 2155### setParameter 2156 2157setParameter(key: string, value: string, callback: AsyncCallback\<void\>): void 2158 2159Sets specified intelligent voice parameters. This API uses an asynchronous callback to return the result. 2160 2161**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2162 2163**System capability**: SystemCapability.AI.IntelligentVoice.Core 2164 2165**Parameters** 2166 2167| Name | Type | Mandatory| Description | 2168| -------- | -------------------------------- | --- | ------------------------------------------- | 2169| key | string | Yes | Key.| 2170| value | string | Yes | Value.| 2171| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2172 2173**Error codes** 2174 2175For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2176 2177| ID| Error Message| 2178| ------- | --------------------------------------------| 2179| 201 | Permission denied. | 2180| 202 | Not system application. | 2181| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2182| 22700102 | Invalid parameter. | 2183 2184**Example** 2185 2186```ts 2187import { BusinessError } from '@kit.BasicServicesKit'; 2188 2189if (wakeupIntelligentVoiceEngine != null) { 2190 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setParameter('scene', '0', (err: BusinessError) => { 2191 if (err) { 2192 console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`); 2193 } else { 2194 console.info(`Succeeded in setting parameter`); 2195 } 2196 }); 2197} 2198``` 2199 2200### setParameter 2201 2202setParameter(key: string, value: string): Promise\<void\> 2203 2204Sets specified intelligent voice parameters. This API uses a promise to return the result. 2205 2206**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2207 2208**System capability**: SystemCapability.AI.IntelligentVoice.Core 2209 2210**Parameters** 2211 2212| Name | Type | Mandatory| Description | 2213| -------- | -------------------------------- | --- | ------------------------------------------- | 2214| key | string | Yes | Key.| 2215| value | string | Yes | Value.| 2216 2217**Return value** 2218 2219| Type | Description | 2220| ----------------------------------------------- | ---------------------------- | 2221| Promise<void> | Promise that returns no value. | 2222 2223**Error codes** 2224 2225For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2226 2227| ID| Error Message| 2228| ------- | --------------------------------------------| 2229| 201 | Permission denied. | 2230| 202 | Not system application. | 2231| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2232| 22700102 | Invalid parameter. | 2233 2234**Example** 2235 2236```ts 2237import { BusinessError } from '@kit.BasicServicesKit'; 2238 2239if (wakeupIntelligentVoiceEngine != null) { 2240 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).setParameter('scene', '0').then(() => { 2241 console.info(`Succeeded in setting parameter`); 2242 }).catch((err: BusinessError) => { 2243 console.error(`Failed to set parameter, Code:${err.code}, message:${err.message}`); 2244 }); 2245} 2246``` 2247 2248### getParameter 2249 2250getParameter(key: string, callback: AsyncCallback\<string\>): void 2251 2252Obtains specified intelligent voice parameters. This API uses an asynchronous callback to return the result. 2253 2254**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2255 2256**System capability**: SystemCapability.AI.IntelligentVoice.Core 2257 2258**Parameters** 2259 2260| Name | Type | Mandatory| Description | 2261| -------- | -------------------------------- | --- | ------------------------------------------- | 2262| key | string | Yes | Key.| 2263| callback | AsyncCallback\<string\> | Yes | Callback used to return the result.| 2264 2265**Error codes** 2266 2267For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2268 2269| ID| Error Message| 2270| ------- | --------------------------------------------| 2271| 201 | Permission denied. | 2272| 202 | Not system application. | 2273| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2274| 22700102 | Invalid parameter. | 2275 2276**Example** 2277 2278```ts 2279import { BusinessError } from '@kit.BasicServicesKit'; 2280 2281if (wakeupIntelligentVoiceEngine != null) { 2282 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getParameter('key', (err: BusinessError, data: string) => { 2283 if (err) { 2284 console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`); 2285 } else { 2286 let param: string = data; 2287 console.info(`Succeeded in getting parameter, param:${param}`); 2288 } 2289 }); 2290} 2291``` 2292 2293### getParameter 2294 2295getParameter(key: string): Promise\<string\> 2296 2297Obtains specified intelligent voice parameters. This API uses a promise to return the result. 2298 2299**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2300 2301**System capability**: SystemCapability.AI.IntelligentVoice.Core 2302 2303**Parameters** 2304 2305| Name | Type | Mandatory| Description | 2306| -------- | -------------------------------- | --- | ------------------------------------------- | 2307| key | string | Yes | Key.| 2308 2309**Return value** 2310 2311| Type | Description | 2312| ----------------------------------------------- | ---------------------------- | 2313| Promise\<string\> | Promise used to return the result. | 2314 2315**Error codes** 2316 2317For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2318 2319| ID| Error Message| 2320| ------- | --------------------------------------------| 2321| 201 | Permission denied. | 2322| 202 | Not system application. | 2323| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2324| 22700102 | Invalid parameter. | 2325 2326**Example** 2327 2328```ts 2329import { BusinessError } from '@kit.BasicServicesKit'; 2330 2331if (wakeupIntelligentVoiceEngine != null) { 2332 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getParameter('key').then((data: string) => { 2333 let param: string = data; 2334 console.info(`Succeeded in getting parameter, param:${param}`); 2335 }).catch((err: BusinessError) => { 2336 console.error(`Failed to get parameter, Code:${err.code}, message:${err.message}`); 2337 }); 2338} 2339``` 2340 2341### getPcm<sup>12+</sup> 2342 2343getPcm(): Promise\<ArrayBuffer\> 2344 2345Obtains the Pulse Code Modulation (PCM) of audio signals. This API uses a promise to return the result. 2346 2347**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2348 2349**System capability**: SystemCapability.AI.IntelligentVoice.Core 2350 2351**Return value** 2352 2353| Type | Description | 2354| ----------------------------------------------- | ---------------------------- | 2355| Promise\<ArrayBuffer\> | Promise used to return the result. | 2356 2357**Error codes** 2358 2359For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2360 2361| ID| Error Message| 2362| ------- | --------------------------------------------| 2363| 201 | Permission denied. | 2364| 202 | Not system application. | 2365| 22700101 | No memory. | 2366| 22700107 | System error. | 2367 2368**Example** 2369 2370```ts 2371import { BusinessError } from '@kit.BasicServicesKit'; 2372 2373if (wakeupIntelligentVoiceEngine != null) { 2374 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).getPcm().then((data: ArrayBuffer) => { 2375 let param: ArrayBuffer = data; 2376 console.info(`Succeeded in getting pcm, param:${param}`); 2377 }).catch((err: BusinessError) => { 2378 console.error(`Failed to get pcm, Code:${err.code}, message:${err.message}`); 2379 }); 2380} 2381``` 2382 2383### startCapturer<sup>12+</sup> 2384 2385startCapturer(channels: number): Promise\<void\> 2386 2387Starts the capturer. This API uses a promise to return the result. 2388 2389**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2390 2391**System capability**: SystemCapability.AI.IntelligentVoice.Core 2392 2393**Parameters** 2394 2395| Name | Type | Mandatory| Description | 2396| -------- | -------------------------------- | --- | ------------------------------------------- | 2397| channels | number | Yes | Number of audio channels.| 2398 2399**Return value** 2400 2401| Type | Description | 2402| ----------------------------------------------- | ---------------------------- | 2403| Promise\<void\> | Promise that returns no value. | 2404 2405**Error codes** 2406 2407For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2408 2409| ID| Error Message| 2410| ------- | --------------------------------------------| 2411| 201 | Permission denied. | 2412| 202 | Not system application. | 2413| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.| 2414| 22700102 | Invalid parameter. | 2415| 22700105 | Start capturer failed. | 2416| 22700107 | System error. | 2417 2418**Example** 2419 2420```ts 2421import { BusinessError } from '@kit.BasicServicesKit'; 2422 2423if (wakeupIntelligentVoiceEngine != null) { 2424 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).startCapturer(1).then(() => { 2425 console.info(`Succeeded in starting capturer`); 2426 }).catch((err: BusinessError) => { 2427 console.error(`Failed to start capturer, Code:${err.code}, message:${err.message}`); 2428 }); 2429} 2430``` 2431 2432### read<sup>12+</sup> 2433 2434read(): Promise\<ArrayBuffer\> 2435 2436Reads audio data. This API uses a promise to return the result. 2437 2438**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2439 2440**System capability**: SystemCapability.AI.IntelligentVoice.Core 2441 2442**Return value** 2443 2444| Type | Description | 2445| ----------------------------------------------- | ---------------------------- | 2446| Promise\<ArrayBuffer\> | Promise used to return the result. | 2447 2448**Error codes** 2449 2450For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2451 2452| ID| Error Message| 2453| ------- | --------------------------------------------| 2454| 201 | Permission denied. | 2455| 202 | Not system application. | 2456| 22700101 | No memory. | 2457| 22700106 | Read failed. | 2458| 22700107 | System error. | 2459 2460**Example** 2461 2462```ts 2463import { BusinessError } from '@kit.BasicServicesKit'; 2464 2465if (wakeupIntelligentVoiceEngine != null) { 2466 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).read().then((data: ArrayBuffer) => { 2467 let param: ArrayBuffer = data; 2468 console.info(`Succeeded in reading data, param:${param}`); 2469 }).catch((err: BusinessError) => { 2470 console.error(`Failed to read data, Code:${err.code}, message:${err.message}`); 2471 }); 2472} 2473``` 2474 2475### stopCapturer<sup>12+</sup> 2476 2477stopCapturer(): Promise\<void\> 2478 2479Stops the capturer. This API uses a promise to return the result. 2480 2481**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2482 2483**System capability**: SystemCapability.AI.IntelligentVoice.Core 2484 2485**Return value** 2486 2487| Type | Description | 2488| ----------------------------------------------- | ---------------------------- | 2489| Promise\<void\> | Promise that returns no value. | 2490 2491**Error codes** 2492 2493For details about the following error codes, see [Universal Error Codes](../errorcode-universal.md) and [Intelligent Voice Error Codes](errorcode-intelligentVoice.md). 2494 2495| ID| Error Message| 2496| ------- | --------------------------------------------| 2497| 201 | Permission denied. | 2498| 202 | Not system application. | 2499| 22700107 | System error. | 2500 2501**Example** 2502 2503```ts 2504import { BusinessError } from '@kit.BasicServicesKit'; 2505 2506if (wakeupIntelligentVoiceEngine != null) { 2507 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).stopCapturer().then(() => { 2508 console.info(`Succeeded in stopping capturer`); 2509 }).catch((err: BusinessError) => { 2510 console.error(`Failed to stop capturer, Code:${err.code}, message:${err.message}`); 2511 }); 2512} 2513``` 2514 2515### release 2516 2517release(callback: AsyncCallback\<void\>): void 2518 2519Releases the intelligent voice wakeup engine. This API uses an asynchronous callback to return the result. 2520 2521**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2522 2523**System capability**: SystemCapability.AI.IntelligentVoice.Core 2524 2525**Parameters** 2526 2527| Name | Type | Mandatory| Description | 2528| -------- | -------------------------------- | --- | ------------------------------------------- | 2529| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2530 2531**Error codes** 2532 2533For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 2534 2535| ID| Error Message| 2536| ------- | --------------------------------------------| 2537| 201 | Permission denied. | 2538| 202 | Not system application. | 2539 2540**Example** 2541 2542```ts 2543import { BusinessError } from '@kit.BasicServicesKit'; 2544 2545if (wakeupIntelligentVoiceEngine != null) { 2546 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).release((err: BusinessError) => { 2547 if (err) { 2548 console.error(`Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 2549 } else { 2550 console.info(`Succeeded in releasing wakeupIntelligentVoice engine.`); 2551 } 2552 }); 2553} 2554``` 2555 2556### release 2557 2558release(): Promise\<void\> 2559 2560Releases the intelligent voice wakeup engine. This API uses a promise to return the result. 2561 2562**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2563 2564**System capability**: SystemCapability.AI.IntelligentVoice.Core 2565 2566**Return value** 2567 2568| Type | Description | 2569| ----------------------------------------------- | ---------------------------- | 2570| Promise<void> | Promise that returns no value. | 2571 2572**Error codes** 2573 2574For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 2575 2576| ID| Error Message| 2577| ------- | --------------------------------------------| 2578| 201 | Permission denied. | 2579| 202 | Not system application. | 2580 2581**Example** 2582 2583```ts 2584import { BusinessError } from '@kit.BasicServicesKit'; 2585 2586if (wakeupIntelligentVoiceEngine != null) { 2587 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).release().then(() => { 2588 console.info(`Succeeded in releasing wakeupIntelligentVoice engine.`); 2589 }).catch((err: BusinessError) => { 2590 console.error(`Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}`); 2591 }); 2592} 2593``` 2594 2595### on 2596 2597on(type: 'wakeupIntelligentVoiceEvent', callback: Callback\<WakeupIntelligentVoiceEngineCallbackInfo\>): void 2598 2599Subscribes to wakeup events. 2600 2601**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2602 2603**System capability**: SystemCapability.AI.IntelligentVoice.Core 2604 2605**Parameters** 2606 2607| Name | Type | Mandatory| Description | 2608| -------- | -------------------------------- | --- | ------------------------------------------- | 2609| type | string | Yes | Event type. This field has a fixed value of **wakeupIntelligentVoiceEvent**.| 2610| callback | Callback\<[WakeupIntelligentVoiceEngineCallbackInfo](#wakeupintelligentvoiceenginecallbackinfo)\> | Yes | Callback for processing of the wakeup event.| 2611 2612**Error codes** 2613 2614For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 2615 2616| ID| Error Message| 2617| ------- | --------------------------------------------| 2618| 201 | Permission denied. | 2619| 202 | Not system application. | 2620 2621**Example** 2622 2623```ts 2624if (wakeupIntelligentVoiceEngine != null) { 2625 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).on('wakeupIntelligentVoiceEvent', 2626 (info: intelligentVoice.WakeupIntelligentVoiceEngineCallbackInfo) => { 2627 let callbackInfo: intelligentVoice.WakeupIntelligentVoiceEngineCallbackInfo = info; 2628 console.info(`wakeup intelligentvoice event, info:${callbackInfo}`); 2629 }); 2630} 2631``` 2632 2633### off 2634 2635off(type: 'wakeupIntelligentVoiceEvent', callback?: Callback\<WakeupIntelligentVoiceEngineCallbackInfo\>): void; 2636 2637Unsubscribes from wakeup events. 2638 2639**Required permissions**: ohos.permission.MANAGE_INTELLIGENT_VOICE 2640 2641**System capability**: SystemCapability.AI.IntelligentVoice.Core 2642 2643**Parameters** 2644 2645| Name | Type | Mandatory| Description | 2646| -------- | -------------------------------- | --- | ------------------------------------------- | 2647| type |string | Yes | Event type. This field has a fixed value of **wakeupIntelligentVoiceEvent**.| 2648| 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. | 2649 2650**Error codes** 2651 2652For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 2653 2654| ID| Error Message| 2655| ------- | --------------------------------------------| 2656| 201 | Permission denied. | 2657| 202 | Not system application. | 2658 2659**Example** 2660 2661```ts 2662if (wakeupIntelligentVoiceEngine != null) { 2663 (wakeupIntelligentVoiceEngine as intelligentVoice.WakeupIntelligentVoiceEngine).off('wakeupIntelligentVoiceEvent'); 2664} 2665``` 2666