语音识别 (ASR) Speech Recognition (ASR)
基于端到端深度学习的语音识别 API,支持 100+ 语言,提供批量识别和实时流式两种模式。支持说话人分离、关键词检测、标点还原、数字规范化等高级能力。 End-to-end deep learning ASR API for 100+ languages. Supports batch recognition and real-time streaming modes, with speaker diarization, keyword spotting, punctuation restoration, and inverse text normalization.
快速概览
Quick Facts
端点 Endpoint POST /v1/speech/recognize
认证方式 Auth Bearer Token
输入方式 Input 文件上传 (multipart) / Base64 / 音频 URL File upload (multipart) / Base64 / Audio URL
音频上限 Max Size 100 MB
最长时长 Max Duration 4 小时(WAV/MP3/AAC)/ 2 小时(FLAC) 4 hours (WAV/MP3/AAC) / 2 hours (FLAC)
支持语言 Languages 100+ 语言
超时时间 Timeout 60 秒
请求端点 Endpoint
POST /v1/speech/recognize
认证 Authentication
Authorization: Bearer {access_token}
请求头 Request Headers
请求头 Header 必填 Required 说明 Description
Authorization required Bearer 认证,格式:Bearer {access_token} Bearer authentication, format: Bearer {access_token}
Content-Type required 文件上传时使用 multipart/form-data;JSON 模式使用 application/json Use multipart/form-data for file upload; application/json for JSON mode
请求参数 Request Parameters
参数 Parameter 类型 Type 必填 Required 说明 Description
audio file / string required 音频文件(multipart 上传)、Base64 编码字符串或音频 URL(JSON 模式)。≤100MB Audio file (multipart), Base64 string, or audio URL (JSON). ≤100MB
lang string optional 音频语言代码,默认 auto 自动检测。显式指定可提升准确率并减少处理时间。详见语种列表 Language code; default auto. Explicitly specifying improves accuracy and speed. See Language List
format string optional 音频格式:wav / mp3 / flac / aac / ogg / opus / m4a。默认根据文件头自动检测 Audio format: wav / mp3 / flac / aac / ogg / opus / m4a. Auto-detected by default
sample_rate integer optional 音频采样率(Hz),如 8000、16000、44100、48000。默认从文件头读取,若文件头信息缺失则建议指定 Audio sample rate (Hz), e.g., 8000, 16000, 44100, 48000. Read from file header by default; specify if header info is missing
model string optional 声学模型:default(通用,默认)、phone_call(电话语音,8kHz 优化)、video(视频场景,远场优化)、medical(医疗专业领域) Acoustic model: default (general), phone_call (telephony, 8kHz optimized), video (far-field), medical (medical domain)
enable_timestamps boolean optional 是否返回词级/段级时间戳(开始/结束时间),默认 false Return word/segment-level timestamps (start/end), default false
enable_punctuation boolean optional 是否自动添加标点符号和大小写修正,默认 true Auto-add punctuation and case correction, default true
enable_itn boolean optional 是否开启逆文本归一化(将"一千二百三十四"转为"1234","百分之五十"转为"50%"),默认 true Enable inverse text normalization (e.g., "twelve thirty-four" → "1234"), default true
enable_diarization boolean optional 是否开启说话人分离(区分不同说话人),默认 false。开启后每段文本会标注 speaker_id Enable speaker diarization (identify different speakers), default false. Each segment will have speaker_id
speaker_count integer optional 预期说话人数量,仅 enable_diarization=true 时有效。范围 1–10,未指定时自动估算 Expected number of speakers, only when enable_diarization=true. Range 1–10, auto-estimated if not specified
enable_keywords array optional 关键词识别列表,传入需要重点识别的一组词/短语,可提高这些词的识别优先级。如 ["人工智能", "机器学习"] Keyword spotting list: provide words/phrases to boost their recognition priority. E.g., ["AI", "machine learning"]
enable_profanity_filter boolean optional 是否开启敏感词过滤,将识别结果中的不当词语替换为 ***,默认 false Filter profanity, replacing inappropriate words with ***, default false
enable_partial_results boolean optional 是否返回阶段性结果(流式模式下有效),默认 false Return partial/interim results (streaming mode), default false
callback_url string optional 异步回调地址。长音频(>10 分钟)建议使用此模式,识别完成后通过 HTTP POST 推送结果 Async callback URL. Recommended for long audio (>10 min); results pushed via HTTP POST on completion
声学模型选择 Acoustic Model Selection
model 适用场景 Use Case 采样率建议 Sample Rate 特点 Features
default通用场景:会议、演讲、播客 General: meetings, speeches, podcasts 16kHz 泛化能力最强,适用大多数场景 Best generalization, fits most scenarios
phone_call电话录音、呼叫中心、VoIP Phone recordings, call centers, VoIP 8kHz 针对窄带电话语音优化,8kHz 下准确率最高 Optimized for narrowband telephony; highest accuracy at 8kHz
video视频配音、直播、远场拾音 Video dubbing, live streaming, far-field 16-48kHz 远场优化,支持背景噪音抑制和多声道处理 Far-field optimized with noise suppression and multi-channel support
medical医疗听写、病历语音录入 Medical dictation, EHR voice input 16kHz 内置医学术语词库,对药品名、疾病名有更高识别率 Built-in medical lexicon; higher accuracy on drug/disease names
支持音频格式 Supported Audio Formats
格式 Format MIME 类型 MIME Type 采样率 Sample Rate 最大时长 Max Duration 说明 Notes
WAV audio/wav8-48kHz 4 小时 4 hours 无损、推荐格式,支持 PCM/ALAW/ULAW 编码 Lossless, recommended; supports PCM/ALAW/ULAW encoding
MP3 audio/mpeg16-48kHz 4 小时 4 hours 最通用压缩格式,建议码率 ≥ 64kbps Most common compressed format; recommend ≥64kbps bitrate
FLAC audio/flac8-48kHz 2 小时 2 hours 无损压缩,高保真场景首选 Lossless compression; preferred for high-fidelity scenarios
AAC audio/aac16-48kHz 4 小时 4 hours 高效压缩,移动端录制常用 Efficient compression; common for mobile recordings
OGG / Opus audio/ogg8-48kHz 2 小时 2 hours WebRTC 流媒体常用,低延迟场景适用 Common in WebRTC streaming; suitable for low-latency scenarios
M4A audio/mp416-48kHz 4 小时 4 hours iOS 录音默认格式,内部通常为 AAC 编码 Default iOS recording format; typically AAC-encoded
请求示例 Request Examples
cURL — 基础识别(文件上传) cURL — Basic Recognition (File Upload)
curl -X POST https://api.itranslator.cc/v1/speech/recognize \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "audio=@meeting.mp3" \
-F "lang=zh" \
-F "enable_timestamps=true" \
-F "enable_punctuation=true"
Copy
cURL — 高级识别(说话人分离 + 关键词) cURL — Advanced (Diarization + Keywords)
curl -X POST https://api.itranslator.cc/v1/speech/recognize \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "audio=@conference.wav" \
-F "lang=zh" \
-F "model=default" \
-F "enable_diarization=true" \
-F "speaker_count=4" \
-F "enable_itn=true" \
-F "enable_punctuation=true"
Copy
cURL — URL 模式 + 异步回调 cURL — URL Mode + Async Callback
curl -X POST https://api.itranslator.cc/v1/speech/recognize \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"audio": "https://cdn.example.com/lecture.mp3",
"lang": "en",
"enable_timestamps": true,
"enable_diarization": true,
"callback_url": "https://myapp.com/webhook/asr-result"
}'
Copy
Python — 文件上传 Python — File Upload
import requests
with open("meeting.mp3", "rb") as audio:
resp = requests.post(
"https://api.itranslator.cc/v1/speech/recognize",
headers={"Authorization": f"Bearer {token}"},
files={"audio": audio},
data={
"lang": "zh",
"enable_timestamps": True,
"enable_diarization": True,
"enable_punctuation": True
}
)
result = resp.json()
for seg in result.get("segments", []):
speaker = seg.get("speaker_id", "?")
print(f"[{seg['start']:.1f}s–{seg['end']:.1f}s] 说话人{speaker}: {seg['text']}")
Copy
JavaScript (Node.js) JavaScript (Node.js)
const fs = require("fs");
const form = new FormData();
form.append("audio", fs.createReadStream("./meeting.mp3"));
form.append("lang", "zh");
form.append("enable_diarization", "true");
form.append("enable_timestamps", "true");
const resp = await fetch(
"https://api.itranslator.cc/v1/speech/recognize",
{
method: "POST",
headers: { Authorization: `Bearer ${token}` },
body: form
}
);
const data = await resp.json();
console.log("识别文本:", data.text);
data.segments.forEach(s => console.log(
`[${s.start}-${s.end}] ${s.text}`));
Copy
Java Java
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;
HttpClient client = HttpClient.newHttpClient();
byte[] audioBytes = Files.readAllBytes(Path.of("meeting.mp3"));
// 使用 Base64 模式
String base64 = java.util.Base64.getEncoder()
.encodeToString(audioBytes);
String json = String.format(
"{\"audio\":\"%s\",\"lang\":\"zh\",\"enable_timestamps\":true}",
base64);
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.itranslator.cc/v1/speech/recognize"))
.header("Authorization", "Bearer " + token)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> resp = client.send(req,
HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());
Copy
响应字段说明 Response Fields
字段 Field 类型 Type 说明 Description
text string 完整识别文本,已拼接为一段 Full recognized text, concatenated as one paragraph
lang string 识别使用的语言代码 Language code used for recognition
detected_lang string 自动检测到的语言(lang=auto 时返回) Auto-detected language (returned when lang=auto)
duration_seconds float 音频总时长(秒) Total audio duration in seconds
segments array 语音分段数组,每段含 start/end 时间戳、text 文本、confidence 置信度、speaker_id(开启说话人分离时) Segment array, each with start/end timestamps, text, confidence, speaker_id (when diarization enabled)
segments[].start float 分段起始时间(秒) Segment start time in seconds
segments[].end float 分段结束时间(秒) Segment end time in seconds
segments[].speaker_id integer 说话人编号(仅 enable_diarization=true 时返回),从 0 开始 Speaker ID (only when enable_diarization=true), starting from 0
words array 词级时间戳数组(仅 enable_timestamps=true),每词含 word、start、end、confidence Word-level timestamp array (enable_timestamps=true), each with word, start, end, confidence
overall_confidence float 整段音频的平均识别置信度(0–1),≥ 0.90 为高可信 Average confidence for the entire audio (0–1); ≥0.90 considered highly reliable
keywords_matched array 匹配到的关键词列表及出现位置(仅启用关键词识别时返回) Matched keywords and their positions (only when keyword spotting enabled)
processing_time_ms integer 处理耗时(毫秒) Processing time in milliseconds
响应示例 Response Examples
示例 1:基础识别 Example 1: Basic Recognition
{
"text": "今天我们要讨论的产品规划包含三个重点方向,分别是用户体验优化、AI 能力集成以及多平台适配。",
"lang": "zh",
"duration_seconds": 12.5,
"overall_confidence": 0.97,
"processing_time_ms": 450
}
示例 2:带时间戳的段级识别 Example 2: Segment-level with Timestamps
{
"text": "今天我们要讨论的产品规划包含三个重点方向,分别是用户体验优化、AI 能力集成以及多平台适配。",
"lang": "zh",
"duration_seconds": 12.5,
"overall_confidence": 0.97,
"segments": [
{ "start": 0.0, "end": 3.2, "text": "今天我们要讨论的产品规划", "confidence": 0.96 },
{ "start": 3.2, "end": 6.5, "text": "包含三个重点方向,", "confidence": 0.98 },
{ "start": 6.5, "end": 12.5, "text": "分别是用户体验优化、AI 能力集成以及多平台适配。", "confidence": 0.97 }
],
"processing_time_ms": 480
}
示例 3:说话人分离 + 词级时间戳 Example 3: Speaker Diarization + Word-level Timestamps
{
"text": "我觉得这个方案可以尝试。 具体怎么落地呢? 我们可以先做个小范围试点。",
"lang": "zh",
"duration_seconds": 8.2,
"overall_confidence": 0.95,
"segments": [
{
"speaker_id": 0, "start": 0.0, "end": 2.8,
"text": "我觉得这个方案可以尝试。", "confidence": 0.96,
"words": [
{ "word": "我", "start": 0.0, "end": 0.3, "confidence": 0.98 },
{ "word": "觉得", "start": 0.3, "end": 0.7, "confidence": 0.97 },
{ "word": "这个", "start": 0.7, "end": 1.0, "confidence": 0.99 },
{ "word": "方案", "start": 1.0, "end": 1.3, "confidence": 0.95 },
{ "word": "可以", "start": 1.3, "end": 1.8, "confidence": 0.97 },
{ "word": "尝试", "start": 2.0, "end": 2.5, "confidence": 0.94 }
]
},
{
"speaker_id": 1, "start": 3.0, "end": 5.5,
"text": "具体怎么落地呢?", "confidence": 0.97,
"words": [
{ "word": "具体", "start": 3.0, "end": 3.4, "confidence": 0.98 },
{ "word": "怎么", "start": 3.4, "end": 3.8, "confidence": 0.97 },
{ "word": "落地", "start": 3.8, "end": 4.3, "confidence": 0.96 },
{ "word": "呢", "start": 4.5, "end": 4.7, "confidence": 0.99 }
]
},
{
"speaker_id": 0, "start": 5.8, "end": 8.2,
"text": "我们可以先做个小范围试点。", "confidence": 0.94,
"words": [
{ "word": "我们", "start": 5.8, "end": 6.1, "confidence": 0.96 },
{ "word": "可以", "start": 6.1, "end": 6.5, "confidence": 0.95 },
{ "word": "先做", "start": 6.5, "end": 6.9, "confidence": 0.94 },
{ "word": "个", "start": 6.9, "end": 7.1, "confidence": 0.98 },
{ "word": "小范围", "start": 7.1, "end": 7.5, "confidence": 0.92 },
{ "word": "试点", "start": 7.5, "end": 7.9, "confidence": 0.93 }
]
}
],
"words": [
{ "word": "我", "speaker_id": 0, "start": 0.0, "end": 0.3, "confidence": 0.98 },
{ "word": "觉得", "speaker_id": 0, "start": 0.3, "end": 0.7, "confidence": 0.97 }
],
"processing_time_ms": 850
}
示例 4:关键词识别结果 Example 4: Keyword Spotting Result
{
"text": "我们的人工智能项目需要引入大语言模型和强化学习来提升效果。",
"lang": "zh",
"duration_seconds": 6.8,
"overall_confidence": 0.96,
"keywords_matched": [
{ "keyword": "人工智能", "start": 0.5, "end": 1.0, "confidence": 0.98 },
{ "keyword": "大语言模型", "start": 2.8, "end": 3.5, "confidence": 0.97 },
{ "keyword": "强化学习", "start": 3.8, "end": 4.3, "confidence": 0.96 }
],
"processing_time_ms": 380
}
错误码 Error Codes
状态码 Status 错误码 Code 说明 Description
400 INVALID_AUDIO_FORMAT 音频格式不支持或文件已损坏 Unsupported or corrupted audio format
400 AUDIO_TOO_LARGE 音频超过 100MB 限制 Audio exceeds 100MB limit
400 AUDIO_TOO_LONG 音频时长超过当前格式的最大限制 Audio duration exceeds the format's maximum limit
400 NO_SPEECH_DETECTED 音频中未检测到有效语音,可能为静音或纯噪音 No valid speech detected; may be silence or pure noise
400 INVALID_LANGUAGE 不支持的语言代码 Unsupported language code
400 INVALID_AUDIO_URL 音频 URL 无效、无法访问或超时 Invalid, inaccessible or timed-out audio URL
401 UNAUTHORIZED 缺少或无效的 Access Token Missing or invalid access token
403 FORBIDDEN 无权访问该资源或配额已耗尽 Access denied or quota exceeded
413 PAYLOAD_TOO_LARGE 请求体超过服务器限制 Request body too large
415 UNSUPPORTED_MEDIA_TYPE Content-Type 不正确或媒体类型不支持 Incorrect or unsupported Content-Type
422 LOW_CONFIDENCE 识别置信度过低,可能因背景噪音过大或语言不匹配 Confidence too low; possible excessive background noise or language mismatch
429 RATE_LIMITED 请求频率超限,请降低并发数 Rate limit exceeded; reduce concurrency
500 INTERNAL_ERROR 服务器内部错误,请稍后重试 Internal server error; try again later
503 SERVICE_UNAVAILABLE 服务暂时不可用,请稍后重试 Service temporarily unavailable
最佳实践 Best Practices
音频质量第一 :清晰、无噪音的音频可获得最高的识别准确率。建议录音时使用外置麦克风,保持距离适中,背景安静。
Audio Quality First : Clear, noise-free audio yields the highest accuracy. Use an external mic, maintain proper distance, and keep the environment quiet.
指定语言代码 :尽量显式指定 lang 而非依赖 auto,既提高准确率又减少处理时间。
Specify Language : Explicitly set lang rather than relying on auto to improve accuracy and reduce processing time.
选对声学模型 :电话录音用 phone_call 模型,会议/演讲用 default,远场/视频用 video,医疗场景用 medical。
Choose the Right Model : Use phone_call for telephony, default for meetings/speeches, video for far-field, medical for healthcare.
长音频异步处理 :超过 10 分钟的音频建议使用 callback_url 异步模式,避免请求超时。回调结果格式与同步响应一致。
Async for Long Audio : Use callback_url async mode for audio over 10 minutes to avoid timeouts. Callback format matches sync response.
说话人分离的技巧 :如果已知会议参与人数,通过 speaker_count 指定可显著提升分离精度。两人对话设为 2,小组讨论设为 4–5。
Diarization Tips : Specify speaker_count when the number of participants is known; set 2 for dialogue, 4–5 for group discussions.
关键词提升 :对领域专有名词(产品名、人名、专业术语),通过 enable_keywords 传入可减少同音误识。
Keyword Boosting : Pass domain-specific terms (product names, person names, jargon) via enable_keywords to reduce homophone errors.
错误重试 :对于 429(频率限制)和 5xx(服务器错误),建议实现指数退避重试策略。
Retry Strategy : Implement exponential backoff for 429 (rate limit) and 5xx (server errors).
常见应用场景 Common Use Cases
场景 Scenario 推荐参数组合 Recommended Parameters
会议纪要自动生成 Meeting Minutes enable_diarization=true, speaker_count=N, enable_timestamps=true, enable_itn=true
呼叫中心质检 Call Center QA model=phone_call, enable_diarization=true, enable_profanity_filter=true
视频字幕生成 Video Subtitles model=video, enable_timestamps=true, enable_punctuation=true
直播实时转写 Live Transcription enable_partial_results=true, model=video
医疗语音病历 Medical Dictation model=medical, enable_itn=true, enable_keywords=["诊断","用药","处方"]
访谈/调研整理 Interview Transcription enable_diarization=true, enable_timestamps=true, enable_punctuation=true
语音搜索/语音助手 Voice Search/Assistant enable_itn=true, enable_punctuation=false
语言支持概览 Language Support Overview
语言 Language 代码 Code 标点 Punctuation ITN 说话人分离 Diarization
中文(普通话) Chinese (Mandarin) zh ✅ ✅ ✅
英语 English en ✅ ✅ ✅
日语 Japanese ja ✅ ✅ ✅
韩语 Korean ko ✅ ✅ ✅
德语 German de ✅ ✅ ✅
法语 French fr ✅ ✅ ✅
西班牙语 Spanish es ✅ ✅ ✅
葡萄牙语 Portuguese pt ✅ — ✅
意大利语 Italian it ✅ — ✅
俄语 Russian ru ✅ — ✅
阿拉伯语 Arabic ar ✅ — —
印地语 Hindi hi — — —
注:完整 100+ 语言列表请参见 Note: For the complete 100+ language list, see 语种列表 Language List 。
使用说明
Notes
文件上传使用 multipart/form-data 编码,Content-Type 请勿手动设置,让 HTTP 客户端自动生成。
Use multipart/form-data encoding; let the HTTP client auto-generate Content-Type.
Base64 编码后字符串会比原文件大约 33%,注意请求体大小限制。
Base64 encoding increases size by ~33%; mind the request body size limit.
长音频(>10 分钟)建议使用 callback_url 异步模式,避免请求超时。单次同步请求超时时间为 60 秒。
For long audio (>10 min), use callback_url async mode to avoid timeouts. Sync request timeout is 60 seconds.
请勿在客户端代码中暴露 Access Token,建议通过后端代理调用。
Do not expose your Access Token in client-side code; use a backend proxy.
如需将识别结果翻译为其他语言,请将 text 传入文本翻译 API ,或直接使用语音翻译 API 一步完成。
To translate recognition results, pass text to Text Translation API , or use Speech Translation API for one-step solution.