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

# Suno Timing API 對接說明

> Suno Music Generation 集成指南 - XHuoAPI

SUNO 允許我們對生成的音樂進行二次創作，獲取音樂的歌詞、音頻時間線，本文檔講解相關 API 的對接方法。

該 API 只有一個輸入參數，就是 `audio_id`，它是官方生成的歌曲ID。

這裡我們輸入的 `audio_id` 是 `ec13e502-d043-4eb2-92ee-e900c6da69d1`。

```python theme={null}
import requests

url = "https://api.xhuoapi.ai/v1/suno/timing"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "audio_id": "ec13e502-d043-4eb2-92ee-e900c6da69d1"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

結果節選如下：

```
{
  "success": true,
  "task_id": "ccf72cca-1c82-4580-8575-bb141c7e8e48",
  "trace_id": "d8e0b7c3-6d24-4ed9-98ac-ffe683576a75",
  "data": {
    "aligned_words": [
      {
        "word": "[Verse]\nSnowflakes ",
        "success": true,
        "start_s": 2.63,
        "end_s": 3.43,
        "p_align": 0.531
      },
      {
        "word": "dance ",
        "success": true,
        "start_s": 3.43,
        "end_s": 3.91,
        "p_align": 0.911
      },
      {
        "word": "on ",
        "success": true,
        "start_s": 3.91,
        "end_s": 4.35,
        "p_align": 0.937
      },
      {
        "word": "rooftops ",
        "success": true,
        "start_s": 4.35,
        "end_s": 5.11,
        "p_align": 0.366
      },
      {
        "word": "high\n",
        "success": true,
        "start_s": 5.11,
        "end_s": 6.25,
        "p_align": 0.969
      },
      ...
    ],
    "waveform_data": [0.02138, 0.02193, 0.01806, 0.16597, 0.15168, 0.14243, ...],
    "hoot_cer": 0.35013262599469497,
    "is_streamed": false
  }
}
```

### aligned\_words 欄位說明

可以看到，`data.aligned_words` 是物件陣列，每個物件代表一個帶有時間資訊的詞或短語。

* `word`: 歌詞中的實際詞或短語
* `success`: 布林值，表示此詞的對齊是否成功
* `start_s`: 詞的開始時間
* `end_s`: 詞的結束時間
* `p_align`: 對齊的機率或置信度分數，範圍為 0 到 1
