diff --git a/wwwroot/api_doc.md b/wwwroot/api_doc.md index e2cbcc4..ad4bc5f 100644 --- a/wwwroot/api_doc.md +++ b/wwwroot/api_doc.md @@ -1782,242 +1782,431 @@ curl -X POST 'https://token.opencomputing.cn/reallife_asset/api/rl_virtual_asset | `上传失败` | 素材上传失败 | 检查 URL 是否可访问 | | `查询失败` | 查询操作失败 | 检查 ID 是否属于当前机构 | -# 视频制作 API +# KTV Pipeline API(视频制作) Base url: `https://token.opencomputing.cn/llmage/v1` -视频制作服务组由开元云(北京)科技有限公司提供,覆盖KTV产线全流程:校准、合成、评估、分离、识别等28个API端点。基础模型使用向量模型和GPU集群进行计算处理。 +KTV产线GPU服务由开元云(北京)科技有限公司提供,覆盖14个原子化GPU端点:语音识别、音频分离、人脸检测/识别/比对、字幕渲染、视频合并、歌曲评分、音乐合成、超分辨率、声音转换、视频评估。 -## 模型列表 +## 调用方式 -| model | 类型 | 功能 | 计费方式 | -|-------|------|------|----------| -| `ktv-media-server` | KTV产线 | 流水线提交 | 2.00元/次 + 0.03元/秒 | -| `ktv-video-eval` | 视频评估 | 质量评估打分 | 0.05元/秒 | -| `ktv-realesrgan` | 超分辨率 | 图像/视频超分 | 0.50元/张 | -| `ktv-asr` | 语音识别 | 语音转文字 | 0.01元/秒 | -| `ktv-face` | 人脸识别 | 检测/识别/比对 | 0.10元/次 | -| `ktv-graph` | 图谱处理 | 知识图谱查询/写入 | 0.05~0.10元/次 | -| `ktv-ner` | 实体识别 | 命名实体提取 | 0.50元/千字 | -| `ktv-songrate` | 歌曲评分 | AI歌曲质量评估 | 0.005元/秒 | -| `ktv-synth` | 音乐合成 | AI歌声合成 | 0.20元/秒 | -| `ktv-demucs` | 音频分离 | 人声/伴奏分离 | 0.02元/秒 | -| `ktv-rvc` | 声音转换 | 声音克隆/变声 | 0.15元/秒 | +所有 KTV Pipeline 服务通过 `/v1/pipeline/submit` 调用,`catelogid` 固定为 `ktv_pipeline`(无需传)。 -## 通用调用方式 +``` +POST /v1/pipeline/submit +``` -所有视频制作模型通过 `/v1/chat/completions` 调用,模型名为上表中的 `model` 值。 - -### 请求格式 +### 通用请求格式 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| -| `model` | string | 是 | 模型名,如 `"ktv-media-server"` | -| `catelogid` | string | 否 | 类目ID,默认根据模型自动选择 | -| 业务参数 | - | 视端点 | 各端点特定参数,见下方 | +| `model` | string | 是 | 模型名,见下方模型列表 | +| 业务参数 | - | 见各端点 | 各端点特定参数 | -### KTV产线操作 (media-server) +### 通用响应格式 -**提交流水线任务** — model: `ktv-media-server` - -| 参数 | 类型 | 说明 | -|------|------|------| -| `task_type` | string | 任务类型 | -| `params` | object | 任务参数 | -| `video_url` | string | 视频URL | -| `audio_url` | string | 音频URL | -| `song_name` | string | 歌曲名 | -| `lyrics` | string | 歌词文本 | -| `gpu_id` | int | GPU编号 | -| `duration` | int | 锁定时间(秒) | - -```bash -# 提交KTV视频生成 -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ - -H 'Authorization: Bearer ***' \ - -H 'Content-Type: application/json' \ - -d '{"model":"ktv-media-server","task_type":"ktv","params":{"song_name":"测试","lyrics":"歌词内容"}}' -``` - -**响应:** +**同步服务(直接返回结果):** ```json { - "id": "luid_xxx", - "object": "chat.completion", - "model": "ktv-media-server", - "choices": [{ - "message": { - "status": "ok", - "video_url": "https://...", - "usage": {"output_seconds": 180} - } - }] + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "usage": {"...": N} } ``` -### 视频评估 (video-eval) +**异步服务(提交后轮询):** -**评估视频质量** — model: `ktv-video-eval` +```json +{ + "taskid": "luid_xxx", + "taskstatus": "PENDING" +} +``` + +异步任务通过 `GET /v1/tasks?taskid=xxx` 查询状态。 + +--- + +## 模型列表 + +| model | 类型 | 功能 | 模式 | 计费 | +|-------|------|------|------|------| +| `ky-asr-transcribe` | 语音 | 语音转文字+时间戳 | 同步 | 0.01元/次 | +| `ky-demucs-separate` | 音频 | 人声/伴奏分离 | 同步 | 0.01元/次 | +| `ky-face-detect` | 视觉 | 人脸检测 | 同步 | 0.01元/次 | +| `ky-face-recognize` | 视觉 | 人脸识别 | 同步 | 0.01元/次 | +| `ky-face-compare` | 视觉 | 人脸比对 | 同步 | 0.01元/次 | +| `ky-subtitle-render` | 视频 | 歌词→ASS字幕渲染 | 同步 | 0.01元/次 | +| `ky-merge-video` | 视频 | 视频+音频+字幕合并 | 同步 | 0.01元/次 | +| `ky-songrate-evaluate` | 音频 | AI歌曲质量评分 | 同步 | 0.01元/次 | +| `ky-synth-generate` | 音频 | AI歌声合成 | **异步** | 0.01元/次 | +| `ky-synth-status` | 音频 | 合成任务状态查询 | 同步 | 0.01元/次 | +| `ky-realesrgan-upscale` | 视觉 | 图像/视频超分辨率 | **异步** | 0.01元/次 | +| `ky-realesrgan-status` | 视觉 | 超分任务状态查询 | 同步 | 0.01元/次 | +| `ky-rvc-convert` | 音频 | 声音克隆/变声 | 同步 | 0.01元/次 | +| `ky-video-eval-evaluate` | 视频 | 视频质量评估 | 同步 | 0.01元/次 | + +--- + +## 各端点详细说明 + +### 1. 语音识别 — ky-asr-transcribe + +上传音频文件,返回识别文本和逐句时间戳。 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| -| `video_url` | string | 是 | 待评估视频URL | +| `audio_url` | string | 是 | 音频文件URL(支持 http/https) | +| `language` | string | 否 | 语言代码,默认 `zh` | ```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ -H 'Authorization: Bearer ***' \ -H 'Content-Type: application/json' \ - -d '{"model":"ktv-video-eval","video_url":"https://example.com/video.mp4"}' + -d '{"model":"ky-asr-transcribe","audio_url":"https://example.com/audio.mp3","language":"zh"}' ``` -**响应:** `{"status":"ok","score":85,"details":{...},"usage":{"video_seconds":60}}` +**响应:** -### 超分辨率 (realesrgan) - -**图像/视频超分** — model: `ktv-realesrgan` - -| 参数 | 类型 | 必填 | 说明 | -|------|------|------|------| -| `image_url` | string | 是 | 待处理图像URL | -| `scale` | int | 否 | 放大倍数(默认2) | - -```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ - -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-realesrgan","image_url":"https://example.com/img.jpg","scale":2}' +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "text": "完整识别文本", + "segments": [ + {"text": "第一句", "start": 0.0, "end": 3.5}, + {"text": "第二句", "start": 4.0, "end": 7.2} + ], + "usage": {"audio_seconds": 10.5} +} ``` -**响应:** `{"status":"ok","output_url":"https://...","usage":{"image_count":1}}` +--- -### 语音识别 (asr) +### 2. 音频分离 — ky-demucs-separate -**语音转文字** — model: `ktv-asr` +分离音频中的人声和伴奏。 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | `audio_url` | string | 是 | 音频文件URL | -| `language` | string | 否 | 语言代码(默认zh) | ```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-asr","audio_url":"https://example.com/audio.mp3"}' + -H 'Content-Type: application/json' \ + -d '{"model":"ky-demucs-separate","audio_url":"https://example.com/music.mp3"}' ``` -**响应:** `{"status":"ok","text":"识别结果文本","segments":[...],"usage":{"audio_seconds":120}}` +**响应:** -### 人脸识别 (face) - -**人脸检测/识别/比对** — model: `ktv-face` - -| 参数 | 类型 | 说明 | -|------|------|------| -| `image_url` | string | 检测图像URL | -| `face_id` | string | 人脸ID(识别时) | -| `image_url1` | string | 图像1(比对时) | -| `image_url2` | string | 图像2(比对时) | - -```bash -# 人脸检测 -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ - -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-face","image_url":"https://example.com/face.jpg"}' +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "vocals_url": "https://token.opencomputing.cn/.../vocals.wav", + "accompaniment_url": "https://token.opencomputing.cn/.../accompaniment.wav", + "usage": {"audio_seconds": 240.0} +} ``` -**响应:** `{"status":"ok","faces":[...],"usage":{"detect_count":1}}` +--- -### 图谱处理 (graph) +### 3. 人脸检测 — ky-face-detect -**知识图谱查询与写入** — model: `ktv-graph` - -| 参数 | 类型 | 说明 | -|------|------|------| -| `node_id` | string | 节点ID | -| `attrs` | object | 节点属性 | -| `from` | string | 起始节点(加边) | -| `to` | string | 目标节点(加边) | -| `label` | string | 边标签 | - -```bash -# 查询邻居 -curl 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ - -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-graph","node_id":"node_001"}' -``` - -**响应:** `{"status":"ok","nodes":[...],"usage":{"query_count":1}}` - -### 实体识别 (ner) - -**命名实体提取** — model: `ktv-ner` +检测图像中的人脸位置。 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| -| `text` | string | 是 | 待分析文本 | +| `image_url` | string | 是 | 图像URL | ```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-ner","text":"张三在北京工作"}' + -H 'Content-Type: application/json' \ + -d '{"model":"ky-face-detect","image_url":"https://example.com/photo.jpg"}' ``` -**响应:** `{"status":"ok","entities":[...],"usage":{"char_count":7}}` +**响应:** -### 歌曲评分 (songrate) +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "faces": [ + {"x": 100, "y": 150, "w": 80, "h": 100, "confidence": 0.98} + ], + "usage": {"detect_count": 1} +} +``` -**AI歌曲质量评估** — model: `ktv-songrate` +--- + +### 4. 人脸识别 — ky-face-recognize + +识别图像中人脸的身份。 + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| `image_url` | string | 是 | 图像URL | +| `face_id` | string | 否 | 指定识别目标ID | + +```bash +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ + -H 'Authorization: Bearer ***' \ + -H 'Content-Type: application/json' \ + -d '{"model":"ky-face-recognize","image_url":"https://example.com/face.jpg"}' +``` + +**响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "matches": [ + {"face_id": "person_001", "confidence": 0.95, "name": "张三"} + ], + "usage": {"recognize_count": 1} +} +``` + +--- + +### 5. 人脸比对 — ky-face-compare + +比较两张人脸的相似度。 + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| `image_url1` | string | 是 | 第一张图像URL | +| `image_url2` | string | 是 | 第二张图像URL | + +```bash +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ + -H 'Authorization: Bearer ***' \ + -H 'Content-Type: application/json' \ + -d '{"model":"ky-face-compare","image_url1":"https://example.com/face1.jpg","image_url2":"https://example.com/face2.jpg"}' +``` + +**响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "similarity": 0.92, + "usage": {"compare_count": 1} +} +``` + +--- + +### 6. 字幕渲染 — ky-subtitle-render + +将歌词时间轴数据渲染为ASS格式字幕文件。 + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| `lyrics_json` | string | 是 | 歌词时间轴JSON字符串 | +| `width` | integer | 否 | 视频宽度,默认 1920 | +| `height` | integer | 否 | 视频高度,默认 1080 | + +```bash +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ + -H 'Authorization: Bearer ***' \ + -H 'Content-Type: application/json' \ + -d '{"model":"ky-subtitle-render","lyrics_json":"[{\"text\":\"第一句歌词\",\"start\":0,\"end\":3.5}]","width":1920,"height":1080}' +``` + +**响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "ass_url": "https://token.opencomputing.cn/.../karaoke.ass", + "usage": {"subtitle_count": 42} +} +``` + +--- + +### 7. 视频合并 — ky-merge-video + +合并视频、音频和字幕为最终成品。 + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| `video_url` | string | 否 | 视频文件URL | +| `audio_url` | string | 否 | 音频文件URL | +| `subtitle_url` | string | 否 | ASS字幕文件URL | +| `output_format` | string | 否 | 输出格式,默认 `mp4` | + +```bash +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ + -H 'Authorization: Bearer ***' \ + -H 'Content-Type: application/json' \ + -d '{"model":"ky-merge-video","video_url":"https://example.com/video.mp4","audio_url":"https://example.com/audio.mp3","subtitle_url":"https://example.com/sub.ass"}' +``` + +**响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "output_url": "https://token.opencomputing.cn/.../output.mp4", + "duration": 180.0, + "usage": {"output_seconds": 180.0} +} +``` + +--- + +### 8. 歌曲评分 — ky-songrate-evaluate + +AI评估歌曲质量,返回多维度评分。 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | `audio_url` | string | 是 | 音频文件URL | -| `scene` | string | 否 | 场景类型(pop/folk等) | +| `scene` | string | 否 | 场景类型,如 `pop`/`folk`/`rock`,默认 `pop` | ```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-songrate","audio_url":"https://example.com/song.mp3"}' + -H 'Content-Type: application/json' \ + -d '{"model":"ky-songrate-evaluate","audio_url":"https://example.com/song.mp3","scene":"pop"}' ``` -**响应:** `{"status":"ok","score":85,"details":{...},"usage":{"audio_seconds":240}}` +**响应:** -### 音乐合成 (ktv-synth) +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "score": 8.5, + "details": { + "rhythm": 8.2, + "pitch": 9.0, + "emotion": 8.3, + "technique": 8.5 + }, + "usage": {"audio_seconds": 240.0} +} +``` -**AI歌声合成** — model: `ktv-synth` +--- + +### 9. 音乐合成 — ky-synth-generate(异步) + +AI歌声合成,提交后返回任务ID,需轮询状态。 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | `lyrics` | string | 是 | 歌词文本 | -| `style` | string | 否 | 演唱风格 | -| `reference_audio` | string | 否 | 参考音频URL | +| `style` | string | 否 | 演唱风格,默认 `pop` | +| `reference_audio` | string | 否 | 参考音频URL(用于声音克隆) | ```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-synth","lyrics":"歌词内容","style":"pop"}' + -H 'Content-Type: application/json' \ + -d '{"model":"ky-synth-generate","lyrics":"春天的花开秋天的风","style":"pop"}' ``` -**响应:** `{"status":"ok","task_id":"xxx","usage":{"output_seconds":120}}` +**提交响应:** -### 音频分离 (demucs) +```json +{ + "taskid": "luid_xxx", + "taskstatus": "PENDING" +} +``` -**人声/伴奏分离** — model: `ktv-demucs` +**查询状态:** `GET /v1/tasks?taskid=luid_xxx` + +**完成响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "output_url": "https://token.opencomputing.cn/.../synth.wav", + "usage": {"audio_seconds": 180.0} +} +``` + +--- + +### 10. 合成状态查询 — ky-synth-status + +查询音乐合成任务的当前状态。 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| -| `audio_url` | string | 是 | 音频文件URL | +| `task_id` | string | 是 | 异步任务ID | ```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ +curl 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-demucs","audio_url":"https://example.com/music.mp3"}' + -H 'Content-Type: application/json' \ + -d '{"model":"ky-synth-status","task_id":"luid_xxx"}' ``` -**响应:** `{"status":"ok","vocals_url":"...","accompaniment_url":"...","usage":{"audio_seconds":200}}` +--- -### 声音转换 (rvc) +### 11. 超分辨率 — ky-realesrgan-upscale(异步) -**声音克隆/变声** — model: `ktv-rvc` +图像/视频超分辨率放大,提交后返回任务ID。 + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| `image_url` | string | 是 | 图像URL | +| `scale` | integer | 否 | 放大倍数,默认 2 | + +```bash +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ + -H 'Authorization: Bearer ***' \ + -H 'Content-Type: application/json' \ + -d '{"model":"ky-realesrgan-upscale","image_url":"https://example.com/photo.jpg","scale":4}' +``` + +**完成响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "output_url": "https://token.opencomputing.cn/.../upscaled.png", + "usage": {"image_count": 1} +} +``` + +--- + +### 12. 超分状态查询 — ky-realesrgan-status + +查询超分辨率任务的当前状态。 + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| `task_id` | string | 是 | 异步任务ID | + +```bash +curl 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ + -H 'Authorization: Bearer ***' \ + -H 'Content-Type: application/json' \ + -d '{"model":"ky-realesrgan-status","task_id":"luid_xxx"}' +``` + +--- + +### 13. 声音转换 — ky-rvc-convert + +声音克隆/变声,将输入音频转换为目标声音。 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| @@ -2025,18 +2214,74 @@ curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ | `voice_model` | string | 是 | 目标声音模型名 | ```bash -curl -X POST 'https://token.opencomputing.cn/llmage/v1/chat/completions' \ +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ -H 'Authorization: Bearer ***' \ - -d '{"model":"ktv-rvc","audio_url":"https://example.com/input.wav","voice_model":"singer_a"}' + -H 'Content-Type: application/json' \ + -d '{"model":"ky-rvc-convert","audio_url":"https://example.com/input.wav","voice_model":"singer_a"}' ``` -**响应:** `{"status":"ok","output_url":"https://...","usage":{"audio_seconds":60}}` +**响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "output_url": "https://token.opencomputing.cn/.../converted.wav", + "usage": {"audio_seconds": 60.0} +} +``` + +--- + +### 14. 视频评估 — ky-video-eval-evaluate + +评估视频质量,返回多维度评分。 + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| `video_url` | string | 是 | 视频URL | + +```bash +curl -X POST 'https://token.opencomputing.cn/llmage/v1/pipeline/submit' \ + -H 'Authorization: Bearer ***' \ + -H 'Content-Type: application/json' \ + -d '{"model":"ky-video-eval-evaluate","video_url":"https://example.com/video.mp4"}' +``` + +**响应:** + +```json +{ + "taskid": "luid_xxx", + "taskstatus": "SUCCEEDED", + "score": 85.0, + "details": { + "sharpness": 90, + "color": 82, + "stability": 88, + "composition": 80 + }, + "usage": {"video_seconds": 60.0} +} +``` + +--- + +## 模型发现 + +列出所有 KTV Pipeline 可用模型: + +```bash +curl 'https://token.opencomputing.cn/llmage/v1/models?catelogid=ktv_pipeline' \ + -H 'Authorization: Bearer ***' +``` ## 错误说明 | 错误信息 | 原因 | 解决方案 | |----------|------|----------| -| `missing prompt parameter` | 缺少必填参数 | 检查请求 body | +| `Model "xxx" not found` | 模型名不存在或未发布 | 检查 model 值,或用 /v1/models 查询 | +| `Missing required parameter` | 缺少必填参数 | 参考上方各端点参数表 | | `余额不足` | 账户余额低于模型最低余额要求 | 充值 | | `模型未配置定价` | 模型缺少 ppid 配置 | 联系管理员 | | `gpu not available` | GPU资源不足 | 稍后重试