文件

AI Music_歌聲生成(Beta-v2)

Service: https://arts.api.yating.tw/v2

你可以輸入樂譜,包含每個字的開始和結束時間以及每個字的音高後,你就可以下載完整的人聲音檔。你也可以使用「歌聲樂譜生成」API來自動產出AI編曲,取代人工定義與輸入。

為保障聲音是在合理範圍應用,每首生成出來的聲音都會壓上聽不出來的浮水印印記,註明聲音來自雅婷智慧。


發起歌聲生成請求

Request

URL: /vocal
Method: POST

Header

Name Type Info
*key String
*Content-Type String Only “application/json”

Body

Name Type Info
*voice string zh_tw_female_2zh_tw_male_2
*metadata JSON 如表下範例
*instruments List program : must be “vocal_leadsheet”
notes : list, must, can be empty list
chordsChange : leave it empty
controlChanges : optional
*audioConfig JSON sampleRate : 音檔的取樣率,僅支援 44.1K
encoding : 音訊編碼格式,可為 WAV 或 MP3 。

metadata example

{
    "metadata": {
        "ticksPerBeat": 480,
        "tempoChanges": [
            {
                "time": 0,
                "tempo": 150
            }
        ],
        "timeSignatureChanges": [
            {
                "time": 0,
                "numerator": 4,
                "denominator": 4
            }
        ],
        "numberOfBars": 16
    }
}

Request Body Example

{
    "metadata": {
        "ticksPerBeat": 480,
        "tempoChanges": [
            {
                "time": 0,
                "tempo": 80
            }
        ],
        "timeSignatureChanges": [
            {
                "time": 0,
                "numerator": 4,
                "denominator": 4
            }
        ],
        "numberOfBars": 16
    },
    "instruments": [
        {
            "program": "vocal_leadsheet",
            "notes": [
                {
                    "start": 1000,
                    "end": 2250,
                    "word": "我",
                    "pitch": 60
                },
                {
                    "start": 3000,
                    "end": 4250,
                    "word": "想",
                    "pitch": 50
                }
            ],
            "chordChanges": [],
            "controlChanges": [
                {
                    "time": 0,
                    "number": 0,
                    "value": 0
                },
                {
                    "time": 0,
                    "number": 0,
                    "value": 0
                }
            ]
        }
    ],
    "voice": {
        "model": "zh_tw_female_2"
    },
    "audioConfig": {
        "encoding": "MP3",
        "sampleRate": "44.1K"
    }
}

Response Body Example

{
    "uid": "92286f51-3b8a-433d-8ffa-e5f533999595",
    "metadata": {
        "genres": [],
        "artistStyle": "",
        "numberOfBars": 16,
        "tempoChanges": [
            {
                "time": 0,
                "tempo": 80
            }
        ],
        "ticksPerBeat": 480,
        "timeSignatureChanges": [
            {
                "time": 0,
                "numerator": 4,
                "denominator": 4
            }
        ]
    },
    "instruments": [
        {
            "notes": [
                {
                    "end": 2250,
                    "word": "我",
                    "pitch": 60,
                    "start": 1000
                },
                {
                    "end": 4250,
                    "word": "想",
                    "pitch": 50,
                    "start": 3000
                }
            ],
            "program": "vocal_leadsheet",
            "chordChanges": [],
            "controlChanges": [
                {
                    "time": 0,
                    "value": 0,
                    "number": 0
                },
                {
                    "time": 0,
                    "value": 0,
                    "number": 0
                }
            ]
        }
    ],
    "voice": {
        "model": "zh_tw_female_2"
    },
    "audioConfig": {
        "encoding": "MP3",
        "sampleRate": "44.1K"
    },
    "path": "",
    "f0Path": null,
    "f0Boundary": null,
    "status": "pending",
    "createdAt": "2024-03-05T10:19:11.232Z",
    "updatedAt": "2024-03-05T10:19:11.000Z"
}

