# SEE2AI 语音字幕

> Transcribe the speech in one video or audio file into timestamped subtitle segments, optionally with speaker labels and confidence, through an asynchronous submit-and-poll workflow.

## 📖 接入指引

**Endpoint**: `POST /api/v1/actions/see2ai_speech_subtitles_v1`

**认证方式**: Bearer Token (租户 API Key)

### Endpoints

| Method | Path | Purpose |
| --- | --- | --- |
| `POST` | `/api/v1/actions/see2ai_speech_subtitles_v1` | Submit the standard action request. |

> **⚠️ 重要提示**
> 
> 本 API 是 SEE2AI 平台标准化封装后的接口，**参数格式与任何上游 API 不同**。
> 请直接使用下方 Schema 中定义的参数，无需参考其他文档。
> 
> *例如：*
> *- 文本模型参数可能是 `query` 而不是 `messages` 数组*
> *- 视频模型参数可能是 `brief` (创意简报) 而不是复杂的配置项*

## 📥 输入参数 (Input Schema)

```json
{
  "additionalProperties": true,
  "description": "One subtitle transcription request.",
  "examples": [
    {
      "enable_speaker_info": true,
      "language": "cmn-Hans-CN",
      "video_url": "https://cdn.example.com/uploads/shot-1.mp4"
    }
  ],
  "properties": {
    "video_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Public HTTP(S) video URL (at most 3 hours). Provide exactly one of video_url or audio_url.",
      "title": "Video Url"
    },
    "audio_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Public HTTP(S) audio URL (at most 3 hours). Provide exactly one of video_url or audio_url.",
      "title": "Audio Url"
    },
    "language": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "cmn-Hans-CN (Simplified Chinese; alias zh-CN) or eng-US (English; alias en-US). Omit to auto-detect.",
      "title": "Language"
    },
    "content_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "speech or singing. Omit to auto-detect.",
      "title": "Content Type"
    },
    "enable_speaker_info": {
      "default": false,
      "description": "Label each segment with a speaker identifier.",
      "title": "Enable Speaker Info",
      "type": "boolean"
    },
    "enable_confidence": {
      "default": false,
      "description": "Include a 0-1 confidence score for each segment.",
      "title": "Enable Confidence",
      "type": "boolean"
    },
    "idempotency_key": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Optional caller key (1-128 printable ASCII; must match X-Idempotency-Key when both are sent) that makes resubmission safe.",
      "title": "Idempotency Key"
    }
  },
  "title": "ActionInput",
  "type": "object"
}
```

### 参数说明

| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|--------|------|------|--------|------|
| `video_url` | string / null | ❌ 否 | `-` | Public HTTP(S) video URL (at most 3 hours). Provide exactly one of video_url or audio_url. |
| `audio_url` | string / null | ❌ 否 | `-` | Public HTTP(S) audio URL (at most 3 hours). Provide exactly one of video_url or audio_url. |
| `language` | string / null | ❌ 否 | `-` | cmn-Hans-CN (Simplified Chinese; alias zh-CN) or eng-US (English; alias en-US). Omit to auto-detect. |
| `content_type` | string / null | ❌ 否 | `-` | speech or singing. Omit to auto-detect. |
| `enable_speaker_info` | boolean | ❌ 否 | `False` | Label each segment with a speaker identifier. |
| `enable_confidence` | boolean | ❌ 否 | `False` | Include a 0-1 confidence score for each segment. |
| `idempotency_key` | string / null | ❌ 否 | `-` | Optional caller key (1-128 printable ASCII; must match X-Idempotency-Key when both are sent) that makes resubmission safe. |

## 📤 输出结果 (Output Schema)

