> ## Documentation Index
> Fetch the complete documentation index at: https://docs.poyo.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.poyo.ai/zh/api-manual/music-series/query-music-detail.md)接口获取结果。

## 使用指南

* 此接口获取已生成音轨的同步歌词及其精确时间戳
* 可用于制作卡拉 OK 式显示、字幕或歌词可视化
* 需要一个已完成且包含人声的音乐生成任务

## 参数详情

* 必填参数：

  * `task_id`：先前音乐生成任务的唯一标识

  * `audio_id`：任务结果中具体音轨的标识

* 这两个标识都可以从音乐生成接口的响应或其回调中获得

## 开发者说明

* 此接口仅适用于包含人声的音轨
* `hoot_cer`（字符错误率）值表示对齐精度，值越低表示越准确
* 使用 `waveform_data` 可在歌词旁制作音频可视化效果

## 响应字段

* `aligned_words` (array)：带时间信息的歌词单词列表
  * `word` (string)：歌词文本，可能包含 `[Verse]`、`[Chorus]` 等段落标记
  * `start_s` (number)：单词开始时间（秒）
  * `end_s` (number)：单词结束时间（秒）
  * `success` (boolean)：该单词是否对齐成功
  * `palign` (number)：对齐置信度分数

* `waveform_data` (array)：用于音频波形可视化的数值数据

* `hoot_cer` (number)：对齐精度分数（字符错误率）

* `is_streamed` (boolean)：表示该音频是否为流式音轨


## OpenAPI

````yaml zh/api-manual/music-series/get-timestamped-lyrics.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: PoYo AI - 获取带时间戳歌词 API
  description: 获取带精确时间戳的同步歌词
  version: 1.0.0
servers:
  - url: https://api.poyo.ai
    description: 生产环境
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - Music Generation
      summary: 提交获取带时间戳歌词任务
      description: 获取已生成音轨的带精确时间戳的同步歌词
      operationId: submitGetTimestampedLyricsTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              basic:
                summary: 获取带时间戳的歌词
                value:
                  model: get-timestamped-lyrics
                  callback_url: https://your-domain.com/callback
                  input:
                    task_id: task-unified-1757165031-uyujaw3d
                    audio_id: e231xxxx-xxxx-xxxx-xxxx-xxxx8cadc7dc
      responses:
        '200':
          description: 成功获取带时间戳的歌词
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LyricsResponse'
        '404':
          description: 资源不存在
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: 404
                error:
                  message: Task or audio not found
                  type: not_found_error
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: |-
            API 模型标识符。

            此接口必须为 `get-timestamped-lyrics`。
          enum:
            - get-timestamped-lyrics
          example: get-timestamped-lyrics
        callback_url:
          type: string
          format: uri
          description: 接收结果通知的 Webhook 回调 URL
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - task_id
            - audio_id
          description: 获取带时间戳歌词的输入参数
          properties:
            task_id:
              type: string
              description: |-
                音乐生成任务的唯一标识符。

                从之前音乐生成请求的响应中获取。
              example: task-unified-1757165031-uyujaw3d
            audio_id:
              type: string
              description: |-
                具体音轨的唯一标识符。

                从任务结果或回调响应中获取。
              example: e231xxxx-xxxx-xxxx-xxxx-xxxx8cadc7dc
    LyricsResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
          description: >-
            业务状态码。`200` 表示成功，其他值都表示请求失败。请务必检查这个字段：部分参数校验错误会以 HTTP 200 返回，响应体里的
            `code` 为 `400`。


            - `200`：成功

            - `400`：请求参数无效

            - `401`：API Key 缺失或无效

            - `402`：积分不足

            - `403`：没有权限

            - `404`：资源不存在

            - `408`：请求超时

            - `429`：请求频率超限

            - `500`：服务器内部错误

            - `502`：上游服务错误

            - `503`：服务暂不可用


            详见[错误码](/zh/api-manual/error-codes)。
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
        data:
          type: object
          properties:
            aligned_words:
              type: array
              description: 已对齐的歌词词语列表，含时间信息
              items:
                type: object
                properties:
                  word:
                    type: string
                    description: 歌词文本（可能包含 [Verse] 等段落标记）
                    example: '[Verse] Waggin'''
                  success:
                    type: boolean
                    description: 该词是否成功对齐
                    example: true
                  start_s:
                    type: number
                    description: 该词的开始时间（秒）
                    example: 1.36
                  end_s:
                    type: number
                    description: 该词的结束时间（秒）
                    example: 1.79
                  palign:
                    type: number
                    description: 对齐置信度分数
                    example: 0
            waveform_data:
              type: array
              description: 用于音频可视化的波形数据
              items:
                type: number
              example:
                - 0
                - 1
                - 0.5
                - 0.75
            hoot_cer:
              type: number
              description: |-
                歌词对齐精度分数（字符错误率）。

                值越低表示对齐越准确。
              example: 0.38
            is_streamed:
              type: boolean
              description: 表示是否为流式音轨
              example: false
    ErrorResponse:
      type: object
      required:
        - code
        - error
      properties:
        code:
          type: integer
          example: 400
          description: >-
            业务状态码。`200` 表示成功，其他值都表示请求失败。请务必检查这个字段：部分参数校验错误会以 HTTP 200 返回，响应体里的
            `code` 为 `400`。


            - `200`：成功

            - `400`：请求参数无效

            - `401`：API Key 缺失或无效

            - `402`：积分不足

            - `403`：没有权限

            - `404`：资源不存在

            - `408`：请求超时

            - `429`：请求频率超限

            - `500`：服务器内部错误

            - `502`：上游服务错误

            - `503`：服务暂不可用


            详见[错误码](/zh/api-manual/error-codes)。
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              example: Invalid request parameters
              description: 描述错误原因的错误信息
            type:
              type: string
              example: invalid_request_error
              description: 错误类型标识
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        所有 API 接口都需要 Bearer Token 认证。


        创建 API Key：登录 PoYo，进入 **仪表盘 → API
        密钥**（[poyo.ai/zh/dashboard/api-key](https://poyo.ai/zh/dashboard/api-key)），点击创建
        Key。


        在请求头中添加：


        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````

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