1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit BasicServicesKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * @namespace intelligentVoice 25 * @syscap SystemCapability.AI.IntelligentVoice.Core 26 * @systemapi 27 * @since 10 28 */ 29declare namespace intelligentVoice { 30 /** 31 * Obtains an {@link IntelligentVoiceManager} instance. 32 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 33 * @returns { IntelligentVoiceManager } this {@link IntelligentVoiceManager} object. 34 * @throws { BusinessError } 201 - Permission denied. 35 * @throws { BusinessError } 22700101 - No memory. 36 * @syscap SystemCapability.AI.IntelligentVoice.Core 37 * @systemapi 38 * @since 10 39 */ 40 function getIntelligentVoiceManager(): IntelligentVoiceManager; 41 42 /** 43 * Implements intelligent voice management. 44 * @typedef IntelligentVoiceManager 45 * @syscap SystemCapability.AI.IntelligentVoice.Core 46 * @systemapi 47 * @since 10 48 */ 49 interface IntelligentVoiceManager { 50 /** 51 * Obtains capability information. 52 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 53 * @returns { Array<IntelligentVoiceEngineType> } array of supported IntelligentVoiceEngineType. 54 * @throws { BusinessError } 201 - Permission denied. 55 * @syscap SystemCapability.AI.IntelligentVoice.Core 56 * @systemapi 57 * @since 10 58 */ 59 getCapabilityInfo(): Array<IntelligentVoiceEngineType>; 60 /** 61 * Subscribes service change events. When the state of intelligent voice service changes, 62 * the callback is invoked. 63 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 64 * @param { 'serviceChange' } type - Type of the event to listen for. Only the serviceChange event is supported. 65 * @param { Callback<ServiceChangeType> } callback - Callback is invoked when the event is triggered. 66 * @throws { BusinessError } 201 - Permission denied. 67 * @syscap SystemCapability.AI.IntelligentVoice.Core 68 * @systemapi 69 * @since 10 70 */ 71 on(type: 'serviceChange', callback: Callback<ServiceChangeType>): void; 72 /** 73 * Unsubscribes service change events. 74 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 75 * @param { 'serviceChange' } type - Type of the event to listen for. Only the serviceChange event is supported. 76 * @param { Callback<ServiceChangeType> } [callback] - Callback is invoked when the event is triggered. 77 * @throws { BusinessError } 201 - Permission denied. 78 * @syscap SystemCapability.AI.IntelligentVoice.Core 79 * @systemapi 80 * @since 10 81 */ 82 off(type: 'serviceChange', callback?: Callback<ServiceChangeType>): void; 83 } 84 85 /** 86 * Implements wakeup management. 87 * @typedef WakeupManager 88 * @syscap SystemCapability.AI.IntelligentVoice.Core 89 * @systemapi 90 * @since 12 91 */ 92 interface WakeupManager { 93 /** 94 * Sets an intelligent voice parameter. This method uses a promise to return the result. 95 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 96 * @param { string } key - the key of the intelligent voice parameter to set. 97 * @param { string } value - the value of the intelligent voice parameter to set. 98 * @returns { Promise<void> } the promise used to return the result. 99 * @throws { BusinessError } 201 - Permission denied. 100 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 101 * @throws { BusinessError } 22700102 - Invalid parameter. 102 * @throws { BusinessError } 22700107 - System error. 103 * @syscap SystemCapability.AI.IntelligentVoice.Core 104 * @systemapi 105 * @since 12 106 */ 107 setParameter(key: string, value: string): Promise<void>; 108 /** 109 * Obtains the value of an intelligent voice parameter. This method uses a promise to return the query result. 110 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 111 * @param { string } key - the key of the intelligent voice parameter whose value is to be obtained. 112 * @returns { Promise<string> } the promise used to return the value of the intelligent voice parameter. 113 * @throws { BusinessError } 201 - Permission denied. 114 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 115 * @throws { BusinessError } 22700102 - Invalid parameter. 116 * @throws { BusinessError } 22700107 - System error. 117 * @syscap SystemCapability.AI.IntelligentVoice.Core 118 * @systemapi 119 * @since 12 120 */ 121 getParameter(key: string): Promise<string>; 122 /** 123 * Obtains files needed to upload. This method uses a promise to return the files needed to upload. 124 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 125 * @param { number } maxCount - the maximum count of upload files. The maxCount should be greater than 0 and smaller than 101 126 * @returns { Promise<Array<UploadFile>> } the promise used to return the upload files. 127 * @throws { BusinessError } 201 - Permission denied. 128 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed. 129 * @throws { BusinessError } 22700101 - No memory. 130 * @throws { BusinessError } 22700102 - Invalid parameter. 131 * @throws { BusinessError } 22700107 - System error. 132 * @syscap SystemCapability.AI.IntelligentVoice.Core 133 * @systemapi 134 * @since 12 135 */ 136 getUploadFiles (maxCount: number): Promise<Array<UploadFile>>; 137 /** 138 * Obtains wakeup source files. This method uses a promise to return the wakeup source files. 139 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 140 * @returns { Promise<Array<WakeupSourceFile>> } the promise used to return the wakeup source files. 141 * @throws { BusinessError } 201 - Permission denied. 142 * @throws { BusinessError } 22700101 - No memory. 143 * @throws { BusinessError } 22700107 - System error. 144 * @syscap SystemCapability.AI.IntelligentVoice.Core 145 * @systemapi 146 * @since 12 147 */ 148 getWakeupSourceFiles(): Promise<Array<WakeupSourceFile>>; 149 /** 150 * Enrolls with wakeup files for result. This method uses a promise to return the enroll result. 151 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 152 * @param { Array<WakeupSourceFile> } wakeupFiles - the wakeup source files needed. 153 * @param { string } wakeupInfo - wakeup information. 154 * @returns { Promise<EnrollResult> } the promise used to return the enroll result. 155 * @throws { BusinessError } 201 - Permission denied. 156 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 157 * @throws { BusinessError } 22700101 - No memory. 158 * @throws { BusinessError } 22700102 - Invalid parameter. 159 * @throws { BusinessError } 22700107 - System error. 160 * @syscap SystemCapability.AI.IntelligentVoice.Core 161 * @systemapi 162 * @since 12 163 */ 164 enrollWithWakeupFilesForResult(wakeupFiles: Array<WakeupSourceFile>, wakeupInfo: string): Promise<EnrollResult>; 165 /** 166 * Clears user data. 167 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 168 * @returns { Promise<void> } the promise used to return the result. 169 * @throws { BusinessError } 201 - Permission denied. 170 * @throws { BusinessError } 22700107 - System error. 171 * @syscap SystemCapability.AI.IntelligentVoice.Core 172 * @systemapi 173 * @since 12 174 */ 175 clearUserData(): Promise<void>; 176 } 177 178 /** 179 * Enumerates upload file type. 180 * @enum {number} 181 * @syscap SystemCapability.AI.IntelligentVoice.Core 182 * @systemapi 183 * @since 12 184 */ 185 enum UploadFileType { 186 /** 187 * Enroll file. 188 * @syscap SystemCapability.AI.IntelligentVoice.Core 189 * @systemapi 190 * @since 12 191 */ 192 ENROLL_FILE = 0, 193 /** 194 * Wakeup file. 195 * @syscap SystemCapability.AI.IntelligentVoice.Core 196 * @systemapi 197 * @since 12 198 */ 199 WAKEUP_FILE = 1, 200 } 201 202 /** 203 * Describes upload file information. 204 * @typedef UploadFile 205 * @syscap SystemCapability.AI.IntelligentVoice.Core 206 * @systemapi 207 * @since 12 208 */ 209 interface UploadFile { 210 /** 211 * Report file type. 212 * @type { UploadFileType } 213 * @syscap SystemCapability.AI.IntelligentVoice.Core 214 * @systemapi 215 * @since 12 216 */ 217 type: UploadFileType; 218 /** 219 * Files description. 220 * @type { string } 221 * @syscap SystemCapability.AI.IntelligentVoice.Core 222 * @systemapi 223 * @since 12 224 */ 225 filesDescription: string; 226 /** 227 * Files content. 228 * @type { Array<ArrayBuffer> } 229 * @syscap SystemCapability.AI.IntelligentVoice.Core 230 * @systemapi 231 * @since 12 232 */ 233 filesContent: Array<ArrayBuffer>; 234 } 235 236 /** 237 * Describes wakeup source file information. 238 * @typedef WakeupSourceFile 239 * @syscap SystemCapability.AI.IntelligentVoice.Core 240 * @systemapi 241 * @since 12 242 */ 243 interface WakeupSourceFile { 244 /** 245 * File path. 246 * @type { string } 247 * @syscap SystemCapability.AI.IntelligentVoice.Core 248 * @systemapi 249 * @since 12 250 */ 251 filePath: string; 252 /** 253 * File content. 254 * @type { ArrayBuffer } 255 * @syscap SystemCapability.AI.IntelligentVoice.Core 256 * @systemapi 257 * @since 12 258 */ 259 fileContent: ArrayBuffer; 260 } 261 262 /** 263 * Enumerates service change type. 264 * @enum {number} 265 * @syscap SystemCapability.AI.IntelligentVoice.Core 266 * @systemapi 267 * @since 10 268 */ 269 enum ServiceChangeType { 270 /** 271 * Service unavailable. 272 * @syscap SystemCapability.AI.IntelligentVoice.Core 273 * @systemapi 274 * @since 10 275 */ 276 SERVICE_UNAVAILABLE = 0, 277 } 278 279 /** 280 * Enumerates intelligent voice engine type. 281 * @enum {number} 282 * @syscap SystemCapability.AI.IntelligentVoice.Core 283 * @systemapi 284 * @since 10 285 */ 286 enum IntelligentVoiceEngineType { 287 /** 288 * Enroll engine. 289 * @syscap SystemCapability.AI.IntelligentVoice.Core 290 * @systemapi 291 * @since 10 292 */ 293 ENROLL_ENGINE_TYPE = 0, 294 /** 295 * Wakeup engine. 296 * @syscap SystemCapability.AI.IntelligentVoice.Core 297 * @systemapi 298 * @since 10 299 */ 300 WAKEUP_ENGINE_TYPE = 1, 301 /** 302 * Update engine. 303 * @syscap SystemCapability.AI.IntelligentVoice.Core 304 * @systemapi 305 * @since 10 306 */ 307 UPDATE_ENGINE_TYPE = 2, 308 } 309 310 /** 311 * Describes enroll intelligent voice engine. 312 * @typedef EnrollIntelligentVoiceEngineDescriptor 313 * @syscap SystemCapability.AI.IntelligentVoice.Core 314 * @systemapi 315 * @since 10 316 */ 317 interface EnrollIntelligentVoiceEngineDescriptor { 318 /** 319 * Wakeup phrase. 320 * @type { string } 321 * @syscap SystemCapability.AI.IntelligentVoice.Core 322 * @systemapi 323 * @since 10 324 */ 325 wakeupPhrase: string; 326 } 327 328 /** 329 * Describes wakeup intelligent voice engine. 330 * @typedef WakeupIntelligentVoiceEngineDescriptor 331 * @syscap SystemCapability.AI.IntelligentVoice.Core 332 * @systemapi 333 * @since 10 334 */ 335 interface WakeupIntelligentVoiceEngineDescriptor { 336 /** 337 * Need reconfirm. 338 * @type { boolean } 339 * @syscap SystemCapability.AI.IntelligentVoice.Core 340 * @systemapi 341 * @since 10 342 */ 343 needReconfirm: boolean; 344 /** 345 * Wakeup phrase. 346 * @type { string } 347 * @syscap SystemCapability.AI.IntelligentVoice.Core 348 * @systemapi 349 * @since 10 350 */ 351 wakeupPhrase: string; 352 } 353 354 /** 355 * Enumerates evaluation result code. 356 * @enum {number} 357 * @syscap SystemCapability.AI.IntelligentVoice.Core 358 * @systemapi 359 * @since 12 360 */ 361 enum EvaluationResultCode { 362 /** 363 * Unknown. 364 * @syscap SystemCapability.AI.IntelligentVoice.Core 365 * @systemapi 366 * @since 12 367 */ 368 UNKNOWN = 0, 369 /** 370 * Pass. 371 * @syscap SystemCapability.AI.IntelligentVoice.Core 372 * @systemapi 373 * @since 12 374 */ 375 PASS = 1, 376 /** 377 * Word is empty. 378 * @syscap SystemCapability.AI.IntelligentVoice.Core 379 * @systemapi 380 * @since 12 381 */ 382 WORD_EMPTY = 2, 383 /** 384 * Only chinese is supported. 385 * @syscap SystemCapability.AI.IntelligentVoice.Core 386 * @systemapi 387 * @since 12 388 */ 389 CHINESE_ONLY = 3, 390 /** 391 * Invalid length. 392 * @syscap SystemCapability.AI.IntelligentVoice.Core 393 * @systemapi 394 * @since 12 395 */ 396 INVALID_LENGTH = 4, 397 /** 398 * Unusual word. 399 * @syscap SystemCapability.AI.IntelligentVoice.Core 400 * @systemapi 401 * @since 12 402 */ 403 UNUSUAL_WORD = 5, 404 /** 405 * Consecutive same word. 406 * @syscap SystemCapability.AI.IntelligentVoice.Core 407 * @systemapi 408 * @since 12 409 */ 410 CONSECUTIVE_SAME_WORD = 6, 411 /** 412 * Too few phonemes. 413 * @syscap SystemCapability.AI.IntelligentVoice.Core 414 * @systemapi 415 * @since 12 416 */ 417 TOO_FEW_PHONEMES = 7, 418 /** 419 * Too many phonemes. 420 * @syscap SystemCapability.AI.IntelligentVoice.Core 421 * @systemapi 422 * @since 12 423 */ 424 TOO_MANY_PHONEMES = 8, 425 /** 426 * Contain common instruction. 427 * @syscap SystemCapability.AI.IntelligentVoice.Core 428 * @systemapi 429 * @since 12 430 */ 431 COMMON_INSTRUCTION = 9, 432 /** 433 * Contain common spoken language. 434 * @syscap SystemCapability.AI.IntelligentVoice.Core 435 * @systemapi 436 * @since 12 437 */ 438 COMMON_SPOKEN_LANGUAGE = 10, 439 /** 440 * Contain sensitive word. 441 * @syscap SystemCapability.AI.IntelligentVoice.Core 442 * @systemapi 443 * @since 12 444 */ 445 SENSITIVE_WORD = 11, 446 /** 447 * Two consecutive words without initial consonant. 448 * @syscap SystemCapability.AI.IntelligentVoice.Core 449 * @systemapi 450 * @since 12 451 */ 452 NO_INITIAL_CONSONANT = 12, 453 /** 454 * Contain repeated phoneme. 455 * @syscap SystemCapability.AI.IntelligentVoice.Core 456 * @systemapi 457 * @since 12 458 */ 459 REPEATED_PHONEME = 13, 460 } 461 462 /** 463 * Describes evaluation result. 464 * @typedef EvaluationResult 465 * @syscap SystemCapability.AI.IntelligentVoice.Core 466 * @systemapi 467 * @since 12 468 */ 469 interface EvaluationResult { 470 /** 471 * Evaluation score. 472 * @type { number } 473 * @syscap SystemCapability.AI.IntelligentVoice.Core 474 * @systemapi 475 * @since 12 476 */ 477 score: number; 478 /** 479 * Describes evaluation result code. 480 * @type { EvaluationResultCode } 481 * @syscap SystemCapability.AI.IntelligentVoice.Core 482 * @systemapi 483 * @since 12 484 */ 485 resultCode: EvaluationResultCode; 486 } 487 488 /** 489 * Obtains an {@link WakeupManager} instance. 490 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 491 * @returns { WakeupManager } this {@link WakeupManager} object. 492 * @throws { BusinessError } 201 - Permission denied. 493 * @throws { BusinessError } 22700101 - No memory. 494 * @throws { BusinessError } 22700107 - System error. 495 * @syscap SystemCapability.AI.IntelligentVoice.Core 496 * @systemapi 497 * @since 12 498 */ 499 function getWakeupManager(): WakeupManager; 500 501 /** 502 * Obtains an {@link EnrollIntelligentVoiceEngine} instance. This method uses an asynchronous callback to return the EnrollIntelligentVoiceEngine instance. 503 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 504 * @param { EnrollIntelligentVoiceEngineDescriptor } descriptor - descriptor indicates enroll intelligent voice engine descriptor. 505 * @param { AsyncCallback<EnrollIntelligentVoiceEngine> } callback - the callback used to return the EnrollIntelligentVoiceEngine instance. 506 * @throws { BusinessError } 201 - Permission denied. 507 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 508 * @throws { BusinessError } 22700101 - No memory. 509 * @throws { BusinessError } 22700102 - Invalid parameter. 510 * @syscap SystemCapability.AI.IntelligentVoice.Core 511 * @systemapi 512 * @since 10 513 */ 514 function createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor, callback: AsyncCallback<EnrollIntelligentVoiceEngine>): void; 515 516 /** 517 * Obtains an {@link EnrollIntelligentVoiceEngine} instance. This method uses a promise to return the EnrollIntelligentVoiceEngine instance. 518 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 519 * @param { EnrollIntelligentVoiceEngineDescriptor } descriptor - descriptor indicates enroll intelligent voice engine descriptor. 520 * @returns { Promise<EnrollIntelligentVoiceEngine> } the promise used to return the EnrollIntelligentVoiceEngine instance. 521 * @throws { BusinessError } 201 - Permission denied. 522 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 523 * @throws { BusinessError } 22700101 - No memory. 524 * @throws { BusinessError } 22700102 - Invalid parameter. 525 * @syscap SystemCapability.AI.IntelligentVoice.Core 526 * @systemapi 527 * @since 10 528 */ 529 function createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor): Promise<EnrollIntelligentVoiceEngine>; 530 531 /** 532 * Obtains an {@link WakeupIntelligentVoiceEngine} instance. This method uses an asynchronous callback to return the WakeupIntelligentVoiceEngine instance. 533 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 534 * @param { WakeupIntelligentVoiceEngineDescriptor } descriptor - descriptor indicates wakeup intelligent voice engine descriptor. 535 * @param { AsyncCallback<WakeupIntelligentVoiceEngine> } callback - the callback used to return the WakeupIntelligentVoiceEngine instance. 536 * @throws { BusinessError } 201 - Permission denied. 537 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 538 * @throws { BusinessError } 22700101 - No memory. 539 * @throws { BusinessError } 22700102 - Invalid parameter. 540 * @syscap SystemCapability.AI.IntelligentVoice.Core 541 * @systemapi 542 * @since 10 543 */ 544 function createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor, callback: AsyncCallback<WakeupIntelligentVoiceEngine>): void; 545 546 /** 547 * Obtains an {@link WakeupIntelligentVoiceEngine} instance. This method uses a promise to return the WakeupIntelligentVoiceEngine instance. 548 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 549 * @param { WakeupIntelligentVoiceEngineDescriptor } descriptor - descriptor indicates wakeup intelligent voice engine descriptor. 550 * @returns { Promise<WakeupIntelligentVoiceEngine> } the promise used to return the WakeupIntelligentVoiceEngine instance. 551 * @throws { BusinessError } 201 - Permission denied. 552 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 553 * @throws { BusinessError } 22700101 - No memory. 554 * @throws { BusinessError } 22700102 - Invalid parameter. 555 * @syscap SystemCapability.AI.IntelligentVoice.Core 556 * @systemapi 557 * @since 10 558 */ 559 function createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor): Promise<WakeupIntelligentVoiceEngine>; 560 561 /** 562 * Describes enroll engine config. 563 * @typedef EnrollEngineConfig 564 * @syscap SystemCapability.AI.IntelligentVoice.Core 565 * @systemapi 566 * @since 10 567 */ 568 interface EnrollEngineConfig { 569 /** 570 * Language that enroll engine supports. 571 * @type { string } 572 * @syscap SystemCapability.AI.IntelligentVoice.Core 573 * @systemapi 574 * @since 10 575 */ 576 language: string; 577 /** 578 * Region that enroll engine supports. 579 * @type { string } 580 * @syscap SystemCapability.AI.IntelligentVoice.Core 581 * @systemapi 582 * @since 10 583 */ 584 region: string; 585 } 586 587 /** 588 * Enumerates sensibility type. 589 * @enum {number} 590 * @syscap SystemCapability.AI.IntelligentVoice.Core 591 * @systemapi 592 * @since 10 593 */ 594 enum SensibilityType { 595 /** 596 * Low sensibility. 597 * @syscap SystemCapability.AI.IntelligentVoice.Core 598 * @systemapi 599 * @since 10 600 */ 601 LOW_SENSIBILITY = 1, 602 /** 603 * Middle sensibility. 604 * @syscap SystemCapability.AI.IntelligentVoice.Core 605 * @systemapi 606 * @since 10 607 */ 608 MIDDLE_SENSIBILITY = 2, 609 /** 610 * High sensibility. 611 * @syscap SystemCapability.AI.IntelligentVoice.Core 612 * @systemapi 613 * @since 10 614 */ 615 HIGH_SENSIBILITY = 3, 616 } 617 618 /** 619 * Describes wakeup hap information. 620 * @typedef WakeupHapInfo 621 * @syscap SystemCapability.AI.IntelligentVoice.Core 622 * @systemapi 623 * @since 10 624 */ 625 interface WakeupHapInfo { 626 /** 627 * Bundle name. 628 * @type { string } 629 * @syscap SystemCapability.AI.IntelligentVoice.Core 630 * @systemapi 631 * @since 10 632 */ 633 bundleName: string; 634 /** 635 * Ability name. 636 * @type { string } 637 * @syscap SystemCapability.AI.IntelligentVoice.Core 638 * @systemapi 639 * @since 10 640 */ 641 abilityName: string; 642 } 643 644 /** 645 * Enumerates wakeup intelligent voice event type. 646 * @enum {number} 647 * @syscap SystemCapability.AI.IntelligentVoice.Core 648 * @systemapi 649 * @since 10 650 */ 651 enum WakeupIntelligentVoiceEventType { 652 /** 653 * Wakeup None. 654 * @syscap SystemCapability.AI.IntelligentVoice.Core 655 * @systemapi 656 * @since 10 657 */ 658 INTELLIGENT_VOICE_EVENT_WAKEUP_NONE = 0, 659 /** 660 * Recognize complete. 661 * @syscap SystemCapability.AI.IntelligentVoice.Core 662 * @systemapi 663 * @since 10 664 */ 665 INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE = 1, 666 /** 667 * Headset Recognize complete. 668 * @syscap SystemCapability.AI.IntelligentVoice.Core 669 * @systemapi 670 * @since 12 671 */ 672 INTELLIGENT_VOICE_EVENT_HEADSET_RECOGNIZE_COMPLETE = 2, 673 } 674 675 /** 676 * Enumerates intelligent voice error code. 677 * @enum {number} 678 * @syscap SystemCapability.AI.IntelligentVoice.Core 679 * @systemapi 680 * @since 10 681 */ 682 enum IntelligentVoiceErrorCode { 683 /** 684 * No memory. 685 * @syscap SystemCapability.AI.IntelligentVoice.Core 686 * @systemapi 687 * @since 10 688 */ 689 INTELLIGENT_VOICE_NO_MEMORY = 22700101, 690 /** 691 * Invalid parameter. 692 * @syscap SystemCapability.AI.IntelligentVoice.Core 693 * @systemapi 694 * @since 10 695 */ 696 INTELLIGENT_VOICE_INVALID_PARAM = 22700102, 697 /** 698 * Init failed. 699 * @syscap SystemCapability.AI.IntelligentVoice.Core 700 * @systemapi 701 * @since 10 702 */ 703 INTELLIGENT_VOICE_INIT_FAILED = 22700103, 704 /** 705 * Failed to commit the enrollment. 706 * @syscap SystemCapability.AI.IntelligentVoice.Core 707 * @systemapi 708 * @since 10 709 */ 710 INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED = 22700104, 711 /** 712 * Start capturer failed. 713 * @syscap SystemCapability.AI.IntelligentVoice.Core 714 * @systemapi 715 * @since 12 716 */ 717 INTELLIGENT_VOICE_START_CAPTURER_FAILED = 22700105, 718 /** 719 * Read failed. 720 * @syscap SystemCapability.AI.IntelligentVoice.Core 721 * @systemapi 722 * @since 12 723 */ 724 INTELLIGENT_VOICE_READ_FAILED = 22700106, 725 /** 726 * System error. 727 * @syscap SystemCapability.AI.IntelligentVoice.Core 728 * @systemapi 729 * @since 12 730 */ 731 INTELLIGENT_VOICE_SYSTEM_ERROR = 22700107, 732 } 733 734 /** 735 * Enumerates enroll result. 736 * @enum {number} 737 * @syscap SystemCapability.AI.IntelligentVoice.Core 738 * @systemapi 739 * @since 10 740 */ 741 enum EnrollResult { 742 /** 743 * Success. 744 * @syscap SystemCapability.AI.IntelligentVoice.Core 745 * @systemapi 746 * @since 10 747 */ 748 SUCCESS = 0, 749 /** 750 * Vpr train failed. 751 * @syscap SystemCapability.AI.IntelligentVoice.Core 752 * @systemapi 753 * @since 10 754 */ 755 VPR_TRAIN_FAILED = -1, 756 /** 757 * Wakeup phrase not match. 758 * @syscap SystemCapability.AI.IntelligentVoice.Core 759 * @systemapi 760 * @since 10 761 */ 762 WAKEUP_PHRASE_NOT_MATCH = -2, 763 /** 764 * Too noisy. 765 * @syscap SystemCapability.AI.IntelligentVoice.Core 766 * @systemapi 767 * @since 10 768 */ 769 TOO_NOISY = -3, 770 /** 771 * Too loud. 772 * @syscap SystemCapability.AI.IntelligentVoice.Core 773 * @systemapi 774 * @since 10 775 */ 776 TOO_LOUD = -4, 777 /** 778 * Interval large. 779 * @syscap SystemCapability.AI.IntelligentVoice.Core 780 * @systemapi 781 * @since 10 782 */ 783 INTERVAL_LARGE = -5, 784 /** 785 * Different person. 786 * @syscap SystemCapability.AI.IntelligentVoice.Core 787 * @systemapi 788 * @since 10 789 */ 790 DIFFERENT_PERSON = -6, 791 /** 792 * Unknown error. 793 * @syscap SystemCapability.AI.IntelligentVoice.Core 794 * @systemapi 795 * @since 10 796 */ 797 UNKNOWN_ERROR = -100, 798 } 799 800 /** 801 * Enumerates capturer channel. 802 * @enum {number} 803 * @syscap SystemCapability.AI.IntelligentVoice.Core 804 * @systemapi 805 * @since 12 806 */ 807 enum CapturerChannel { 808 /** 809 * Capturer channel 1. 810 * @syscap SystemCapability.AI.IntelligentVoice.Core 811 * @systemapi 812 * @since 12 813 */ 814 CAPTURER_CHANNEL_1 = 0x1 << 0, 815 /** 816 * Capturer channel 2. 817 * @syscap SystemCapability.AI.IntelligentVoice.Core 818 * @systemapi 819 * @since 12 820 */ 821 CAPTURER_CHANNEL_2 = 0x1 << 1, 822 /** 823 * Capturer channel 3. 824 * @syscap SystemCapability.AI.IntelligentVoice.Core 825 * @systemapi 826 * @since 12 827 */ 828 CAPTURER_CHANNEL_3 = 0x1 << 2, 829 /** 830 * Capturer channel 4. 831 * @syscap SystemCapability.AI.IntelligentVoice.Core 832 * @systemapi 833 * @since 12 834 */ 835 CAPTURER_CHANNEL_4 = 0x1 << 3, 836 } 837 838 /** 839 * Describes enroll callback information. 840 * @typedef EnrollCallbackInfo 841 * @syscap SystemCapability.AI.IntelligentVoice.Core 842 * @systemapi 843 * @since 10 844 */ 845 interface EnrollCallbackInfo { 846 /** 847 * Result. 848 * @type { EnrollResult } 849 * @syscap SystemCapability.AI.IntelligentVoice.Core 850 * @systemapi 851 * @since 10 852 */ 853 result: EnrollResult; 854 /** 855 * Describes enroll event context. 856 * @type { string } 857 * @syscap SystemCapability.AI.IntelligentVoice.Core 858 * @systemapi 859 * @since 10 860 */ 861 context: string; 862 } 863 864 /** 865 * Describes wakeup intelligent voice engine callback information. 866 * @typedef WakeupIntelligentVoiceEngineCallbackInfo 867 * @syscap SystemCapability.AI.IntelligentVoice.Core 868 * @systemapi 869 * @since 10 870 */ 871 interface WakeupIntelligentVoiceEngineCallbackInfo { 872 /** 873 * Wakeup event id. 874 * @type { WakeupIntelligentVoiceEventType } 875 * @syscap SystemCapability.AI.IntelligentVoice.Core 876 * @systemapi 877 * @since 10 878 */ 879 eventId: WakeupIntelligentVoiceEventType; 880 /** 881 * Is success. 882 * @type { boolean } 883 * @syscap SystemCapability.AI.IntelligentVoice.Core 884 * @systemapi 885 * @since 10 886 */ 887 isSuccess: boolean; 888 /** 889 * Describes wakeup event context. 890 * @type { string } 891 * @syscap SystemCapability.AI.IntelligentVoice.Core 892 * @systemapi 893 * @since 10 894 */ 895 context: string; 896 } 897 898 /** 899 * Implements enroll intelligent voice engine. 900 * @typedef EnrollIntelligentVoiceEngine 901 * @syscap SystemCapability.AI.IntelligentVoice.Core 902 * @systemapi 903 * @since 10 904 */ 905 interface EnrollIntelligentVoiceEngine { 906 /** 907 * Obtains the supported regions, This method uses an asynchronous callback to return the query result. 908 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 909 * @param { AsyncCallback<Array<string>> } callback - the callback used to return the supported regions. 910 * @throws { BusinessError } 201 - Permission denied. 911 * @syscap SystemCapability.AI.IntelligentVoice.Core 912 * @systemapi 913 * @since 10 914 */ 915 getSupportedRegions(callback: AsyncCallback<Array<string>>): void; 916 /** 917 * Obtains the supported regions, This method uses a promise to return the query result. 918 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 919 * @returns { Promise<Array<string>> } the promise used to return the supported regions. 920 * @throws { BusinessError } 201 - Permission denied. 921 * @syscap SystemCapability.AI.IntelligentVoice.Core 922 * @systemapi 923 * @since 10 924 */ 925 getSupportedRegions(): Promise<Array<string>>; 926 /** 927 * Initials the engine, This method uses an asynchronous callback to return the result. 928 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 929 * @param { EnrollEngineConfig } config - config indicates enroll engine configuration. 930 * @param { AsyncCallback<void> } callback - the callback used to return the result. 931 * @throws { BusinessError } 201 - Permission denied. 932 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 933 * @throws { BusinessError } 22700102 - Invalid parameter. 934 * @throws { BusinessError } 22700103 - Init failed. 935 * @syscap SystemCapability.AI.IntelligentVoice.Core 936 * @systemapi 937 * @since 10 938 */ 939 init(config: EnrollEngineConfig, callback: AsyncCallback<void>): void; 940 /** 941 * Initials the engine, This method uses a promise to return the result. 942 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 943 * @param { EnrollEngineConfig } config - config indicates enroll engine configuration. 944 * @returns { Promise<void> } the promise used to return the result. 945 * @throws { BusinessError } 201 - Permission denied. 946 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 947 * @throws { BusinessError } 22700102 - Invalid parameter. 948 * @throws { BusinessError } 22700103 - Init failed. 949 * @syscap SystemCapability.AI.IntelligentVoice.Core 950 * @systemapi 951 * @since 10 952 */ 953 init(config: EnrollEngineConfig): Promise<void>; 954 /** 955 * Enrolls for result, This method uses an asynchronous callback to return the result. 956 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 957 * @param { boolean } isLast - isLast indicates if it is the last time to enroll. 958 * @param { AsyncCallback<EnrollCallbackInfo> } callback - the callback used to return the result. 959 * @throws { BusinessError } 201 - Permission denied. 960 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 961 * @syscap SystemCapability.AI.IntelligentVoice.Core 962 * @systemapi 963 * @since 10 964 */ 965 enrollForResult(isLast: boolean, callback: AsyncCallback<EnrollCallbackInfo>): void; 966 /** 967 * Enrolls for result, This method uses a promise to return the result. 968 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 969 * @param { boolean } isLast - isLast indicates if it is the last time to enroll. 970 * @returns { Promise<EnrollCallbackInfo> } the promise used to return the result. 971 * @throws { BusinessError } 201 - Permission denied. 972 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 973 * @syscap SystemCapability.AI.IntelligentVoice.Core 974 * @systemapi 975 * @since 10 976 */ 977 enrollForResult(isLast: boolean): Promise<EnrollCallbackInfo>; 978 /** 979 * Stops the engine, This method uses an asynchronous callback to return the result. 980 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 981 * @param { AsyncCallback<void> } callback - the callback used to return the result. 982 * @throws { BusinessError } 201 - Permission denied. 983 * @syscap SystemCapability.AI.IntelligentVoice.Core 984 * @systemapi 985 * @since 10 986 */ 987 stop(callback: AsyncCallback<void>): void; 988 /** 989 * Stops the engine, This method uses a promise to return the result. 990 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 991 * @returns { Promise<void> } the promise used to return the result. 992 * @throws { BusinessError } 201 - Permission denied. 993 * @syscap SystemCapability.AI.IntelligentVoice.Core 994 * @systemapi 995 * @since 10 996 */ 997 stop(): Promise<void>; 998 /** 999 * Commit enroll, This method uses an asynchronous callback to return the result. 1000 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1001 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1002 * @throws { BusinessError } 201 - Permission denied. 1003 * @throws { BusinessError } 22700104 - Failed to commit the enrollment. 1004 * @syscap SystemCapability.AI.IntelligentVoice.Core 1005 * @systemapi 1006 * @since 10 1007 */ 1008 commit(callback: AsyncCallback<void>): void; 1009 /** 1010 * Commit enroll, This method uses a promise to return the result. 1011 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1012 * @returns { Promise<void> } the promise used to return the result. 1013 * @throws { BusinessError } 201 - Permission denied. 1014 * @throws { BusinessError } 22700104 - Failed to commit the enrollment. 1015 * @syscap SystemCapability.AI.IntelligentVoice.Core 1016 * @systemapi 1017 * @since 10 1018 */ 1019 commit(): Promise<void>; 1020 /** 1021 * Sets wakeup hap information, This method uses an asynchronous callback to return the result. 1022 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1023 * @param { WakeupHapInfo } info - info indicates wakeup hap information. 1024 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1025 * @throws { BusinessError } 201 - Permission denied. 1026 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1027 * @throws { BusinessError } 22700102 - Invalid parameter. 1028 * @syscap SystemCapability.AI.IntelligentVoice.Core 1029 * @systemapi 1030 * @since 10 1031 */ 1032 setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback<void>): void; 1033 /** 1034 * Sets wakeup hap information, This method uses a promise to return the result. 1035 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1036 * @param { WakeupHapInfo } info - info indicates wakeup hap information. 1037 * @returns { Promise<void> } the promise used to return the result. 1038 * @throws { BusinessError } 201 - Permission denied. 1039 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1040 * @throws { BusinessError } 22700102 - Invalid parameter. 1041 * @syscap SystemCapability.AI.IntelligentVoice.Core 1042 * @systemapi 1043 * @since 10 1044 */ 1045 setWakeupHapInfo(info: WakeupHapInfo): Promise<void>; 1046 /** 1047 * Sets sensibility, This method uses an asynchronous callback to return the result. 1048 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1049 * @param { SensibilityType } sensibility - sensibility to set. 1050 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1051 * @throws { BusinessError } 201 - Permission denied. 1052 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1053 * @throws { BusinessError } 22700102 - Invalid parameter. 1054 * @syscap SystemCapability.AI.IntelligentVoice.Core 1055 * @systemapi 1056 * @since 10 1057 */ 1058 setSensibility(sensibility: SensibilityType, callback: AsyncCallback<void>): void; 1059 /** 1060 * Sets sensibility, This method uses a promise to return the result. 1061 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1062 * @param { SensibilityType } sensibility - sensibility to set. 1063 * @returns { Promise<void> } the promise used to return the result. 1064 * @throws { BusinessError } 201 - Permission denied. 1065 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1066 * @throws { BusinessError } 22700102 - Invalid parameter. 1067 * @syscap SystemCapability.AI.IntelligentVoice.Core 1068 * @systemapi 1069 * @since 10 1070 */ 1071 setSensibility(sensibility: SensibilityType): Promise<void>; 1072 /** 1073 * Sets an intelligent voice parameter. This method uses an asynchronous callback to return the result. 1074 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1075 * @param { string } key - the key of the intelligent voice parameter to set. 1076 * @param { string } value - the value of the intelligent voice parameter to set. 1077 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1078 * @throws { BusinessError } 201 - Permission denied. 1079 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1080 * @throws { BusinessError } 22700102 - Invalid parameter. 1081 * @syscap SystemCapability.AI.IntelligentVoice.Core 1082 * @systemapi 1083 * @since 10 1084 */ 1085 setParameter(key: string, value: string, callback: AsyncCallback<void>): void; 1086 /** 1087 * Sets an intelligent voice parameter. This method uses a promise to return the result. 1088 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1089 * @param { string } key - the key of the intelligent voice parameter to set. 1090 * @param { string } value - the value of the intelligent voice parameter to set. 1091 * @returns { Promise<void> } the promise used to return the result. 1092 * @throws { BusinessError } 201 - Permission denied. 1093 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1094 * @throws { BusinessError } 22700102 - Invalid parameter. 1095 * @syscap SystemCapability.AI.IntelligentVoice.Core 1096 * @systemapi 1097 * @since 10 1098 */ 1099 setParameter(key: string, value: string): Promise<void>; 1100 /** 1101 * Obtains the value of an intelligent voice parameter. This method uses an asynchronous callback to return the query result. 1102 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1103 * @param { string } key - the key of the intelligent voice parameter whose value is to be obtained. 1104 * @param { AsyncCallback<string> } callback - the callback used to return the value of the intelligent voice parameter. 1105 * @throws { BusinessError } 201 - Permission denied. 1106 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1107 * @throws { BusinessError } 22700102 - Invalid parameter. 1108 * @syscap SystemCapability.AI.IntelligentVoice.Core 1109 * @systemapi 1110 * @since 10 1111 */ 1112 getParameter(key: string, callback: AsyncCallback<string>): void; 1113 /** 1114 * Obtains the value of an intelligent voice parameter. This method uses a promise to return the query result. 1115 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1116 * @param { string } key - the key of the intelligent voice parameter whose value is to be obtained. 1117 * @returns { Promise<string> } the promise used to return the value of the intelligent voice parameter. 1118 * @throws { BusinessError } 201 - Permission denied. 1119 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1120 * @throws { BusinessError } 22700102 - Invalid parameter. 1121 * @syscap SystemCapability.AI.IntelligentVoice.Core 1122 * @systemapi 1123 * @since 10 1124 */ 1125 getParameter(key: string): Promise<string>; 1126 /** 1127 * Evaluates for result, This method uses a promise to return the result. 1128 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1129 * @param { string } word - the word to evaluate. 1130 * @returns { Promise<EvaluationResult> } the promise used to return the result. 1131 * @throws { BusinessError } 201 - Permission denied. 1132 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1133 * @throws { BusinessError } 22700107 - System error. 1134 * @syscap SystemCapability.AI.IntelligentVoice.Core 1135 * @systemapi 1136 * @since 12 1137 */ 1138 evaluateForResult(word: string): Promise<EvaluationResult>; 1139 /** 1140 * Releases the engine, This method uses an asynchronous callback to return the result. 1141 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1142 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1143 * @throws { BusinessError } 201 - Permission denied. 1144 * @syscap SystemCapability.AI.IntelligentVoice.Core 1145 * @systemapi 1146 * @since 10 1147 */ 1148 release(callback: AsyncCallback<void>): void; 1149 /** 1150 * Releases the engine, This method uses a promise to return the result. 1151 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1152 * @returns { Promise<void> } the promise used to return the result. 1153 * @throws { BusinessError } 201 - Permission denied. 1154 * @syscap SystemCapability.AI.IntelligentVoice.Core 1155 * @systemapi 1156 * @since 10 1157 */ 1158 release(): Promise<void>; 1159 } 1160 1161 /** 1162 * Implements wakeup intelligent voice engine. 1163 * @typedef WakeupIntelligentVoiceEngine 1164 * @syscap SystemCapability.AI.IntelligentVoice.Core 1165 * @systemapi 1166 * @since 10 1167 */ 1168 interface WakeupIntelligentVoiceEngine { 1169 /** 1170 * Obtains the supported regions, This method uses an asynchronous callback to return the query result. 1171 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1172 * @param { AsyncCallback<Array<string>> } callback - the callback used to return the supported regions. 1173 * @throws { BusinessError } 201 - Permission denied. 1174 * @syscap SystemCapability.AI.IntelligentVoice.Core 1175 * @systemapi 1176 * @since 10 1177 */ 1178 getSupportedRegions(callback: AsyncCallback<Array<string>>): void; 1179 /** 1180 * Obtains the supported regions, This method uses a promise to return the query result. 1181 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1182 * @returns { Promise<Array<string>> } the promise used to return the supported regions. 1183 * @throws { BusinessError } 201 - Permission denied. 1184 * @syscap SystemCapability.AI.IntelligentVoice.Core 1185 * @systemapi 1186 * @since 10 1187 */ 1188 getSupportedRegions(): Promise<Array<string>>; 1189 /** 1190 * Sets wakeup hap information, This method uses an asynchronous callback to return the result. 1191 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1192 * @param { WakeupHapInfo } info - info indicates wakeup hap information. 1193 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1194 * @throws { BusinessError } 201 - Permission denied. 1195 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1196 * @throws { BusinessError } 22700102 - Invalid parameter. 1197 * @syscap SystemCapability.AI.IntelligentVoice.Core 1198 * @systemapi 1199 * @since 10 1200 */ 1201 setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback<void>): void; 1202 /** 1203 * Sets wakeup hap information, This method uses a promise to return the result. 1204 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1205 * @param { WakeupHapInfo } info - info indicates wakeup hap information. 1206 * @returns { Promise<void> } the promise used to return the result. 1207 * @throws { BusinessError } 201 - Permission denied. 1208 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1209 * @throws { BusinessError } 22700102 - Invalid parameter. 1210 * @syscap SystemCapability.AI.IntelligentVoice.Core 1211 * @systemapi 1212 * @since 10 1213 */ 1214 setWakeupHapInfo(info: WakeupHapInfo): Promise<void>; 1215 /** 1216 * Sets sensibility, This method uses an asynchronous callback to return the result. 1217 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1218 * @param { SensibilityType } sensibility - sensibility to set. 1219 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1220 * @throws { BusinessError } 201 - Permission denied. 1221 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1222 * @throws { BusinessError } 22700102 - Invalid parameter. 1223 * @syscap SystemCapability.AI.IntelligentVoice.Core 1224 * @systemapi 1225 * @since 10 1226 */ 1227 setSensibility(sensibility: SensibilityType, callback: AsyncCallback<void>): void; 1228 /** 1229 * Sets sensibility, This method uses a promise to return the result. 1230 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1231 * @param { SensibilityType } sensibility - sensibility to set. 1232 * @returns { Promise<void> } the promise used to return the result. 1233 * @throws { BusinessError } 201 - Permission denied. 1234 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1235 * @throws { BusinessError } 22700102 - Invalid parameter. 1236 * @syscap SystemCapability.AI.IntelligentVoice.Core 1237 * @systemapi 1238 * @since 10 1239 */ 1240 setSensibility(sensibility: SensibilityType): Promise<void>; 1241 /** 1242 * Sets an intelligent voice parameter. This method uses an asynchronous callback to return the result. 1243 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1244 * @param { string } key - the key of the intelligent voice parameter to set. 1245 * @param { string } value - the value of the intelligent voice parameter to set. 1246 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1247 * @throws { BusinessError } 201 - Permission denied. 1248 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1249 * @throws { BusinessError } 22700102 - Invalid parameter. 1250 * @syscap SystemCapability.AI.IntelligentVoice.Core 1251 * @systemapi 1252 * @since 10 1253 */ 1254 setParameter(key: string, value: string, callback: AsyncCallback<void>): void; 1255 /** 1256 * Sets an intelligent voice parameter. This method uses a promise to return the result. 1257 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1258 * @param { string } key - the key of the intelligent voice parameter to set. 1259 * @param { string } value - the value of the intelligent voice parameter to set. 1260 * @returns { Promise<void> } the promise used to return the result. 1261 * @throws { BusinessError } 201 - Permission denied. 1262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1263 * @throws { BusinessError } 22700102 - Invalid parameter. 1264 * @syscap SystemCapability.AI.IntelligentVoice.Core 1265 * @systemapi 1266 * @since 10 1267 */ 1268 setParameter(key: string, value: string): Promise<void>; 1269 /** 1270 * Obtains the value of an intelligent voice parameter. This method uses an asynchronous callback to return the query result. 1271 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1272 * @param { string } key - the key of the intelligent voice parameter whose value is to be obtained. 1273 * @param { AsyncCallback<string> } callback - the callback used to return the value of the intelligent voice parameter. 1274 * @throws { BusinessError } 201 - Permission denied. 1275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1276 * @throws { BusinessError } 22700102 - Invalid parameter. 1277 * @syscap SystemCapability.AI.IntelligentVoice.Core 1278 * @systemapi 1279 * @since 10 1280 */ 1281 getParameter(key: string, callback: AsyncCallback<string>): void; 1282 /** 1283 * Obtains the value of an intelligent voice parameter. This method uses a promise to return the query result. 1284 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1285 * @param { string } key - the key of the intelligent voice parameter whose value is to be obtained. 1286 * @returns { Promise<string> } the promise used to return the value of the intelligent voice parameter. 1287 * @throws { BusinessError } 201 - Permission denied. 1288 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 1289 * @throws { BusinessError } 22700102 - Invalid parameter. 1290 * @syscap SystemCapability.AI.IntelligentVoice.Core 1291 * @systemapi 1292 * @since 10 1293 */ 1294 getParameter(key: string): Promise<string>; 1295 /** 1296 * Gets pulse-code modulation audio. This method uses a promise to return the result. 1297 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1298 * @returns { Promise<ArrayBuffer> } the promise used to return the pulse-code modulation audio. 1299 * @throws { BusinessError } 201 - Permission denied. 1300 * @throws { BusinessError } 22700101 - No memory. 1301 * @throws { BusinessError } 22700107 - System error. 1302 * @syscap SystemCapability.AI.IntelligentVoice.Core 1303 * @systemapi 1304 * @since 12 1305 */ 1306 getPcm(): Promise<ArrayBuffer>; 1307 /** 1308 * Starts the capturer. This method uses a promise to return the result. 1309 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1310 * @param { number } channels - the channels needed in reading. The channels should be greater than 0 and smaller than 16. 1311 * @returns { Promise<void> } the promise used to return the result. 1312 * @throws { BusinessError } 201 - Permission denied. 1313 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed. 1314 * @throws { BusinessError } 22700102 - Invalid parameter. 1315 * @throws { BusinessError } 22700105 - Start capturer failed. 1316 * @throws { BusinessError } 22700107 - System error. 1317 * @syscap SystemCapability.AI.IntelligentVoice.Core 1318 * @systemapi 1319 * @since 12 1320 */ 1321 startCapturer(channels: number): Promise<void>; 1322 /** 1323 * Reads the buffer from wakeup engine. This method uses a promise to return the result. 1324 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1325 * @returns { Promise<ArrayBuffer> } the promise used to return the buffer. 1326 * @throws { BusinessError } 201 - Permission denied. 1327 * @throws { BusinessError } 22700101 - No memory. 1328 * @throws { BusinessError } 22700106 - Read failed. 1329 * @throws { BusinessError } 22700107 - System error. 1330 * @syscap SystemCapability.AI.IntelligentVoice.Core 1331 * @systemapi 1332 * @since 12 1333 */ 1334 read(): Promise<ArrayBuffer>; 1335 /** 1336 * Stops the capturer. This method uses a promise to return the result. 1337 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1338 * @returns { Promise<void> } the promise used to return the result. 1339 * @throws { BusinessError } 201 - Permission denied. 1340 * @throws { BusinessError } 22700107 - System error. 1341 * @syscap SystemCapability.AI.IntelligentVoice.Core 1342 * @systemapi 1343 * @since 12 1344 */ 1345 stopCapturer(): Promise<void>; 1346 /** 1347 * Releases the engine, This method uses an asynchronous callback to return the result. 1348 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1349 * @param { AsyncCallback<void> } callback - the callback used to return the result. 1350 * @throws { BusinessError } 201 - Permission denied. 1351 * @syscap SystemCapability.AI.IntelligentVoice.Core 1352 * @systemapi 1353 * @since 10 1354 */ 1355 release(callback: AsyncCallback<void>): void; 1356 /** 1357 * Releases the engine, This method uses a promise to return the result. 1358 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1359 * @returns { Promise<void> } the promise used to return the result. 1360 * @throws { BusinessError } 201 - Permission denied. 1361 * @syscap SystemCapability.AI.IntelligentVoice.Core 1362 * @systemapi 1363 * @since 10 1364 */ 1365 release(): Promise<void>; 1366 /** 1367 * Subscribes wakeup intelligent voice events. When wakeup intelligent voice events reach, 1368 * the callback is invoked. 1369 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1370 * @param { 'wakeupIntelligentVoiceEvent' } type - Type of the event to listen for. Only the wakeupIntelligentVoice event is supported. 1371 * @param { Callback<WakeupIntelligentVoiceEngineCallbackInfo> } callback - the callback invoked when the event is triggered. 1372 * @throws { BusinessError } 201 - Permission denied. 1373 * @syscap SystemCapability.AI.IntelligentVoice.Core 1374 * @systemapi 1375 * @since 10 1376 */ 1377 on(type: 'wakeupIntelligentVoiceEvent', callback: Callback<WakeupIntelligentVoiceEngineCallbackInfo>): void; 1378 /** 1379 * Unsubscribes wakeup intelligent voice events. 1380 * @permission ohos.permission.MANAGE_INTELLIGENT_VOICE 1381 * @param { 'wakeupIntelligentVoiceEvent' } type - Type of the event to listen for. Only the wakeupIntelligentVoice event is supported. 1382 * @param { Callback<WakeupIntelligentVoiceEngineCallbackInfo> } [callback] - the callback invoked when the event is triggered. 1383 * @throws { BusinessError } 201 - Permission denied. 1384 * @syscap SystemCapability.AI.IntelligentVoice.Core 1385 * @systemapi 1386 * @since 10 1387 */ 1388 off(type: 'wakeupIntelligentVoiceEvent', callback?: Callback<WakeupIntelligentVoiceEngineCallbackInfo>): void; 1389 } 1390} 1391 1392export default intelligentVoice;