Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
143a745b
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
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看板
提交
143a745b
编写于
7月 29, 2023
作者:
L
lvqiang214
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add api references for intelligent voice
Signed-off-by:
N
lvqiang214
<
lvqiang1@huawei.com
>
上级
562258f2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1689 addition
and
0 deletion
+1689
-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
+1567
-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
+119
-0
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
143a745b
...
...
@@ -297,6 +297,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
浏览文件 @
143a745b
# @ohos.ai.intelligentVoice (智能语音)
智能语音组件包括智能语音服务框架和智能语音驱动,主要提供了语音注册及语音唤醒相关功能。
> **说明:**
>
> 本模块首批接口从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
=
intelligentVoice
.
getIntelligentVoiceManager
();
if
(
intelligentvoiceManager
==
null
)
{
console
.
error
(
"
Get IntelligentVoiceManager failed.
"
);
}
else
{
console
.
info
(
"
Get IntelligentVoiceManager success.
"
);
return
;
}
```
## 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 | if input parameter value error. |
**示例:**
```
js
let
engineDescriptor
=
{
wakeupPhrase
:
''
,
}
intelligentVoice
.
createEnrollIntelligentVoiceEngine
(
engineDescriptor
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`EnrollIntelligentVoice Created: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
EnrollIntelligentVoice Created: Success: SUCCESS
'
);
let
engine
=
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 | if input parameter value error. |
**示例:**
```
js
var
engine
=
null
;
let
engineDescriptor
=
{
wakeupPhrase
:
''
,
}
intelligentVoice
.
createEnrollIntelligentVoiceEngine
(
engineDescriptor
).
then
((
data
)
=>
{
engine
=
data
;
console
.
info
(
'
Create EnrollIntelligentVoice Engine finish
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Create EnrollIntelligentVoice Engine failed, err:
'
+
err
.
message
);
});
if
(
engine
==
null
)
{
console
.
error
(
'
Create EnrollIntelligentVoice Engine failed
'
);
return
;
}
```
## 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 | if input parameter value error. |
**示例:**
```
js
let
engineDescriptor
=
{
needApAlgEngine
:
true
,
wakeupPhrase
:
''
,
}
intelligentVoice
.
createWakeupIntelligentVoiceEngine
(
engineDescriptor
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`WakeupIntelligentVoice Created: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
WakeupIntelligentVoice Created: Success: SUCCESS
'
);
let
engine
=
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 | if input parameter value error. |
**示例:**
```
js
var
engine
=
null
;
let
engineDescriptor
=
{
needApAlgEngine
:
true
,
wakeupPhrase
:
''
,
}
intelligentVoice
.
createWakeupIntelligentVoiceEngine
(
engineDescriptor
).
then
((
data
)
=>
{
engine
=
data
;
console
.
info
(
'
Create WakeupIntelligentVoice Engine finish
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Create WakeupIntelligentVoice Engine failed, err:
'
+
err
.
message
);
});
if
(
engine
==
null
)
{
console
.
error
(
'
Create WakeupIntelligentVoice Engine failed
'
);
return
;
}
```
## IntelligentVoiceManager
智能语音管理器类,使用前需要通过getIntelligentVoiceManager获取智能语音管理实例。
### 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'): void
取消订阅服务变更事件。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | 是 | 系统服务变更事件,固定取值为'serviceChange'。 |
**示例:**
```
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
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| needApAlgEngine | boolean | 是 | 需要ap算法引擎。 |
| wakeupPhrase | string | 是 | 唤醒词。 |
## EnrollEngineConfig
描述注册引擎配置。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| language | string | 是 | 注册引擎支持的语言。 |
| region | string | 是 | 注册引擎支持的区域。 |
## 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。 |
## EnrollIntelligentVoiceEventType
枚举,注册智能语音事件类型。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| INTELLIGENT_VOICE_EVENT_ENROLL_NONE | 0 | 无注册。 |
| INTELLIGENT_VOICE_EVENT_ENROLL_INIT_DONE | 1 | 初始化完成。 |
| INTELLIGENT_VOICE_EVENT_ENROLL_COMPLETE | 2 | 注册完成。 |
| INTELLIGENT_VOICE_EVENT_COMMIT_ENROLL_COMPLETE | 3 | 提交注册完成。 |
## WakeupIntelligentVoiceEventType
枚举,唤醒智能语音事件类型。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| INTELLIGENT_VOICE_EVENT_WAKEUP_NONE | 0 | 无唤醒。 |
| INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE | 1 | 识别完成。 |
## IntelligentVoiceErrorCode
枚举,智能语音错误码。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 值 | 说明 |
| ------------------------- | ---- | ------------ |
| INTELLIGENT_VOICE_SUCCESS | 0 | 成功。 |
| INTELLIGENT_VOICE_NO_MEMORY | 22700101 | 内存不足。 |
| INTELLIGENT_VOICE_INVALID_PARAM | 22700102 | 参数无效。 |
| INTELLIGENT_VOICE_INIT_FAILED | 22700103 | 初始化失败。 |
| INTELLIGENT_VOICE_ENROLL_FAILED | 22700104 | 注册失败。 |
| INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED | 22700105 | 提交注册失败。 |
| INTELLIGENT_VOICE_RECOGNIZE_FAILED | 22700106 | 识别失败。 |
## EnrollIntelligentVoiceEngineCallbackInfo
介绍注册智能语音引擎回调信息。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| eventId |
[
EnrollIntelligentVoiceEventType
](
#enrollintelligentvoiceeventtype
)
| 是 | 注册事件ID。 |
| errCode |
[
IntelligentVoiceErrorCode
](
#intelligentvoiceerrorcode
)
| 是 | 错误码。 |
| context | string | 是 | 描述注册事件上下文。 |
## WakeupIntelligentVoiceEngineCallbackInfo
描述唤醒智能语音引擎回调信息。
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 名称 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | -------------- | ---------- |
| eventId |
[
WakeupIntelligentVoiceEventType
](
#wakeupintelligentvoiceeventtype
)
| 是 | 唤醒事件ID。 |
| errCode |
[
IntelligentVoiceErrorCode
](
#intelligentvoiceerrorcode
)
| 是 | 错误码。 |
| context | string | 是 | 描述注册事件上下文。 |
## EnrollIntelligentVoiceEngine
实现注册智能语音引擎。
### getSupportedRegions
getSupportedRegions(callback: AsyncCallback
<
Array
<
string
>>
): void
获取支持的区域,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
<
Array
<
string
>>
| 是 | 支持区域的回调结果。 |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
getSupportedRegions
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to getSupportedRegions,
${
err
}
`
);
}
else
{
console
.
info
(
'
getSupportedRegions success.
'
);
let
regions
=
data
;
}
});
```
### getSupportedRegions
getSupportedRegions(): Promise
<
Array
<
string
>>
获取支持的区域,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
Array
<
string
>>
| 返回支持区域。 |
**示例:**
```
js
let
regions
;
enrollIntelligentVoiceEngine
.
getSupportedRegions
().
then
((
data
)
=>
{
regions
=
data
;
console
.
info
(
'
getSupportedRegions success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to getSupportedRegion: ERROR :
${
err
}
`
);
});
```
### init
init(config: EnrollEngineConfig, callback: AsyncCallback
<
EnrollIntelligentVoiceEngineCallbackInfo
>
): void
初始化引擎,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| config |
[
EnrollEngineConfig
](
#enrollengineconfig
)
| 是 | config表示注册引擎配置。 |
| callback |AsyncCallback
\<
[
EnrollIntelligentVoiceEngineCallbackInfo
](
#enrollintelligentvoiceenginecallbackinfo
)
\>
| 是 | 初始化返回结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
let
config
=
{
language
:
"
zh
"
,
area
:
"
CN
"
,
}
enrollIntelligentVoiceEngine
.
init
(
config
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Init EnrollIntelligentVoice Engine finish, Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
Init EnrollIntelligentVoice Engine SUCCESS
'
);
let
callbackInfo
=
data
;
}
});
```
### init
init(config: EnrollEngineConfig): Promise
<
EnrollIntelligentVoiceEngineCallbackInfo
>
初始化引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| config |
[
EnrollEngineConfig
](
#enrollengineconfig
)
| 是 | config表示注册引擎配置。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
[EnrollIntelligentVoiceEngineCallbackInfo](#enrollintelligentvoiceenginecallbackinfo)
>
| 初始化回调信息。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
let
config
=
{
language
:
"
zh
"
,
area
:
"
CN
"
,
}
let
callbackInfo
;
enrollIntelligentVoiceEngine
.
init
(
config
).
then
((
data
)
=>
{
callbackInfo
=
data
;
console
.
info
(
'
Init EnrollIntelligentVoice Engine finish
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
Init EnrollIntelligentVoice Engine failed, err:
'
+
err
.
message
);
});
```
### start
start(isLast: boolean, callback: AsyncCallback
<
EnrollIntelligentVoiceEngineCallbackInfo
>
): void
启动引擎,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| isLast | boolean | 是 | isLast表示是否为最后一次启动。 |
| callback | AsyncCallback
<
[EnrollIntelligentVoiceEngineCallbackInfo](#enrollintelligentvoiceenginecallbackinfo)
>
| 是 | 启动结果返回。 |
**示例:**
```
js
let
isLast
=
true
;
enrollIntelligentVoiceEngine
.
start
(
isLast
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Start enrollment failed, error:
${
err
}
`
);
}
else
{
console
.
info
(
'
Start enrollment finish
'
);
let
callbackInfo
=
data
;
}
});
```
### start
start(isLast: boolean): Promise
<
EnrollIntelligentVoiceEngineCallbackInfo
>
启动引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| isLast | boolean | 是 | isLast表示是否为最后一次启动。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
[EnrollIntelligentVoiceEngineCallbackInfo](#enrollintelligentvoiceenginecallbackinfo)
>
| 启动结果回调信息。 |
**示例:**
```
js
let
isLast
=
true
;
let
callbackInfo
;
enrollIntelligentVoiceEngine
.
start
(
isLast
).
then
((
data
)
=>
{
callbackInfo
=
data
;
console
.
info
(
'
Start enrollment finish
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
Start enrollment failed, err:
'
+
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
(
`enrollIntelligentVoiceEngine stop: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
enrollIntelligentVoiceEngine stop Success
'
);
}
});
```
### stop
stop(): Promise
<
void
>
停止引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**示例:**
```
js
enrollIntelligentVoiceEngine
.
stop
().
then
(()
=>
{
console
.
info
(
'
enrollIntelligentVoiceEngine stop
'
);
});
```
### commit
commit(callback: AsyncCallback
<
EnrollIntelligentVoiceEngineCallbackInfo
>
): void
提交注册,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
<
[EnrollIntelligentVoiceEngineCallbackInfo](#enrollintelligentvoiceenginecallbackinfo)
>
| 是 | 提交注册结果返回。 |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
commit
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Commit enroll result failed, err:
${
err
}
`
);
}
else
{
console
.
info
(
'
Commit enroll result finish
'
);
let
callbackInfo
=
data
;
}
});
```
### commit
commit(): Promise
<
EnrollIntelligentVoiceEngineCallbackInfo
>
提交注册,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Promise
<
[EnrollIntelligentVoiceEngineCallbackInfo](#enrollintelligentvoiceenginecallbackinfo)
>
| 提交注册回调信息。 |
**示例:**
```
js
let
callbackInfo
;
enrollIntelligentVoiceEngine
.
commit
().
then
((
data
)
=>
{
callbackInfo
=
data
;
console
.
info
(
'
Commit enroll result finish
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
Commit enroll result failed, err:
'
+
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> | 是 | 返回结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
demo
"
,
abilityName
:
"
demo
"
,
}
enrollIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
,(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Set wakeup hap info failed, err:
${
err
}
`
);
}
else
{
console
.
info
(
'
Set wakeup hap info finish
'
);
}
});
```
### setWakeupHapInfo
setWakeupHapInfo(info: WakeupHapInfo): Promise
\<
void>
设置唤醒hap信息,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| info |
[
WakeupHapInfo
](
#wakeuphapinfo
)
| 是 | 唤醒hap信息。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
demo
"
,
abilityName
:
"
demo
"
,
}
enrollIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
).
then
(()
=>
{
console
.
info
(
'
Set wakeup hap info finish
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
Set wakeup hap info failed, err:
'
+
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 | if input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
,(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`setSensibility: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
setSensibility: Success: SUCCESS
'
);
}
});
```
### setSensibility
setSensibility(sensibility: SensibilityType): Promise
\<
void>
设置灵敏度,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| sensibility |
[
SensibilityType
](
#sensibilitytype
)
| 是 | 灵敏度类型。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
).
then
(()
=>
{
console
.
info
(
'
setSensibility Success : Stream Type: SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setSensibility : ERROR :
${
err
}
`
);
});
```
### 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 | if input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setParameter
(
'
scene
'
,
'
0
'
,(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`setParameter: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
setParameter: Success: SUCCESS
'
);
}
});
```
### setParameter
setParameter(key: string, value: string): Promise
\<
void>
设置参数,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| value | string | 是 | 值。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
setSensibility
(
'
scene
'
,
'
0
'
).
then
(()
=>
{
console
.
info
(
'
setParameter Success : Stream Type: SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setParameter : ERROR :
${
err
}
`
);
});
```
### 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 | if input parameter value error. |
**示例:**
```
js
enrollIntelligentVoiceEngine
.
getParameter
(
'
key
'
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getParameter: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getParameter: Success: SUCCESS
'
);
let
param
=
data
;
}
});
```
### 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 | if input parameter value error. |
**示例:**
```
js
let
param
;
enrollIntelligentVoiceEngine
.
getParameter
(
'
key
'
).
then
((
data
)
=>
{
param
=
data
;
console
.
info
(
'
getParameter: Success : Stream Type: SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`getParameter: ERROR :
${
err
}
`
);
});
```
### 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
(
`Release EnrollIntelligentVoice engine failed, err:
${
err
}
`
);
}
else
{
console
.
info
(
'
Release EnrollIntelligentVoice engine success.
'
);
}
});
```
### release
release(): Promise
<
void
>
通过Promise释放引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**示例:**
```
js
enrollIntelligentVoiceEngine
.
release
().
then
(()
=>
{
console
.
info
(
'
Release EnrollIntelligentVoice engine success.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
Release EnrollIntelligentVoice engine failed, err:
'
+
err
.
message
);
});
```
## WakeupIntelligentVoiceEngine
实现唤醒智能语音引擎。
### getSupportedRegions
getSupportedRegions(callback: AsyncCallback
\<
Array
\<
string>>): void
获取支持的区域,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| callback | AsyncCallback
\<
void> | 是 | 返回的结果。 |
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
getSupportedRegions
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to getSupportedRegions,
${
err
}
`
);
}
else
{
console
.
info
(
'
getSupportedRegions success.
'
);
let
regions
=
data
;
}
});
```
### getSupportedRegions
getSupportedRegions(): Promise
\<
Array
\<
string>>
获取支持的区域,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ---------------------------- |
| Array
\<
string> | 返回受支持区域。 |
**示例:**
```
js
let
regions
;
wkeupIntelligentVoiceEngine
.
getSupportedRegions
().
then
((
data
)
=>
{
regions
=
data
;
console
.
info
(
'
getSupportedRegions success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to getSupportedRegion: ERROR :
${
err
}
`
);
});
```
### 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> | 是 | 返回的结果。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
demo
"
,
abilityName
:
"
demo
"
,
}
wkeupIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
,(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Set wakeup hap info failed, err:
${
err
}
`
);
}
else
{
console
.
info
(
'
Set wakeup hap info finish
'
);
}
});
```
### setWakeupHapInfo
setWakeupHapInfo(info: WakeupHapInfo): Promise
\<
void>
设置唤醒hap信息,使用promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| info |
[
WakeupHapInfo
](
#wakeuphapinfo
)
| 是 | 唤醒hap信息。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
let
info
=
{
bundleName
:
"
demo
"
,
abilityName
:
"
demo
"
,
}
wkeupIntelligentVoiceEngine
.
setWakeupHapInfo
(
info
).
then
(()
=>
{
console
.
info
(
'
Set wakeup hap info finish
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
Set wakeup hap info failed, err:
'
+
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 | if input parameter value error. |
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
,(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`setSensibility: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
setSensibility: Success: SUCCESS
'
);
}
});
```
### setSensibility
setSensibility(sensibility: SensibilityType): Promise
\<
void>
设置灵敏度,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| sensibility |
[
SensibilityType
](
#sensibilitytype
)
| 是 | 灵敏度类型。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
setSensibility
(
intelligentVoice
.
SensibilityType
.
LOW_SENSIBILITY
).
then
(()
=>
{
console
.
info
(
'
setSensibility Success : Stream Type: SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setSensibility : ERROR :
${
err
}
`
);
});
```
### 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 | if input parameter value error. |
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
setParameter
(
'
scene
'
,
'
0
'
,(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`setParameter: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
setParameter: Success: SUCCESS
'
);
}
});
```
### setParameter
setParameter(key: string, value: string): Promise
\<
void>
设置参数,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| key | string | 是 | 键。 |
| value | string | 是 | 值。 |
**错误码:**
以下错误码的详细介绍请参见
[
智能语音错误码
](
../errorcodes/errorcode-intelligentVoice.md
)
。
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------|
| 22700102 | if input parameter value error. |
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
setSensibility
(
'
scene
'
,
'
0
'
).
then
(()
=>
{
console
.
info
(
'
setParameter Success : Stream Type: SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`setParameter : ERROR :
${
err
}
`
);
});
```
### 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 | if input parameter value error. |
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
getParameter
(
'
key
'
,(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
`getParameter: Error:
${
err
}
`
);
}
else
{
console
.
info
(
'
getParameter: Success: SUCCESS
'
);
let
param
=
data
;
}
});
```
### 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 | if input parameter value error. |
**示例:**
```
js
let
param
;
wkeupIntelligentVoiceEngine
.
getParameter
(
'
key
'
).
then
((
data
)
=>
{
param
=
data
;
console
.
info
(
'
getParameter: Success : Stream Type: SUCCESS
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`getParameter: ERROR :
${
err
}
`
);
});
```
### release
release(callback: AsyncCallback
\<
void>): void
释放引擎,使用callback异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
release
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Release EnrollIntelligentVoice engine failed, err:
${
err
}
`
);
}
else
{
console
.
info
(
'
Release EnrollIntelligentVoice engine success.
'
);
}
});
```
### release
release(): Promise
\<
void>
释放引擎,使用Promise异步回调。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
release
().
then
(()
=>
{
console
.
info
(
'
Release EnrollIntelligentVoice engine success.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
Release EnrollIntelligentVoice engine failed, err:
'
+
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
wkeupIntelligentVoiceEngine
.
on
(
'
wakeupIntelligentVoiceEvent
'
,
(
callback
)
=>
{
console
.
info
(
`
${
tag
}
: wakeup intelligentvoice event`
);
for
(
let
prop
in
callback
)
{
console
.
info
(
`
${
tag
}
: intelligentvoice prop:
${
prop
}
`
);
}
});
```
### off
off(type: 'wakeupIntelligentVoiceEvent')
取消订阅唤醒智能语音事件。
**需要权限:**
ohos.permission.MANAGE_INTELLIGENT_VOICE
**系统能力:**
SystemCapability.AI.IntelligentVoice.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type |string | 是 | 唤醒智能语音事件,固定取为'wakeupIntelligentVoiceEvent'。 |
**示例:**
```
js
wkeupIntelligentVoiceEngine
.
off
(
'
wakeupIntelligentVoiceEvent
'
);
```
zh-cn/application-dev/reference/errorcodes/Readme-CN.md
浏览文件 @
143a745b
...
...
@@ -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
浏览文件 @
143a745b
# IntelligentVoice错误码
> **说明:**
>
> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。
## 22700101 内存不足
**错误信息**
No memory.
**错误描述**
调用接口时,分配内存失败或者出现空指针。
**可能原因**
1.
系统内存压力大,没有足够的内存用来映射。
2.
对于失效的实例,没有及时销毁释放内存。
**处理步骤**
1.
停止当前操作,或者暂停其他的应用,以保证当前业务有可用内存。
2.
主动清空失效的实例,释放内存后再重新创建事件,仍然失败,则停止相关操作。
## 22700102 无效入参
**错误信息**
if input parameter value error.
**错误描述**
调用接口时,传入的参数无效。
**可能原因**
参数无效,比如值不在边界范围内,没有使用指定的枚举范围等。
**处理步骤**
根据接口文档,传入正确的入参。
## 22700103 初始化失败
**错误信息**
Init failed.
**错误描述**
调用引擎的初始化接口时,返回初始化失败。
**可能原因**
1、重复初始化。
2、没有初始化所需要的资源。
**处理步骤**
1、不要重复初始化。
2、确认初始化资源已经预置
## 22700104 注册失败
**错误信息**
Enroll failed.
**错误描述**
调用注册引擎的注册接口时,返回注册失败。
**可能原因**
1、创建录音流失败。
2、用户没有准确说出唤醒词。
**处理步骤**
1、确认录音流失败的原因后再重新发起注册。
2、按照界面提示的唤醒词进行注册。
## 22700105 确认注册完成失败
**错误信息**
Commit enroll failed.
**错误描述**
调用注册引擎的确认注册完成接口时,返回失败。
**可能原因**
没有完成指定次数的注册流程。
**处理步骤**
根据界面上要求的注册次数注册完成后再确认注册结果。
## 22700106 唤醒失败
**错误信息**
Recognize failed.
**错误描述**
注册唤醒引擎的唤醒事件监听后,接收到唤醒事件时,返回唤醒失败。
**可能原因**
误唤醒或者用户未准确说出注册的唤醒词
**处理步骤**
不处理该次唤醒事件
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录