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