跳至主要内容

用户词典注册

用于导入和导出用户词典注册词的API。

获取用户注册词典

可以以JSON格式获取注册单词的列表。

endpoint

GET https://acp-api.amivoice.com/profilewords/<dgn>/<pid>?adf=<adf>

认证

请在Authorization header中指定APPKEY。

Authorization: Bearer {APPKEY}

请求参数

参数名
参数名
注释
dgn连接引擎名称指定类似-a-general的连接引擎名称。可指定的值请参阅语音识别引擎列表。作为路径参数设置。
pidprofileId任意字符串。作为路径参数设置。
adf音频数据格式指定16k8k之一。如果未指定,默认为16k。虽然语音识别引擎可能支持多个采样率,但用户词典将8k16k视为不同的引擎,因此需要指定其中之一。作为查询参数设置。
但是,对于End to End引擎,16k8k被视为相同的引擎,因此无需指定。

获取 profile 列表

可以以JSON格式获取 profile 列表。

endpoint

GET https://acp-api.amivoice.com/profilewords/<dgn>/?adf=<adf>

认证

请在Authorization头中指定APPKEY。

Authorization: Bearer {APPKEY}

请求参数

参数名
参数名
注释
dgn连接引擎名指定如-a-general等连接引擎名。可指定的值请参考语音识别引擎列表。作为路径参数设置。
adf音频数据格式指定16k8k之一。不指定时默认为16k。虽然某些语音识别引擎支持多个采样率,但用户词典需要分别指定8k16k,因为它们被视为不同的引擎。作为查询参数设置。
但是,对于End to End引擎,16k8k被视为相同的引擎,因此无需指定。

注册用户词典单词

可以替换指定语音识别引擎和 profileId 的用户词典单词。

endpoint

POST https://acp-api.amivoice.com/profilewords/<dgn>/<pid>?adf=<adf>

认证

请在Authorization header中指定APPKEY。

Authorization: Bearer {APPKEY}

请求参数

参数名
参数名
注释
dgn连接引擎名称指定类似-a-general的连接引擎名称。可指定的值请参阅语音识别引擎列表
pidprofileId任意字符串。作为路径参数设置。
adf音频数据格式指定16k8k之一。如果未指定,默认为16k。虽然语音识别引擎可能支持多个采样率,但用户词典将8k16k视为不同的引擎,因此需要指定其中之一。
但是,对于End to End引擎,16k8k被视为相同的引擎,因此无需指定。

内容类型

Content-Type: application/json

请求正文

Hybrid 引擎的情况

字段名
说明
补充
profilewords单词注册信息以数组形式指定要注册的单词
profilewords[].written显示指定单词的显示
profilewords[].spoken读音指定单词的读音
profilewords[].classname类名指定类名。未设置时可省略。

示例

{
"profilewords": [
{
"written": "AMI",
"spoken": "あみ"
},
{
"written": "AOI",
"spoken": "あおい"
},
{
"written": "躑躅森",
"spoken": "つつじもり",
"classname": "名前"
}
]
}

End to End引擎的情况

字段名
说明
补充
profilewords单词强调信息以数组形式指定要强调的单词
profilewords[].written显示指定单词的显示
profilewords[].alternativewritten替代显示指定要替换为"显示"的单词显示
profilewords[].biasing单词强调度指定强调单词的强度。可指定0~1的值,0表示不强调,1表示以牺牲整体识别率为代价进行强烈的单词强调。如果不指定,默认为0.5

也可以为相同的显示指定多个替代显示。这时,对于相同显示的单词将应用相同的单词强调度。如果在请求时为相同的显示指定了不同的单词强调度,则将采用请求中最先出现的单词强调度值。在以下示例中,相同显示"AMI"的单词强调度将统一应用其中最先出现的值"0.8"。第三个显示"AOI"的单词强调度由于未指定,将应用默认值"0.5"。

示例

{
"profilewords": [
{
"written": "AMI",
"alternativewritten": "アドバンストメディア",
"biasing": 0.8
},
{
"written": "AMI",
"alternativewritten": "あみ"
},
{
"written": "AOI",
"alternativewritten": "あおい"
}
]
}

响应

成功时

HTTP状态码: 200 OK

响应正文

Hybrid 引擎的情况

字段名
说明
补充
profilewords单词注册信息以数组形式获取注册的单词
profilewords[].written显示获取单词的显示
profilewords[].spoken读音获取单词的读音
profilewords[].classname类名获取类名。未设置时省略

示例

{
"profilewords": [
{
"written": "AMI",
"spoken": "あみ"
},
{
"written": "AOI",
"spoken": "あおい"
},
{
"written": "躑躅森",
"spoken": "つつじもり",
"classname": "名前"
}
]
}

End to End引擎的情况

字段名
说明
补充
profilewords单词强调信息以数组形式获取要强调的单词
profilewords[].written显示获取单词的显示
profilewords[].alternativewritten替代显示获取要替换为"显示"的单词显示
profilewords[].biasing单词强调度获取强调单词的强度。当值为默认的0.5时省略

示例

{
"profilewords": [
{
"written": "AMI",
"alternativewritten": "あみ",
"biasing": 0.8
},
{
"written": "AMI",
"alternativewritten": "アドバンストメディア",
"biasing": 0.8
},
{
"written": "AOI",
"alternativewritten": "あおい"
}
]
}

失败时

HTTP状态码: 非200

响应正文

字段名
说明
补充
code错误代码表示错误类型的代码
message错误消息说明错误详细内容的文本

错误代码和错误消息

HTTP状态码
响应体错误情况
404 Not Found{"code":"?","message":"missing dictation grammar file name"}未指定听写语法文件名 <dgn>
404 Not Found{"code":"?","message":"missing profile id"}未指定 profileId <pid>
405 Method Not Allowed{"code":"?","message":"POST method is not allowed"}指定POST时
400 Bad Request{"code":"-","message":"missing request body"}使用POST方法请求但未指定请求体时
400 Bad Request{"code":"-","message":"invalid request body (<optionalMessage>)"}请求体作为JSON不正确时
422 Unprocessable Entity{"code":"?","message":"missing profile words"}请求体中指定的JSON格式不符合预期时
422 Unprocessable Entity{"code":"?","message":"invalid written: <written>"}请求体中指定的JSON中的显示不正确时
422 Unprocessable Entity{"code":"?","message":"invalid spoken: <spoken>"}请求体中指定的JSON中的读音不正确时
422 Unprocessable Entity{"code":"?","message":"invalid class name: <className>"}请求体中指定的JSON中的单词类不正确时
422 Unprocessable Entity{"code":"?","message":"invalid alternative written: <alternativeWritten>"}请求体中指定的JSON中的替代显示不正确时
401 Unauthorized{"code":"-","message":"can't verify service authorization"}APPKEY(service 认证密钥字符串)认证失败时
401 Unauthorized{"code":"-","message":"service authorization has expired: <expirationTime> (<expiresIn>)"}APPKEY(service 认证密钥字符串)认证失败时
500 Internal Server Error{"code":"?","message":"unexpected exception occurred (<optionalMessage>)"}发生意外异常时

示例

{
"code":"?",
"message":"missing dictation grammar file name"
}