Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
70248a5f
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
70248a5f
编写于
8月 14, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 14, 2023
浏览文件
操作
浏览文件
下载
差异文件
!21478 add intelligent voice api reference
Merge pull request !21478 from lvqiang214/master
上级
2d2b459b
6c7be0e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1727 addition
and
0 deletion
+1727
-0
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+1
-0
zh-cn/application-dev/reference/apis/js-apis-intelligentVoice.md
...pplication-dev/reference/apis/js-apis-intelligentVoice.md
+1643
-0
zh-cn/application-dev/reference/errorcodes/Readme-CN.md
zh-cn/application-dev/reference/errorcodes/Readme-CN.md
+2
-0
zh-cn/application-dev/reference/errorcodes/errorcode-intelligentVoice.md
...on-dev/reference/errorcodes/errorcode-intelligentVoice.md
+81
-0
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
70248a5f
...
...
@@ -301,6 +301,7 @@
-
AI
-
[
@ohos.ai.mindSporeLite (推理能力)
](
js-apis-mindSporeLite.md
)
-
[
@ohos.ai.intelligentVoice (智能语音)
](
js-apis-intelligentVoice.md
)
-
电话服务
-
[
@ohos.contact (联系人)
](
js-apis-contact.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-intelligentVoice.md
0 → 100755
浏览文件 @
70248a5f
# @ohos.ai.intelligentVoice (智能语音)
智能语音主要提供了语音注册及语音唤醒相关功能。
该模块提供以下智能语音相关的常用功能:
-
[
IntelligentVoiceManager
](
#intelligentvoicemanager
)
:智能语音管理类,明确当前智能语音提供的相关功能,当前支持语音注册、语音唤醒。在进行智能语音相关开发前,需先调用
[
getIntelligentVoiceManager()
](
#intelligentvoicegetintelligentvoicemanager
)
确认当前支持智能语音的相关功能,再进行语音注册和语音唤醒的相关开发。
-
[
EnrollIntelligentVoiceEngine
](
#enrollintelligentvoiceengine
)
:实现语音注册。开发者需要先进行智能语音的注册,然后才能进行唤醒。
-
[
WakeupIntelligentVoiceEngine
](
#wakeupintelligentvoiceengine
)
:实现语音唤醒。开发者需要先进行智能语音的注册,然后才能进行唤醒。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
## 导入模块
```
js
import
intelligentVoice
from
'
@ohos.ai.intelligentVoice
'
;
```
## intelligentVoice.getIntelligentVoiceManager
getIntelligentVoiceManager(): IntelligentVoiceManager
获取智能语音管理类。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------- | ------------ |
|
[
IntelligentVoiceManager
](
#intelligentvoicemanager
)
| 智能语音管理类。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700101 | No memory. |
**示例:**
```
js
var
intelligentVoiceManager
=
null
;
try
{
intelligentVoiceManager
=
intelligentVoice
.
getIntelligentVoiceManager
();
}
catch
(
err
)
{
console
.
error
(
'
Get IntelligentVoiceManager failed. Code:${err.code}, message:${err.message}
'
);
}
```
## intelligentVoice.createEnrollIntelligentVoiceEngine
createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor, callback: AsyncCallback
<
EnrollIntelligentVoiceEngine
>
): void
创建智能语音注册引擎实例,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ---------------------- |
| descriptor |
[
EnrollIntelligentVoiceEngineDescriptor
](
#enrollintelligentvoiceenginedescriptor
)
| 是 | 智能语音注册引擎描述符。 |
| callback | AsyncCallback
\<
[
EnrollIntelligentVoiceEngine
](
#enrollintelligentvoiceengine
)
\>
| 是 | 返回注册智能语音引擎。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700101 | No memory. |
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
engineDescriptor
=
{
wakeupPhrase
:
'
小花小花
'
,
}
var
enrollIntelligentVoiceEngine
=
null
;
intelligentVoice
.
createEnrollIntelligentVoiceEngine
(
engineDescriptor
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to create enrollIntelligentVoice engine, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in creating enrollIntelligentVoice engine.
'
);
enrollIntelligentVoiceEngine
=
data
;
}
});
```
## intelligentVoice.createEnrollIntelligentVoiceEngine
createEnrollIntelligentVoiceEngine(descriptor: EnrollIntelligentVoiceEngineDescriptor): Promise
<
EnrollIntelligentVoiceEngine
>
创建智能语音注册引擎实例,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ---------------------- |
| descriptor |
[
EnrollIntelligentVoiceEngineDescriptor
](
#enrollintelligentvoiceenginedescriptor
)
| 是 | 智能语音注册引擎描述符。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
\<
[
EnrollIntelligentVoiceEngine
](
#enrollintelligentvoiceengine
)
\>
| 返回注册智能语音引擎。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700101 | No memory. |
| 22700102 | Input parameter value error. |
**示例:**
```
js
var
enrollIntelligentVoiceEngine
=
null
;
let
engineDescriptor
=
{
wakeupPhrase
:
'
小花小花
'
,
}
intelligentVoice
.
createEnrollIntelligentVoiceEngine
(
engineDescriptor
).
then
((
data
)
=>
{
enrollIntelligentVoiceEngine
=
data
;
console
.
info
(
'
Succeeded in creating enrollIntelligentVoice engine.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to create enrollIntelligentVoice engine, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
## intelligentVoice.createWakeupIntelligentVoiceEngine
createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor, callback: AsyncCallback
<
WakeupIntelligentVoiceEngine
>
): void
创建智能语音唤醒引擎实例,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ---------------------- |
| descriptor |
[
WakeupIntelligentVoiceEngineDescriptor
](
#wakeupintelligentvoiceenginedescriptor
)
| 是 | 唤醒智能语音引擎描述符。 |
| callback | AsyncCallback
\<
[
WakeupIntelligentVoiceEngine
](
#wakeupintelligentvoiceengine
)
\>
| 是 | 返回唤醒智能语音引擎。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700101 | No memory. |
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
engineDescriptor
=
{
needReconfirm
:
true
,
wakeupPhrase
:
'
小花小花
'
,
}
var
wakeupIntelligentVoiceEngine
=
null
;
intelligentVoice
.
createWakeupIntelligentVoiceEngine
(
engineDescriptor
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to create wakeupIntelligentVoice engine, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in creating wakeupIntelligentVoice engine.
'
);
wakeupIntelligentVoiceEngine
=
data
;
}
});
```
## intelligentVoice.createWakeupIntelligentVoiceEngine
createWakeupIntelligentVoiceEngine(descriptor: WakeupIntelligentVoiceEngineDescriptor): Promise
<
WakeupIntelligentVoiceEngine
>
创建智能语音唤醒引擎实例,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ---------------------- |
| descriptor |
[
WakeupIntelligentVoiceEngineDescriptor
](
#wakeupintelligentvoiceenginedescriptor
)
| 是 | 唤醒智能语音引擎描述符。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
\<
[
WakeupIntelligentVoiceEngine
](
#wakeupintelligentvoiceengine
)
> | 返回唤醒智能语音引擎。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700101 | No memory. |
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
engineDescriptor
=
{
needReconfirm
:
true
,
wakeupPhrase
:
'
小花小花
'
,
}
var
wakeupIntelligentVoiceEngine
=
null
;
intelligentVoice
.
createWakeupIntelligentVoiceEngine
(
engineDescriptor
).
then
((
data
)
=>
{
wakeupIntelligentVoiceEngine
=
data
;
console
.
info
(
'
Succeeded in creating wakeupIntelligentVoice engine.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to create wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message});
});
```
## IntelligentVoiceManager
智能语音管理类,使用前需要通过
[
getIntelligentVoiceManager()
](
#intelligentvoicegetintelligentvoicemanager
)
获取智能语音管理实例。
### getCapabilityInfo
getCapabilityInfo(): Array
<
IntelligentVoiceEngineType
>
获取支持的智能语音引擎列表信息。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Array
\<
[
IntelligentVoiceEngineType
](
#intelligentvoiceenginetype
)
\>
| 支持的智能语音引擎类型数组。 |
**示例:**
```
js
let
info
=
intelligentVoiceManager
.
getCapabilityInfo
();
```
### on('serviceChange')
on(type: 'serviceChange', callback: Callback
<
ServiceChangeType
>
): void
订阅服务变更事件。当智能语音业务状态发生变化时,调用回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 系统服务变更事件,固定取值为'serviceChange',表示服务变更事件。 |
| callback | Callback
\<
[
ServiceChangeType
](
#servicechangetype
)
\>
| 是 | 服务状态变更对应的处理。|
**示例:**
```
js
intelligentVoiceManager
.
on
(
'
serviceChange
'
,
(
serviceChangeType
)
=>
{});
```
### off('serviceChange')
off(type: 'serviceChange', callback?: Callback
\<
ServiceChangeType
\>
): void
取消订阅服务变更事件。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 系统服务变更事件,固定取值为'serviceChange'。 |
| callback | Callback
\<
[
ServiceChangeType
](
#servicechangetype
)
\>
| 否 | 服务状态变更对应的处理,无参数,则取消所有订阅,否则,取消对应的处理。|
**示例:**
```
js
intelligentVoiceManager
.
off
(
'
serviceChange
'
);
```
## ServiceChangeType
枚举,服务状态变更类型。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| SERVICE_UNAVAILABLE | 0 | 服务状态不可用。 |
## IntelligentVoiceEngineType
枚举,智能语音引擎类型。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| ENROLL_ENGINE_TYPE | 0 | 语音注册引擎。 |
| WAKEUP_ENGINE_TYPE | 1 | 语音唤醒引擎。 |
| UPDATE_ENGINE_TYPE | 2 | 静默升级引擎。 |
## EnrollIntelligentVoiceEngineDescriptor
注册智能语音引擎描述符。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| wakeupPhrase | string | 是 | 唤醒词。 |
## WakeupIntelligentVoiceEngineDescriptor
唤醒智能语音引擎描述符。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| needReconfirm | boolean | 是 | 是否需要再次确认唤醒结果,true为需要,false为不需要。 |
| wakeupPhrase | string | 是 | 唤醒词。 |
## EnrollEngineConfig
描述注册引擎配置。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| language | string | 是 | 注册引擎支持的语言,当前仅支持中文,取值为'zh'。 |
| region | string | 是 | 注册引擎支持的区域。当前仅支持中国,取值为'CN'。 |
## SensibilityType
枚举,唤醒灵敏度类型。
灵敏度用于调整唤醒的门限,灵敏度越高,门限越低,就越容易唤醒。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| LOW_SENSIBILITY | 1 | 低灵敏度。 |
| MIDDLE_SENSIBILITY | 2 | 中灵敏度。 |
| HIGH_SENSIBILITY | 3 | 高灵敏度。 |
## WakeupHapInfo
描述唤醒应用的hap信息。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| bundleName | string | 是 | 唤醒应用的bundleName。 |
| abilityName | string | 是 | 唤醒应用的ailityName。 |
## WakeupIntelligentVoiceEventType
枚举,唤醒智能语音事件类型。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| INTELLIGENT_VOICE_EVENT_WAKEUP_NONE | 0 | 无唤醒。 |
| INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE | 1 | 唤醒识别完成。 |
## IntelligentVoiceErrorCode
枚举,智能语音错误码。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| INTELLIGENT_VOICE_NO_MEMORY | 22700101 | 内存不足。 |
| INTELLIGENT_VOICE_INVALID_PARAM | 22700102 | 参数无效。 |
| INTELLIGENT_VOICE_INIT_FAILED | 22700103 | 注册失败。 |
| INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED | 22700104 | 确认注册结果失败。 |
## EnrollResult
枚举,注册结果。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| SUCCESS | 0 | 注册成功。 |
| VPR_TRAIN_FAILED | -1 | 声纹训练失败。 |
| WAKEUP_PHRASE_NOT_MATCH | -2 | 唤醒短语不匹配。 |
| TOO_NOISY | -3 | 周边环境太吵。 |
| TOO_LOUD | -4 | 声音太大。 |
| INTERVAL_LARGE | -5 | 唤醒词时间间隔太大。 |
| DIFFERENT_PERSON | -6 | 不同人注册唤醒词。 |
| UNKNOWN_ERROR | -100 | 未知错误。 |
## EnrollCallbackInfo
注册回调信息。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| result |
[
EnrollResult
](
#enrollresult
)
| 是 | 注册结果。 |
| context | string | 是 | 描述注册事件上下文。 |
## WakeupIntelligentVoiceEngineCallbackInfo
描述唤醒智能语音引擎回调信息。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| eventId |
[
WakeupIntelligentVoiceEventType
](
#wakeupintelligentvoiceeventtype
)
| 是 | 唤醒智能语音事件类型。 |
| isSuccess | boolean | 是 | 是否唤醒成功,false为唤醒失败,true为唤醒成功。 |
| context | string | 是 | 描述唤醒事件上下文。 |
## EnrollIntelligentVoiceEngine
实现注册智能语音引擎,通过
[
createEnrollIntelligentVoiceEngine()
](
#intelligentvoicecreateenrollintelligentvoiceengine
)
获取注册智能语音引擎。
### getSupportedRegions
getSupportedRegions(callback: AsyncCallback
<
Array
<
string
>>
): void
获取支持的区域,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
<
Array
<
string
>>
| 是 | 返回支持区域的数组,当前只支持中国,对应取值为'CN'。 |
**示例:**
```
js
let
regions
=
null
;
enrollIntelligentVoiceEngine
.
getSupportedRegions
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get supported regions, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
regions
=
data
;
console
.
info
(
'
Succeeded in getting supported regions, regions:${regions}.
'
);
}
});
```
### getSupportedRegions
getSupportedRegions(): Promise
<
Array
<
string
>>
获取支持的区域,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
Array
<
string
>>
| 返回支持区域的数组,当前只支持中国,对应取值为'CN'。 |
**示例:**
```
js
let
regions
=
null
;
enrollIntelligentVoiceEngine
.
getSupportedRegions
().
then
((
data
)
=>
{
regions
=
data
;
console
.
info
(
'
Succeeded in getting supported regions, regions:${regions}.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to get supported regions, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### init
init(config: EnrollEngineConfig, callback: AsyncCallback
<
void
>
): void
初始化注册智能语音引擎,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| config |
[
EnrollEngineConfig
](
#enrollengineconfig
)
| 是 | 注册引擎配置。 |
| callback |AsyncCallback
<
void
>
| 是 | 返回初始化结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
| 22700103 | Init failed. |
**示例:**
```
js
let
config
=
{
language
:
"
zh
"
,
area
:
"
CN
"
,
}
enrollIntelligentVoiceEngine
.
init
(
config
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to initialize enrollIntelligentVoice engine. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in initialzing enrollIntelligentVoice engine.
'
);
}
});
```
### init
init(config: EnrollEngineConfig): Promise
<
void
>
初始化注册智能语音引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| config |
[
EnrollEngineConfig
](
#enrollengineconfig
)
| 是 | config表示注册引擎配置。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
| 22700103 | Init failed. |
**示例:**
```
js
let
config
=
{
language
:
"
zh
"
,
area
:
"
CN
"
,
}
enrollIntelligentVoiceEngine
.
init
(
config
).
then
(()
=>
{
console
.
info
(
'
Succeeded in initializing enrollIntelligentVoice engine.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to initialize enrollIntelligentVoice engine. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### enrollForResult
enrollForResult(isLast: boolean, callback: AsyncCallback
<
EnrollCallbackInfo
>
): void
获取注册结果,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| isLast | boolean | 是 | isLast表示是否为最后一次注册,false为非最后一次,true为最后一次。 |
| callback | AsyncCallback
<
[EnrollCallbackInfo](#enrollcallbackinfo)
>
| 是 | 返回注册结果。 |
**示例:**
```
js
let
isLast
=
true
;
let
callbackInfo
=
null
;
enrollIntelligentVoiceEngine
.
enrollForResult
(
isLast
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to enroll for result, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
callbackInfo
=
data
;
console
.
info
(
'
Succeeded in enrolling for result, info:${callbackInfo}.
'
);
}
});
```
### enrollForResult
enrollForResult(isLast: boolean): Promise
<
EnrollCallbackInfo
>
获取注册结果,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| isLast | boolean | 是 | isLast表示是否为最后一次注册,false为非最后一次,true为最后一次。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
[EnrollCallbackInfo](#enrollcallbackinfo)
>
| 返回注册结果。 |
**示例:**
```
js
let
isLast
=
true
;
let
callbackInfo
=
null
;
enrollIntelligentVoiceEngine
.
enrollForResult
(
isLast
).
then
((
data
)
=>
{
callbackInfo
=
data
;
console
.
info
(
'
Succeeded in enrolling for result, info:${callbackInfo}.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to enroll for result, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### stop
stop(callback: AsyncCallback
<
void
>
): void
停止注册,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
<
void
>
| 是 | 返回停止结果。 |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
stop
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to stop enrollIntelligentVoice engine, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in stopping enrollIntelligentVoice engine.
'
);
}
});
```
### stop
stop(): Promise
<
void
>
停止注册,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
stop
().
then
(()
=>
{
console
.
info
(
'
Succeeded in stopping enrollIntelligentVoice engine.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to stop enrollIntelligentVoice engine, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### commit
commit(callback: AsyncCallback
<
void
>
): void
提交注册,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
<
void
>
| 是 | 返回确认注册结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700104 | Commit enroll failed. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
commit
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to commit enroll, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in committing enroll.
'
);
}
});
```
### commit
commit(): Promise
<
void
>
提交注册,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700104 | Commit enroll failed. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
commit
().
then
(()
=>
{
console
.
info
(
'
Succeeded in committing enroll.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to commit enroll, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### setWakeupHapInfo
setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback
\<
void>): void
设置唤醒应用的hap信息,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| info |
[
WakeupHapInfo
](
#wakeuphapinfo
)
| 是 | 唤醒hap信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回设置唤醒hap信息的结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
com.wakeup
"
,
abilityName
:
"
WakeUpExtAbility
"
,
}
enrollIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to set wakeup hap info, Code:${err.code}, message:${err.message}
'
);
}
else
{
console
.
info
(
'
Succeeded in setting wakeup hap info.
'
);
}
});
```
### setWakeupHapInfo
setWakeupHapInfo(info: WakeupHapInfo): Promise
\<
void
\>
设置唤醒应用的hap信息,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
com.wakeup
"
,
abilityName
:
"
WakeUpExtAbility
"
,
}
enrollIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
).
then
(()
=>
{
console
.
info
(
'
Succeeded in setting wakeup hap info.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set wakeup hap info, Code:${err.code},
});
```
### setSensibility
setSensibility(sensibility: SensibilityType, callback: AsyncCallback
\<
void
\>
): void
设置唤醒灵敏度,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| sensibility |
[
SensibilityType
](
#sensibilitytype
)
| 是 | 灵敏度类型。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回设置灵敏度的结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set sensibility, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in setting sensibility.
'
);
}
});
```
### setSensibility
setSensibility(sensibility: SensibilityType): Promise
\<
void
\>
设置唤醒灵敏度,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| sensibility |
[
SensibilityType
](
#sensibilitytype
)
| 是 | 灵敏度类型。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
).
then
(()
=>
{
console
.
info
(
'
Succeeded in setting sensibility.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to set sensibility, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### setParameter
setParameter(key: string, value: string, callback: AsyncCallback
\<
void
\>
): void
设置指定的智能语音参数,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| value | string | 是 | 值。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回设置智能语音参数的结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setParameter
(
'
scene
'
,
'
0
'
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in setting parameter
'
);
}
});
```
### setParameter
setParameter(key: string, value: string): Promise
\<
void
\>
设置指定的智能语音参数,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| value | string | 是 | 值。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setParameter
(
'
scene
'
,
'
0
'
).
then
(()
=>
{
console
.
info
(
'
Succeeded in setting parameter
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to set parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### getParameter
getParameter(key: string, callback: AsyncCallback
\<
string
\>
): void
获取指定的智能语音参数,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| callback | AsyncCallback
\<
string
\>
| 是 | 返回智能语音参数。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
getParameter
(
'
key
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
let
param
=
data
;
console
.
info
(
'
Succeeded in getting parameter, param:${param}
'
);
}
});
```
### getParameter
getParameter(key: string): Promise
\<
string
\>
获取指定的智能语音参数,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
\<
string
\>
| 返回智能语音参数。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
param
=
null
;
enrollIntelligentVoiceEngine
.
getParameter
(
'
key
'
).
then
((
data
)
=>
{
param
=
data
;
console
.
info
(
'
Succeeded in getting parameter, param:${param}
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to get parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### release
release(callback: AsyncCallback
<
void
>
): void
释放注册智能语音引擎,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回释放注册引擎的结果。 |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
release
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}
'
);
}
else
{
console
.
info
(
'
Succeeded in releasing enrollIntelligentVoice engine.
'
);
}
});
```
### release
release(): Promise
<
void
>
释放注册智能语音引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
release
().
then
(()
=>
{
console
.
info
(
'
Succeeded in releasing enrollIntelligentVoice engine.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to release enrollIntelligentVoice engine, Code:${err.code}, message:${err.message}
'
);
});
```
## WakeupIntelligentVoiceEngine
实现唤醒智能语音引擎,通过
[
createWakeupIntelligentVoiceEngine()
](
#intelligentvoicecreatewakeupintelligentvoiceengine
)
获取唤醒智能语音引擎。
### getSupportedRegions
getSupportedRegions(callback: AsyncCallback
<
Array
<
string
>>
): void
获取支持的区域,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
<
Array
<
string
>>
| 是 | 返回支持区域的数组,当前只支持中国,对应取值为'CN'。 |
**示例:**
```
js
let
regions
=
null
;
wakeupIntelligentVoiceEngine
.
getSupportedRegions
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get supported regions, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
regions
=
data
;
console
.
info
(
'
Succeeded in getting supported regions, regions:${regions}.
'
);
}
});
```
### getSupportedRegions
getSupportedRegions(): Promise
<
Array
<
string
>>
获取支持的区域,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
Array
<
string
>>
| 返回支持区域的数组,当前只支持中国,对应取值为'CN'。 |
**示例:**
```
js
let
regions
=
null
;
wakeupIntelligentVoiceEngine
.
getSupportedRegions
().
then
((
data
)
=>
{
regions
=
data
;
console
.
info
(
'
Succeeded in getting supported regions, regions:${regions}.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to get supported regions, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### setWakeupHapInfo
setWakeupHapInfo(info: WakeupHapInfo, callback: AsyncCallback
\<
void
\>
): void
设置唤醒应用的hap信息,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| info |
[
WakeupHapInfo
](
#wakeuphapinfo
)
| 是 | 唤醒hap信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回设置唤醒hap信息的结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
com.wakeup
"
,
abilityName
:
"
WakeUpExtAbility
"
,
}
wakeupIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to set wakeup hap info, Code:${err.code}, message:${err.message}
'
);
}
else
{
console
.
info
(
'
Succeeded in setting wakeup hap info.
'
);
}
});
```
### setWakeupHapInfo
setWakeupHapInfo(info: WakeupHapInfo): Promise
\<
void
\>
设置唤醒应用的hap信息,使用promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| info |
[
WakeupHapInfo
](
#wakeuphapinfo
)
| 是 | 唤醒hap信息。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
com.wakeup
"
,
abilityName
:
"
WakeUpExtAbility
"
,
}
wakeupIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
).
then
(()
=>
{
console
.
info
(
'
Succeeded in setting wakeup hap info.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set wakeup hap info, Code:${err.code}, message:${err.message}
'
);
});
```
### setSensibility
setSensibility(sensibility: SensibilityType, callback: AsyncCallback
\<
void
\>
): void
设置唤醒灵敏度,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| sensibility |
[
SensibilityType
](
#sensibilitytype
)
| 是 | 灵敏度类型。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回设置灵敏度的结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set sensibility, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in setting sensibility.
'
);
}
});
```
### setSensibility
setSensibility(sensibility: SensibilityType): Promise
\<
void
\>
设置唤醒灵敏度,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| sensibility |
[
SensibilityType
](
#sensibilitytype
)
| 是 | 灵敏度类型。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
).
then
(()
=>
{
console
.
info
(
'
Succeeded in setting sensibility.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to set sensibility, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### setParameter
setParameter(key: string, value: string, callback: AsyncCallback
\<
void
\>
): void
设置指定的智能语音参数,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| value | string | 是 | 值。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回设置智能语音参数的结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
setParameter
(
'
scene
'
,
'
0
'
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
'
Succeeded in setting parameter
'
);
}
});
```
### setParameter
setParameter(key: string, value: string): Promise
\<
void
\>
设置指定的智能语音参数,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| value | string | 是 | 值。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
setParameter
(
'
scene
'
,
'
0
'
).
then
(()
=>
{
console
.
info
(
'
Succeeded in setting parameter
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to set parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### getParameter
getParameter(key: string, callback: AsyncCallback
\<
string
\>
): void
获取指定的智能语音参数,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| callback | AsyncCallback
\<
string
\>
| 是 | 返回智能语音参数。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
getParameter
(
'
key
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
let
param
=
data
;
console
.
info
(
'
Succeeded in getting parameter, param:${param}
'
);
}
});
```
### getParameter
getParameter(key: string): Promise
\<
string
\>
获取指定的智能语音参数,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
\<
string
\>
| 返回智能语音参数。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | Input parameter value error. |
**示例:**
```
js
let
param
;
wakeupIntelligentVoiceEngine
.
getParameter
(
'
key
'
).
then
((
data
)
=>
{
param
=
data
;
console
.
info
(
'
Succeeded in getting parameter, param:${param}
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to get parameter, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
### release
release(callback: AsyncCallback
\<
void
\>
): void
释放唤醒智能语音引擎,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
\<
void
\>
| 是 | 返回释放唤醒引擎的结果。 |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
release
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}
'
);
}
else
{
console
.
info
(
'
Succeeded in releasing wakeupIntelligentVoice engine.
'
);
}
});
```
### release
release(): Promise
\<
void
\>
释放唤醒智能语音引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
release
().
then
(()
=>
{
console
.
info
(
'
Succeeded in releasing wakeupIntelligentVoice engine.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to release wakeupIntelligentVoice engine, Code:${err.code}, message:${err.message}
'
);
});
```
### on
on(type: 'wakeupIntelligentVoiceEvent', callback: Callback
\<
WakeupIntelligentVoiceEngineCallbackInfo
\>
): void
订阅唤醒事件。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 唤醒智能语音事件,固定取为'wakeupIntelligentVoiceEvent',表示智能语音唤醒事件。 |
| callback | Callback
\<
[
WakeupIntelligentVoiceEngineCallbackInfo
](
#wakeupintelligentvoiceenginecallbackinfo
)
\>
| 是 | 收到唤醒事件的对应处理。 |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
on
(
'
wakeupIntelligentVoiceEvent
'
,
(
callback
)
=>
{
console
.
info
(
`wakeup intelligentvoice event`
);
for
(
let
prop
in
callback
)
{
console
.
info
(
`intelligentvoice prop:
${
prop
}
`
);
}
});
```
### off
off(type: 'wakeupIntelligentVoiceEvent', callback?: Callback
\<
WakeupIntelligentVoiceEngineCallbackInfo
\>
): void;
取消订阅唤醒事件。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type |string | 是 | 唤醒智能语音事件,固定取为'wakeupIntelligentVoiceEvent'。 |
| callback | Callback
\<
[
WakeupIntelligentVoiceEngineCallbackInfo
](
#wakeupintelligentvoiceenginecallbackinfo
)
\>
| 否 | 收到唤醒事件的对应处理。无参数,则取消所有的订阅,否则,取消对应的订阅 |
**示例:**
```
js
wakeupIntelligentVoiceEngine
.
off
(
'
wakeupIntelligentVoiceEvent
'
);
```
zh-cn/application-dev/reference/errorcodes/Readme-CN.md
浏览文件 @
70248a5f
...
...
@@ -5,6 +5,8 @@
-
[
元能力子系统错误码
](
errorcode-ability.md
)
-
[
DistributedSchedule错误码
](
errorcode-DistributedSchedule.md
)
-
[
卡片错误码
](
errorcode-form.md
)
-
AI业务
-
[
智能语音错误码
](
errorcode-intelligentVoice.md
)
-
包管理
-
[
包管理子系统通用错误码
](
errorcode-bundle.md
)
-
[
zlib子系统错误码
](
errorcode-zlib.md
)
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-intelligentVoice.md
0 → 100755
浏览文件 @
70248a5f
# IntelligentVoice错误码
> **说明:**
>
> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。
## 22700101 内存不足
**错误信息**
No memory.
**错误描述**
调用接口时,分配内存失败或者出现空指针。
**可能原因**
1.
系统内存压力大,没有足够的内存用来映射。
2.
对于失效的实例,没有及时销毁释放内存。
**处理步骤**
1.
停止当前操作,或者暂停其他的应用,以保证当前业务有可用内存。
2.
主动清空失效的实例,释放内存后再重新创建实例,仍然失败,则停止相关操作。
## 22700102 无效入参
**错误信息**
Input parameter value error.
**错误描述**
调用接口时,传入的参数无效。
**可能原因**
参数无效,比如值不在边界范围内,没有使用指定的枚举范围等。
**处理步骤**
根据接口文档,传入正确的入参。
## 22700103 初始化失败
**错误信息**
Init failed.
**错误描述**
调用引擎的初始化接口时,返回初始化失败。
**可能原因**
1.
重复初始化。
2.
没有注册初始化所需要的资源。
**处理步骤**
1.
不要重复初始化。
2.
确认注册初始化需要的资源(声学模型文件等)已经完备。
## 22700104 确认注册结果失败
**错误信息**
Commit enroll failed.
**错误描述**
调用注册引擎的确认注册结果接口
[
commit()
](
../apis/js-apis-intelligentVoice.md#commit
)
时,返回失败。
**可能原因**
没有完成指定次数的注册流程。
**处理步骤**
根据界面上要求的注册次数注册完成后再确认注册结果。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录