API Path
/aipaas/voice/v1/TibetanNostreamingAsrR/filetrans
请求协议
HTTPS
请求方法
POST
请求头部:
| 头部标签 | 必填 | 说明 | 类型 | 数据字典 | 限制 | 头部内容 | 示例 |
|---|---|---|---|---|---|---|---|
| Content-Type | 是 | 内容类型 | application/json | application/json | |||
| Content-Length | 否 | HTTP Body 中内容的⻓度 | |||||
| X-APP-ID | 是 | 控制台--应用管理--AppID | |||||
| Device-Uuid | 是 | 设备管理-设备uuid | |||||
| Authorization | 是 | 鉴权信息 |
请求参数 Json
Object
| 参数名 | 说明 | 必填 | 类型 | 数据字典 | 限制 | 示例 |
|---|---|---|---|---|---|---|
| req_id | 请求全局唯一 ID,记录该值便于排查问题 | 是 | [string] | 0 | ||
| file_link | 存放录音文件的地址链接,支持 HTTP | 是 | [string] | 0 | ||
| enable_callback | 是否启用回调功能,当前仅支持设为 true(开启回调方式) | 是 | [boolean] | 0 | ||
| callback_url | 回调用户服务的地址,URL 支持 HTTP,如果开启 enable_callback,则该字段必须有值。 | 否 | [string] | 0 | ||
| return_mode | 结果返回模式,0:push,1:pull,默认为0。push模式即提供callback_url接收最终结果回调;pull模型即通过大模型异步调用结果回查接口查询最终调用结果,接口文档详见开发指南下的大模型异步调用结果回查。 | 否 | [int] | 32 | ||
| sample_rate | 音频采样率,默认值 16000 Hz,仅针对pcm 格式音频有效 | 否 | [int] | 0 | ||
| num_channels | 输入音频数据的通道数(正整数),默认值是 1,仅针对pcm 格式音频有效 | 否 | [int] | 0 | ||
| enable_punc | 是否开启加标点,默认值是 true | 否 | [boolean] | 0 | ||
| enable_itn | 是否开启 ITN,默认值是 true | 否 | [boolean] | 0 | ||
| hotwords | 热词列表 | 否 | [array] | 0 | ["热词A", "热词B"] |
响应内容:
返回结果
成功 (200)
Json
Object
| 参数名 | 说明 | 必填 | 类型 | 数据字典 | 限制 | 示例 |
|---|---|---|---|---|---|---|
| code | 状态码,⻅服务码说明 | 是 | [int] | 0 | ||
| message | 状态说明,⻅服务码说明 | 是 | [string] | 0 | ||
| task_id | 识别任务 ID | 是 | [string] | 0 | ||
| business_duration | 识别的音频文件总时长,单位为毫秒,注:如果是双通道音频,总时长也会倍增 | 否 | [int] | 0 | ||
| result | 否 | [object] | 0 | |||
| result>>sentences | 否 | [array] | 0 | |||
| result>>sentences>>begin_time | 该句的起始时间偏移,单位为毫秒 | 否 | [int] | 0 | ||
| result>>sentences>>end_time | 该句的结束时间偏移,单位为毫秒 | 否 | [int] | 0 | ||
| result>>sentences>>texts | 该句的识别文本结果(如果开启 nbest,则是多个文本的列表) | 否 | [string] | 0 | ||
| result>>sentences>>channel_id | 音轨通道id,0 为左声道,1为右声道 | 否 | [int] | 0 | ||
| result>>sentences>>speaker_id | 该句所属说话人 ID(当服务不具备话者分离能力时,speaker_id与channel_id相同) | 否 | [int] | 0 | ||
| result>>sentences>>confidence | 当前句子识别结果的置信度,取值范围:[0.0, 1.0],值越大表示置信度越高 | 否 | [float] | 0 | ||
| result>>sentences>>loudness | 该句的声音响度,单位:db | 否 | [float] | 0 |
详细说明:
离线语音识别,用于将离线音频文件的内容转换为文字的场景。
- 支持多轨 MP3、WAV、PCM、OGG 格式录音文件识别,其中 MP3 文件要求编码格式为 mp3,WAV 和 PCM 文件要求编码格式为 pcm_s16le;
- 支持调用方式:当前仅支持回调方式;
- 支持 8000 Hz、16000 Hz、22050Hz、24000 Hz、32000 Hz、44100 Hz、48000 Hz 采样率;
- 支持汉语普通话;
- 录音文件地址链接支持 HTTP,且访问权限需要保证能被服务端访问和下载;
| 修订日期 | 算法版本号 | 修订内容 |
|---|---|---|
| 2026-05-15 | V1.0.0 | 支持藏语文件音频转写 |
服务接口调用时需要严格遵循服务鉴权规则,服务调用鉴权规则请参见:开发指南 - 接口签名认证。
{
"file_link": "<https://gw.alipayobjects.com/os/bmw-prod/0574ee2e-f494-45a5-820f-63aee583045a.wav>",
"req_id": "3a87fe9793c9-4ebd-95d4-4ce2-a80c054b",
"enable_callback": true,
"callback_url": "<http://{ip}/{port}/{uri}>"
}
| 状态码 | 解释 | 说明 | 解决方法 |
|---|---|---|---|
| 10301 | Required parameter miss | 必填参数缺失 | 检查请求体是否符合接口协议 |
| 10302 | Too many requests | 并发请求过多 | 联系商务,增加并发 |
| 10304 | Parse request body fail | 请求格式错误 | 查看请求的 URL body 格式是否正确,参考接口文档 |
| 10503 | Server connection time out | 服务连接超时 | 联系技术人员 |
| 10603 | Fetch audio failed | 获取音频文件失败 | 检查文件 URL 是否正确 |
| 10604 | Decode audio failed | 解析音频文件失败 | 检查源音频文件格式是否正确 |
| 10605 | Resample audio failed | 重采样音频失败 | 联系技术人员 |
| 10607 | Audio too large | 音频文件过大 | 切分音频再进行识别 |
| 10608 | Audio too long | 音频过长 | 切分音频再进行识别 |
| 10801 | Task processing | 任务处理中 | 等待重新查询 |
| 10903 | Recognition failed | 识别失败 | 联系技术人员 |
| 10904 | Query failed | 查询失败 | 联系技术人员,通常是因为 task id 错误导致 |
| 10905 | Unexpected error | 未知错误 | 联系技术人员 |
| 10000 | Success | 成功 | 执行下一步操作 |
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
* 为保证示例可以正常运行,请确认maven中是否存在以下依赖:
* <dependency>
* <groupId>cn.hutool</groupId>
* <artifactId>hutool-all</artifactId>
* <version>5.8.29</version>
* </dependency>
* <dependency>
* <groupId>com.alibaba</groupId>
* <artifactId>fastjson</artifactId>
* <version>1.2.83</version>
* </dependency>
*/
public class Example {
public static void example() {
try {
// 算法调用地址,请根据实际情况修改
String url = "算法调用地址";
// 设置请求头
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Device-Uuid", "2018619061498245122");
headers.put("X-APP-ID", "你实际的AppId");
headers.put("Authorization", "你实际的Authorization");
// 设置请求参数,请根据实际情况修改
String requestString = "{\\n" +
" \\"req_id\\":\\"\\",\\n" +
" \\"callback_url\\":\\"\\",\\n" +
" \\"num_channels\\":0,\\n" +
" \\"enable_punc\\":false,\\n" +
" \\"sample_rate\\":0,\\n" +
" \\"file_link\\":\\"\\",\\n" +
" \\"enable_itn\\":false,\\n" +
" \\"enable_callback\\":false,\\n" +
" \\"hotwords\\":[]\\n" +
"}";
// 发起HTTP请求
HttpResponse response = HttpRequest.post(url)
.headerMap(headers, true)
.body(requestString)
.execute();
// 输出响应结果
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
example();
}
}
import json
import hashlib
import hmac
import time
import re
import urllib.parse
import requests
import warnings
from datetime import datetime
import logging
# 配置日志,设置日志级别为INFO,并指定日志格式
logging.basicConfig(level=logging.INFO, format=\'%(asctime)s - %(levelname)s - %(message)s\')
# 配置环境变量
X_APP_ID = "yourAppId"
AUTHORIZATION = "yourAuthorization"
# 请求的URL
url = "算法调用地址"
# 请求数据
request_data = {
"req_id":"",
"callback_url":"",
"num_channels":0,
"enable_punc":False,
"sample_rate":0,
"file_link":"",
"enable_itn":False,
"enable_callback":False,
"hotwords":[]
}
# 构建请求头
headers = {
"Content-Type": "application/json",
"Device-Uuid": "2018619061498245122",
"X-APP-ID": X_APP_ID,
"Authorization": AUTHORIZATION
}
def timeSimple(timestamp):
# 将时间戳转换为HH:MM:SS格式的时间字符串
dt_object = datetime.fromtimestamp(timestamp)
formatted_time = dt_object.strftime("%H:%M:%S")
return formatted_time
def send_request(url):
try:
start_time = time.time()
logging.info(f"请求路径: {url}")
logging.info(f"开始发送: {timeSimple(start_time)}")
with requests.post(
url, json=request_data, headers=headers, stream=True, verify=False
) as response:
first_packet_time = None
if response.status_code == 200:
logging.info(f"接受到返回: {timeSimple(time.time())}")
for chunk in response.iter_content(chunk_size=1024):
if chunk:
if first_packet_time is None:
first_packet_time = time.time()
logging.info(
f"Received chunk: {timeSimple(time.time())} {chunk.decode(\'utf-8\')}"
)
end_time = time.time()
logging.info(f"Time to first byte (TTFB): {first_packet_time - start_time:.3f} seconds")
logging.info(f"Request completed in {end_time - start_time:.3f} seconds")
else:
logging.error(f"Request failed with status code {response.status_code}")
except Exception as e:
logging.error(f"An error occurred: {e}")
# 发送请求
send_request(url)
logging.info(f"headers = {headers}")
离线语音识别,用于将离线音频文件的内容转换为文字的场景。
- 支持多轨 MP3、WAV、PCM、OGG 格式录音文件识别,其中 MP3 文件要求编码格式为 mp3,WAV 和 PCM 文件要求编码格式为 pcm_s16le;
- 支持调用方式:当前仅支持回调方式;
- 支持 8000 Hz、16000 Hz、22050Hz、24000 Hz、32000 Hz、44100 Hz、48000 Hz 采样率;
- 支持汉语普通话;
- 录音文件地址链接支持 HTTP,且访问权限需要保证能被服务端访问和下载;
| 修订日期 | 算法版本号 | 修订内容 |
|---|---|---|
| 2026-05-15 | V1.0.0 | 支持藏语文件音频转写 |
服务接口调用时需要严格遵循服务鉴权规则,服务调用鉴权规则请参见:开发指南 - 接口签名认证。
{
"file_link": "<https://gw.alipayobjects.com/os/bmw-prod/0574ee2e-f494-45a5-820f-63aee583045a.wav>",
"req_id": "3a87fe9793c9-4ebd-95d4-4ce2-a80c054b",
"enable_callback": true,
"callback_url": "<http://{ip}/{port}/{uri}>"
}
| 状态码 | 解释 | 说明 | 解决方法 |
|---|---|---|---|
| 10301 | Required parameter miss | 必填参数缺失 | 检查请求体是否符合接口协议 |
| 10302 | Too many requests | 并发请求过多 | 联系商务,增加并发 |
| 10304 | Parse request body fail | 请求格式错误 | 查看请求的 URL body 格式是否正确,参考接口文档 |
| 10503 | Server connection time out | 服务连接超时 | 联系技术人员 |
| 10603 | Fetch audio failed | 获取音频文件失败 | 检查文件 URL 是否正确 |
| 10604 | Decode audio failed | 解析音频文件失败 | 检查源音频文件格式是否正确 |
| 10605 | Resample audio failed | 重采样音频失败 | 联系技术人员 |
| 10607 | Audio too large | 音频文件过大 | 切分音频再进行识别 |
| 10608 | Audio too long | 音频过长 | 切分音频再进行识别 |
| 10801 | Task processing | 任务处理中 | 等待重新查询 |
| 10903 | Recognition failed | 识别失败 | 联系技术人员 |
| 10904 | Query failed | 查询失败 | 联系技术人员,通常是因为 task id 错误导致 |
| 10905 | Unexpected error | 未知错误 | 联系技术人员 |
| 10000 | Success | 成功 | 执行下一步操作 |
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
* 为保证示例可以正常运行,请确认maven中是否存在以下依赖:
* <dependency>
* <groupId>cn.hutool</groupId>
* <artifactId>hutool-all</artifactId>
* <version>5.8.29</version>
* </dependency>
* <dependency>
* <groupId>com.alibaba</groupId>
* <artifactId>fastjson</artifactId>
* <version>1.2.83</version>
* </dependency>
*/
public class Example {
public static void example() {
try {
// 算法调用地址,请根据实际情况修改
String url = "算法调用地址";
// 设置请求头
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Device-Uuid", "2018619061498245122");
headers.put("X-APP-ID", "你实际的AppId");
headers.put("Authorization", "你实际的Authorization");
// 设置请求参数,请根据实际情况修改
String requestString = "{\n" +
" \"req_id\":\"\",\n" +
" \"callback_url\":\"\",\n" +
" \"num_channels\":0,\n" +
" \"enable_punc\":false,\n" +
" \"sample_rate\":0,\n" +
" \"file_link\":\"\",\n" +
" \"enable_itn\":false,\n" +
" \"enable_callback\":false,\n" +
" \"hotwords\":[]\n" +
"}";
// 发起HTTP请求
HttpResponse response = HttpRequest.post(url)
.headerMap(headers, true)
.body(requestString)
.execute();
// 输出响应结果
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
example();
}
}
import json
import hashlib
import hmac
import time
import re
import urllib.parse
import requests
import warnings
from datetime import datetime
import logging
# 配置日志,设置日志级别为INFO,并指定日志格式
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# 配置环境变量
X_APP_ID = "yourAppId"
AUTHORIZATION = "yourAuthorization"
# 请求的URL
url = "算法调用地址"
# 请求数据
request_data = {
"req_id":"",
"callback_url":"",
"num_channels":0,
"enable_punc":False,
"sample_rate":0,
"file_link":"",
"enable_itn":False,
"enable_callback":False,
"hotwords":[]
}
# 构建请求头
headers = {
"Content-Type": "application/json",
"Device-Uuid": "2018619061498245122",
"X-APP-ID": X_APP_ID,
"Authorization": AUTHORIZATION
}
def timeSimple(timestamp):
# 将时间戳转换为HH:MM:SS格式的时间字符串
dt_object = datetime.fromtimestamp(timestamp)
formatted_time = dt_object.strftime("%H:%M:%S")
return formatted_time
def send_request(url):
try:
start_time = time.time()
logging.info(f"请求路径: {url}")
logging.info(f"开始发送: {timeSimple(start_time)}")
with requests.post(
url, json=request_data, headers=headers, stream=True, verify=False
) as response:
first_packet_time = None
if response.status_code == 200:
logging.info(f"接受到返回: {timeSimple(time.time())}")
for chunk in response.iter_content(chunk_size=1024):
if chunk:
if first_packet_time is None:
first_packet_time = time.time()
logging.info(
f"Received chunk: {timeSimple(time.time())} {chunk.decode('utf-8')}"
)
end_time = time.time()
logging.info(f"Time to first byte (TTFB): {first_packet_time - start_time:.3f} seconds")
logging.info(f"Request completed in {end_time - start_time:.3f} seconds")
else:
logging.error(f"Request failed with status code {response.status_code}")
except Exception as e:
logging.error(f"An error occurred: {e}")
# 发送请求
send_request(url)
logging.info(f"headers = {headers}")