跳到主要内容

创建转写

POST 

https://api.knoxstudio.ai/v1/speech-to-text

批量转写。model_id 必填。必须且只能提供 file 或 source_url(cloud_storage_url 已弃用)。文件最大 5GB,音频至少 100ms。默认模型 scribe_v2,$0.27/小时。指南:语音转文本。

请求​

查询参数​

名称类型必填描述
enable_loggingBoolean否默认 true。

请求头​

名称类型必填描述
AuthorizationString是Bearer <token> Knox API key。也接受 xi-api-key。
Content-TypeString是multipart/form-data(上传文件)或 application/json(仅 URL)。

请求体​

名称类型必填描述
model_idString是scribe_v2 或 scribe_v2_realtime。
fileFile条件音频/视频文件。必须且只能与 source_url 二选一。
source_urlString条件HTTPS 音频/视频 URL(YouTube/TikTok 及托管文件)。
cloud_storage_urlString否已弃用;请使用 source_url。
language_codeString否ISO-639-1 或 ISO-639-3。省略则自动检测。
tag_audio_eventsBoolean否标记笑声等事件。
num_speakersInteger否最多预测 32 位说话人。
timestamps_granularityString否none、word 或 character。
diarizeBoolean否标注谁在说话。
diarization_thresholdNumber否仅在 diarize=true 且未设 num_speakers 时。
file_formatString否pcm_s16le_16 或 other。
webhookBoolean否提前返回,稍后通过 webhook 投递。
webhook_idString否webhook=true 时指定 webhook。
webhook_metadataObject or String否包含在 webhook 负载中(最大 16KB,深度 2)。
temperatureNumber否0.0–2.0。
seedInteger否0–2147483647。
use_multi_channelBoolean否按声道转写(最多 5)。每个声道按完整时长计费。
multichannel_output_styleString否separate(默认)或 combined。
entity_detectionString or List否all、类别(pii、phi、pci、other、offensive_language)或类型。+$0.12/小时。
entity_redactionString or List否entity_detection 的子集。
entity_redaction_modeString否redacted、entity_type、enumerated_entity_type。
no_verbatimBoolean否去掉语气词/口误。仅 scribe_v2。
use_speaker_libraryBoolean否diarize=true 时匹配已知说话人。
detect_speaker_rolesBoolean否需要 diarize=true。+10% 附加费。不能与多声道同时使用。
keytermsList of Strings否最多 1000 个,每个 50 字符、5 个词。+$0.10/小时。超过 100 个时最低 20 秒计费。
additional_formatsList of Objects否额外导出格式。

cURL 示例​

curl -X POST https://api.knoxstudio.ai/v1/speech-to-text \
-H "Authorization: Bearer $KNOXCHAT_API_KEY" \
-F "model_id=scribe_v2" \
-F "file=@interview.mp3" \
-F "diarize=true" \
-F "timestamps_granularity=word"

响应​

成功响应 (200)​

同步结果:

名称类型描述
textstring转写文本。
language_codestring检测到的语言(例如 eng)。
language_probabilitynumber0–1。
wordsarraytext、type(word / spacing / audio_event)、logprob、start、end,以及可选 speaker_id、characters、channel_index。
transcription_idstring用于获取/删除转写。
audio_duration_secsnumber计费时长。
entitiesarray开启实体检测时:text、entity_type、start_char、end_char。
transcriptsarray多声道 separate 样式。

webhook=true 时请求会提前返回,不含 text。

错误响应​

校验失败返回 HTTP 422:

{
"detail": [
{
"loc": ["body", "field"],
"msg": "…",
"type": "value_error"
}
]
}

其他错误使用 { "detail": "message" }。

状态何时
400未携带 Upgrade: websocket 访问 WebSocket 路径。
401缺少或无效的 API key。
402余额不足。
403Token 无权使用该模型。
404资源不存在。
422校验错误。
429超出速率限制。
500服务器内部错误。