處理狀態查詢

發起歌聲生成請求後,status 鍵將從 pending 變為 ongoing,最後變為 completed 。 如果出現問題,就會顯示 error。 您可以發出 GET 請求以檢查狀態的更新。

您必須重複 GET 請求,直到您的狀態為 completederror。 一旦狀態鍵顯示為 completed,您就可以從 path 拿到新的連結,並且可以直接下載檔案。

Request

URL: /vocal
Method: GET

Header

Name Type Info
*key String Bearer {key}

Query parameter

Name Info
page number
perPage number
status pending, ongoing, completed, error. if no value, get all list

Request URL Example

/vocal?page=1&perPage=2&status=ongoing

Response Body Example

{
    "page": 3032,
    "perPage": 2,
    "total": 6064,
    "nextPage": null,
    "data": [
        {
            "uid": "92286f51-3b8a-433d-8ffa-e5f533999595",
            "metadata": {
                "genres": [],
                "artistStyle": "",
                "numberOfBars": 16,
                "tempoChanges": [
                    {
                        "time": 0,
                        "tempo": 80
                    }
                ],
                "ticksPerBeat": 480,
                "timeSignatureChanges": [
                    {
                        "time": 0,
                        "numerator": 4,
                        "denominator": 4
                    }
                ]
            },
            "instruments": [
                {
                    "notes": [
                        {
                            "end": 2250,
                            "word": "我",
                            "pitch": 60,
                            "start": 1000
                        },
                        {
                            "end": 4250,
                            "word": "想",
                            "pitch": 50,
                            "start": 3000
                        }
                    ],
                    "program": "vocal_leadsheet",
                    "chordChanges": [],
                    "controlChanges": [
                        {
                            "time": 0,
                            "value": 0,
                            "number": 0
                        },
                        {
                            "time": 0,
                            "value": 0,
                            "number": 0
                        }
                    ]
                }
            ],
            "voice": {
                "model": "zh_tw_female_2"
            },
            "audioConfig": {
                "encoding": "MP3",
                "sampleRate": "44.1K"
            },
            "path": "https://yating-art-prod.s3.ap-northeast-1.amazonaws.com/vocal_generation/cb6384ce-4f65-4a7b-b7f3-399f5870c8cf.mp3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQBODKHMMEW2JBHSO%2F20240305%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20240305T102639Z&X-Amz-Expires=900&X-Amz-Signature=4de8078c61e799c608a65d8c458aca31f64c13830fcb20b4778405f54ea690f5&X-Amz-SignedHeaders=host",
            "f0Path": "https://yating-art-prod.s3.ap-northeast-1.amazonaws.com/vocal_generation/3e8cadfd-4b0e-47f6-9dd0-5bb7afe13902_f0.bin?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQBODKHMMEW2JBHSO%2F20240305%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20240305T102639Z&X-Amz-Expires=900&X-Amz-Signature=46687b9ebcee4cd99c5da613feee01edc63fae590f47114f8eaadd07f774094d&X-Amz-SignedHeaders=host",
            "f0Boundary": [
                [
                    127,
                    301
                ],
                [
                    393,
                    570
                ]
            ],
            "status": "completed",
            "createdAt": "2024-03-05T10:19:11.232Z",
            "updatedAt": "2024-03-05T10:19:21.000Z"
        },
        {
            "uid": "370acea8-3d6b-4a1e-bb87-c70895f10ddc",
            "metadata": {
                "genres": [],
                "artistStyle": "",
                "numberOfBars": 16,
                "tempoChanges": [
                    {
                        "time": 0,
                        "tempo": 80
                    }
                ],
                "ticksPerBeat": 480,
                "timeSignatureChanges": [
                    {
                        "time": 0,
                        "numerator": 4,
                        "denominator": 4
                    }
                ]
            },
            "instruments": [
                {
                    "notes": [
                        {
                            "end": 2250,
                            "word": "我",
                            "pitch": 60,
                            "start": 1000
                        },
                        {
                            "end": 4250,
                            "word": "想",
                            "pitch": 50,
                            "start": 3000
                        }
                    ],
                    "program": "vocal_leadsheet",
                    "chordChanges": [],
                    "controlChanges": [
                        {
                            "time": 0,
                            "value": 0,
                            "number": 0
                        },
                        {
                            "time": 0,
                            "value": 0,
                            "number": 0
                        }
                    ]
                }
            ],
            "voice": {
                "model": "zh_tw_female_2"
            },
            "audioConfig": {
                "encoding": "MP3",
                "sampleRate": "44.1K"
            },
            "path": "https://yating-art-prod.s3.ap-northeast-1.amazonaws.com/vocal_generation/af05deb8-f129-457f-9113-f641aef62b08.mp3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQBODKHMMEW2JBHSO%2F20240305%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20240305T102639Z&X-Amz-Expires=900&X-Amz-Signature=b65fd3f844773124ee3c861218d1b4b6446b55e6aaa089747f68aad1663bbf0d&X-Amz-SignedHeaders=host",
            "f0Path": "https://yating-art-prod.s3.ap-northeast-1.amazonaws.com/vocal_generation/9c152e39-fe72-4f65-a76e-aa1e422edf2c_f0.bin?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQBODKHMMEW2JBHSO%2F20240305%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20240305T102639Z&X-Amz-Expires=900&X-Amz-Signature=3a4f8d6ad640698ec8d877c990c57d1ce1b37de6eedd81e6e5c4234922bb2ae6&X-Amz-SignedHeaders=host",
            "f0Boundary": [
                [
                    127,
                    301
                ],
                [
                    393,
                    570
                ]
            ],
            "status": "completed",
            "createdAt": "2024-03-05T10:26:00.680Z",
            "updatedAt": "2024-03-05T10:26:10.000Z"
        }
    ]
}

