> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vidgo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 替换片段

> 替换已生成音乐曲目中的指定片段

> [!TIP]
>
> 1. 提交后会返回 `task_id`。如果提供了 `callback_url`，当任务状态变为 `finished` 或 `failed` 时，系统会向 `callback_url` 发送 POST 请求。
> 2. 无论是否提供 `callback_url`，都可以通过统一的[查询音乐详情](https://docs.vidgo.ai/zh/api-manual/music-series/query-music-detail.md)接口获取结果。

## 使用指南

* 此接口用新内容替换现有音乐曲目中的指定时间段
* 适合编辑主歌、副歌或已生成曲目的任意部分
* 替换内容根据你的提示词和风格标签生成

## 参数详情

* `task_id`（必填）：已完成音乐生成的原始任务 ID
* `audio_id`（必填）：回调数据中具体音轨的标识符
* `prompt`（必填）：替换内容的描述（歌词或音乐描述）
* `tags`（必填）：替换片段的风格标签
* `title`（必填）：生成曲目的标题
* `infill_start_s`（必填）：开始时间（秒，最小 0，最多 2 位小数）
* `infill_end_s`（必填）：结束时间（秒，必须大于开始时间）

## 使用说明

* 确保 `infill_end_s` 始终大于 `infill_start_s`
* 时间范围应在原曲时长之内
* 希望整首曲目的歌词保持一致时，使用 `full_lyrics`

## 可选参数

* `negative_tags` (string)：替换片段中要排除的风格
* `full_lyrics` (string)：修改后整首曲目的完整歌词
* `callback_url` (string)：用于接收完成通知的 Webhook URL


## OpenAPI

````yaml zh/api-manual/music-series/replace-section.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Vidgo API - Replace Section API
  description: 替换已生成音乐音轨的指定片段
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - Music Editing
      summary: 提交替换片段任务
      description: 用新内容替换现有音乐音轨中的指定时间段
      operationId: submitReplaceSectionTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              replace-chorus:
                summary: 替换副歌片段
                value:
                  model: replace-section
                  callback_url: https://your-domain.com/callback
                  input:
                    task_id: 5c79xxxxbe8e
                    audio_id: e231xxxx-xxxx-xxxx-xxxx-xxxx8cadc7dc
                    prompt: A powerful chorus with soaring vocals
                    tags: pop, upbeat
                    title: 夏日之梦
                    infill_start_s: 30
                    infill_end_s: 60
                    full_lyrics: >-
                      Complete song lyrics including the new chorus and all
                      unchanged sections
              replace-with-lyrics:
                summary: 使用完整歌词替换片段
                value:
                  model: replace-section
                  callback_url: https://your-domain.com/callback
                  input:
                    task_id: 5c79xxxxbe8e
                    audio_id: e231xxxx-xxxx-xxxx-xxxx-xxxx8cadc7dc
                    prompt: New verse lyrics here
                    tags: jazz, smooth
                    title: 午夜蓝调
                    infill_start_s: 15.5
                    infill_end_s: 45
                    negative_tags: rock, heavy
                    full_lyrics: >-
                      Complete song lyrics including modified and unmodified
                      sections
      responses:
        '200':
          description: 任务提交成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          example: replace-section
        callback_url:
          type: string
          format: uri
          description: 接收结果通知的 Webhook 回调 URL
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - task_id
            - audio_id
            - prompt
            - tags
            - title
            - infill_start_s
            - infill_end_s
            - full_lyrics
          description: 片段替换的输入参数
          properties:
            task_id:
              type: string
              description: |-
                原始任务 ID（父任务）。

                用于识别要替换片段的源音乐。
              example: 5c79xxxxbe8e
            audio_id:
              type: string
              description: |-
                要替换的音轨唯一标识符。

                音乐生成完成后，此 ID 会在回调数据中返回。
              example: e231xxxx-xxxx-xxxx-xxxx-xxxx8cadc7dc
            prompt:
              type: string
              description: |-
                描述替换音频内容的文本。

                描述你希望替换片段中包含的歌词、旋律或音乐内容。
              example: A powerful chorus with soaring vocals
            tags:
              type: string
              description: |-
                音乐风格标签。

                指定替换片段的流派、情绪或风格（例如 jazz、electronic、upbeat）。
              example: pop, upbeat
            title:
              type: string
              description: |-
                音乐标题。

                生成音轨的标题。
              example: Summer Dreams
            infill_start_s:
              type: number
              description: |-
                开始时间（秒）。

                要替换片段的起点，最多支持 2 位小数。

                最小值：0
              minimum: 0
              example: 30
            infill_end_s:
              type: number
              description: |-
                结束时间（秒）。

                要替换片段的终点，最多支持 2 位小数。

                必须大于 `infill_start_s`。
              example: 60
            negative_tags:
              type: string
              description: |-
                替换时要排除的风格。

                指定生成片段中要避免的流派或特征。
              example: rock, heavy metal
            full_lyrics:
              type: string
              description: |-
                修改后的完整歌词。

                包含整首音轨中已修改和未修改的歌词。
              example: Complete song lyrics including all sections
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
          description: HTTP 状态码
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-unified-1757165031-uyujaw3d
              description: 任务唯一标识，用于查询任务状态
            status:
              type: string
              enum:
                - not_started
              example: not_started
              description: 初始任务状态
            created_time:
              type: string
              format: date-time
              example: '2025-11-12T10:30:00'
              description: 任务创建时间，ISO 8601 格式
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        所有 API 接口都需要 Bearer Token 认证


        获取 API Key：


        进入 **仪表盘 → API 密钥**（[API Key
        管理页面](https://vidgo.ai/apis/dashboard/api-key)）获取你的 API Key


        在请求头中添加：


        ```

        Authorization: Bearer VIDGO_API_KEY

        ```

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.