```json
{
  "$defs": {
    "SubtitleSegment": {
      "properties": {
        "subtitle_text": {
          "description": "Recognized text of this segment.",
          "title": "Subtitle Text",
          "type": "string"
        },
        "start_time": {
          "description": "Segment start in seconds.",
          "title": "Start Time",
          "type": "number"
        },
        "end_time": {
          "description": "Segment end in seconds.",
          "title": "End Time",
          "type": "number"
        },
        "speaker": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Speaker identifier when requested.",
          "title": "Speaker"
        },
        "confidence": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Confidence 0-1 when requested.",
          "title": "Confidence"
        }
      },
      "required": [
        "subtitle_text",
        "start_time",
        "end_time"
      ],
      "title": "SubtitleSegment",
      "type": "object"
    }
  },
  "properties": {
    "input_tokens": {
      "default": 0,
      "description": "输入消耗的词元数量",
      "title": "Input Tokens",
      "type": "integer"
    },
    "output_tokens": {
      "default": 0,
      "description": "输出消耗的词元数量",
      "title": "Output Tokens",
      "type": "integer"
    },
    "total_tokens": {
      "default": 0,
      "description": "总消耗的词元数量",
      "title": "Total Tokens",
      "type": "integer"
    },
    "model": {
      "default": "",
      "description": "实际使用的 SEE2AI 化身模型名称（由各 action 显式填写）",
      "title": "Model",
      "type": "string"
    },
    "source": {
      "default": "see2ai",
      "description": "服务来源（统一 `see2ai`；真实路由仅平台内部可见）",
      "title": "Source",
      "type": "string"
    },
    "cost_points": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "预先计算的扣费词元（如果插件内部已经计算好费用，则直接使用此值，忽略基于词元的计算）",
      "title": "Cost Points"
    },
    "task_id": {
      "description": "Opaque task ID used for status polling.",
      "title": "Task Id",
      "type": "string"
    },
    "status": {
      "description": "Normalized task status: running, success, or failed.",
      "enum": [
        "running",
        "success",
        "failed"
      ],
      "title": "Status",
      "type": "string"
    },
    "result_urls": {
      "description": "Durable result URLs, empty until success.",
      "items": {
        "type": "string"
      },
      "title": "Result Urls",
      "type": "array"
    },
    "estimated_cost": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Maximum platform points held until settlement.",
      "title": "Estimated Cost"
    },
    "retryable": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Whether a non-terminal status should be polled again.",
      "title": "Retryable"
    },
    "retry_after_seconds": {
      "anyOf": [
        {
          "minimum": 1,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Suggested wait before the next poll.",
      "title": "Retry After Seconds"
    },
    "error_message": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Brand-safe failure or retry guidance.",
      "title": "Error Message"
    },
    "warnings": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Non-blocking optimization suggestions produced by validation.",
      "title": "Warnings"
    },
    "subtitles": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/SubtitleSegment"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Timestamped segments, populated on success.",
      "title": "Subtitles"
    },
    "duration": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Input media duration in seconds (the billed usage).",
      "title": "Duration"
    },
    "language": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Requested language code, if any.",
      "title": "Language"
    }
  },
  "required": [
    "task_id",
    "status"
  ],
  "title": "SpeechSubtitlesStatusOutput",
  "type": "object"
}
```

### 输出字段说明

| 字段名 | 类型 | 说明 |
|--------|------|------|
| `input_tokens` | integer | 输入消耗的词元数量 |
| `output_tokens` | integer | 输出消耗的词元数量 |
| `total_tokens` | integer | 总消耗的词元数量 |
| `model` | string | 实际使用的 SEE2AI 化身模型名称（由各 action 显式填写） |
| `source` | string | 服务来源（统一 `see2ai`；真实路由仅平台内部可见） |
| `cost_points` | integer / null | 预先计算的扣费词元（如果插件内部已经计算好费用，则直接使用此值，忽略基于词元的计算） |
| `task_id` | string | Opaque task ID used for status polling. |
| `status` | string enum | Normalized task status: running, success, or failed. |
| `result_urls` | array | Durable result URLs, empty until success. |
| `estimated_cost` | integer / null | Maximum platform points held until settlement. |
| `retryable` | boolean / null | Whether a non-terminal status should be polled again. |
| `retry_after_seconds` | integer / null | Suggested wait before the next poll. |
| `error_message` | string / null | Brand-safe failure or retry guidance. |
| `warnings` | array / null | Non-blocking optimization suggestions produced by validation. |
| `subtitles` | array / null | Timestamped segments, populated on success. |
| `duration` | number / null | Input media duration in seconds (the billed usage). |
| `language` | string / null | Requested language code, if any. |

## 💡 调用示例

### cURL 示例

```bash
curl -X POST "https://see2ai.com/api/v1/actions/see2ai_speech_subtitles_v1" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer sk-your-tenant-api-key" \
     -d '{
  "enable_speaker_info": true,
  "language": "cmn-Hans-CN",
  "video_url": "https://cdn.example.com/uploads/shot-1.mp4"
}'
```

### Python 示例

```python
import requests

API_KEY = "sk-your-tenant-api-key"
ENDPOINT = "https://see2ai.com/api/v1/actions/see2ai_speech_subtitles_v1"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_KEY}"
}

payload = {
  "enable_speaker_info": true,
  "language": "cmn-Hans-CN",
  "video_url": "https://cdn.example.com/uploads/shot-1.mp4"
}

response = requests.post(ENDPOINT, json=payload, headers=headers)
result = response.json()

print(f"结果：{result}")
```

## 💰 计费说明

> CNY 0.03 per input minute, measured to the millisecond. Charged only on success; the hold is the verified length plus one second for files in SEE2AI storage, otherwise the 3-hour maximum.

**注意**: 所有费用都以词元为单位，系统会自动从租户余额中扣除。

## ⚠️ 常见错误码

| HTTP 状态码 | 错误原因 | 解决方案 |
| --- | --- | --- |
| `402` | Insufficient balance for the maximum task charge | 请稍后重试 |
| `409` | The idempotency key is bound to a different or in-flight request | 请稍后重试 |
| `422` | Invalid request, or the media service could not accept the input | 检查请求参数是否符合 Schema 要求 |
| `503` | Task submission or settlement is temporarily unavailable | 请稍后重试 |

## 📞 技术支持

- **文档问题**: 查看 [SEE2AI 官方文档](https://see2ai.com/docs)
- **API 状态**: 访问 [服务状态页面](https://see2ai.com/status)
- **问题反馈**: 联系技术支持团队

---

**API 版本**: see2ai_speech_subtitles_v1
**最后更新**: 2026-03-23