取得音檔結果

只要你的音檔狀態是 completed,你即可從以下 path 中取得處理後的音檔連結,並進行下載。

請注意,一但音檔完成後,因為安全問題,檔案只會保留 24 小時,超過就漚會自動刪除。

Request

URL: /vocal/{vocal_id}
Method: GET

Header

Name Type Info
*key String Bearer {key}

Query parameter

Name Type Info
vocal_id string uid

Response

{
    "uid": "92286f51-3b8a-433d-8ffa-e5f533999595",
    "metadata": {
        "genres": [],
        "artistStyle": "",
        "numberOfBars": 16,
        "tempoChanges": [
            {
                "time": 0,
                "tempo": 80
            }
        ],
        "ticksPerBeat": 480,
        "timeSignatureChanges": [
            {
                "time": 0,
                "numerator": 4,
                "denominator": 4
            }
        ]
    },
    "instruments": [
        {
            "notes": [
                {
                    "end": 2250,
                    "word": "我",
                    "pitch": 60,
                    "start": 1000
                },
                {
                    "end": 4250,
                    "word": "想",
                    "pitch": 50,
                    "start": 3000
                }
            ],
            "program": "vocal_leadsheet",
            "chordChanges": [],
            "controlChanges": [
                {
                    "time": 0,
                    "value": 0,
                    "number": 0
                },
                {
                    "time": 0,
                    "value": 0,
                    "number": 0
                }
            ]
        }
    ],
    "voice": {
        "model": "zh_tw_female_2"
    },
    "audioConfig": {
        "encoding": "MP3",
        "sampleRate": "44.1K"
    },
    "path": "<URL>",
    "f0Path": "<URL>",
    "f0Boundary": [
        [
            127,
            301
        ],
        [
            393,
            570
        ]
    ],
    "status": "completed",
    "createdAt": "2024-03-05T10:19:11.232Z",
    "updatedAt": "2024-03-05T10:19:21.000Z"
}