文件

AI主播/虛擬主播 v2

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

這個API是一個基於深度學習模型的服務,主要是將音訊和頭像結合,創造出一個虛擬主播的影片,其中頭像的嘴巴動作會與語音同步。這使得用戶可以為人物添加語音,並且創造出一個更加生動和互動的用戶體驗。

使用者首先發起一個POST請求到API,包含了音訊文件的URL、頭像ID以及其他可選參數。API將返回一個任務ID,用戶可以利用這個ID來查詢任務的處理狀態。一旦處理完成,用戶就可以通過一個GET請求來檢索生成的影片文件。


取得avatar列表

Request

URL: /v2/avatar
Method: GET

Header

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

Error Code

  • 201 (Created): 請求已接受,正在處理。
  • 400 (Bad Request): 請求格式錯誤或者音檔長度超過5分鐘。
  • 403 (Forbidden): 認證失敗。

Response

{
    "page": 1,
    "perPage": 20,
    "total": 43,
    "nextPage": 2,
    "data": [
        {
            "uid": "c6a85ed7-3159-41ec-b9c3-8c1722b0c35e",
            "name": "yating-default",
            "path": "https://yating-art-prod.s3.ap-northeast-1.amazonaws.com/virtual_anchor_generation/assets/23224c8d810c24a41b8a402d9e602818.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQBODKHMMEW2JBHSO%2F20231225%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231225T082128Z&X-Amz-Expires=345600&X-Amz-Signature=60f6a61b11cc28cb4dd402f278b9141e03f27cbf088fb488c59e4331cfae6553&X-Amz-SignedHeaders=host",
            "previewImagePath": "https://yating-art-prod.s3.ap-northeast-1.amazonaws.com/virtual_anchor_generation/assets/23224c8d810c24a41b8a402d9e602818.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQBODKHMMEW2JBHSO%2F20231225%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231225T082128Z&X-Amz-Expires=345600&X-Amz-Signature=ddbc70e66fbec852aca7323b557c44ea3199b658ad06b2c9b01840e95388b42b&X-Amz-SignedHeaders=host",
            "thumbnailPath": "https://yating-art-prod.s3.ap-northeast-1.amazonaws.com/virtual_anchor_generation/assets/yating-default-preview.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAQBODKHMMEW2JBHSO%2F20231225%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231225T082128Z&X-Amz-Expires=345600&X-Amz-Signature=df1c4284ce8122c5a34583efc3d50c3cd7bb4d151cdae477d39180f0bdd1d908&X-Amz-SignedHeaders=host",
            "thumbnailGenerationStatus": "pending",
            "createdAt": "2023-12-05T02:24:45.000Z",
            "updatedAt": "2023-12-05T02:46:20.000Z"
        },

Example Curl command

curl --location 'https://arts.api.yating.tw/v2/avatar' \
        --header 'key: YOUR_KEY' \
        --header 'Content-Type: application/json' \

取得特定 Avatar

Request

URL: /v2/avatar/{uid}
Method: GET

Header

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

Error Code

  • 201 (Created): 請求已接受,正在處理。
  • 400 (Bad Request): 請求格式錯誤或者音檔長度超過5分鐘。
  • 403 (Forbidden): 認證失敗。

Response

{
    "uid": "0c60968c-7779-4b0f-98dc-f57cf9eaf11d",
    "name": "iris-default",
    "path": "https://yating-art.s3.ap-northeast-1.amazonaws.com/virtual_anchor_generation/assets/c61def0d17d853bc72b63cf190dab5fe.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA2XEMWPOTI2PSWOF5%2F20231108%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231108T073655Z&X-Amz-Expires=345600&X-Amz-Signature=ed6bb0f9967ab9036c913bd683660a468afb1173760d46ac9d6a53da68da78f7&X-Amz-SignedHeaders=host",
    "previewImagePath": "https://yating-art.s3.ap-northeast-1.amazonaws.com/virtual_anchor_generation/assets/c61def0d17d853bc72b63cf190dab5fe.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA2XEMWPOTI2PSWOF5%2F20231108%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231108T073656Z&X-Amz-Expires=345600&X-Amz-Signature=6af7c4a0e7ff682820838b0255809dc6dbb9dffde7e173739164f60bae178f2f&X-Amz-SignedHeaders=host",
    "thumbnailPath": "https://yating-art.s3.ap-northeast-1.amazonaws.com/virtual_anchor_generation/assets/c61def0d17d853bc72b63cf190dab5fe.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA2XEMWPOTI2PSWOF5%2F20231108%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231108T073656Z&X-Amz-Expires=345600&X-Amz-Signature=6af7c4a0e7ff682820838b0255809dc6dbb9dffde7e173739164f60bae178f2f&X-Amz-SignedHeaders=host",
    "createdAt": "2023-11-08T03:58:14.000Z",
    "updatedAt": "2023-11-08T03:58:14.000Z"
}

Example Curl command

curl --location 'https://arts.api.yating.tw/v2/avatar/0c60968c-7779-4b0f-98dc-f57cf9eaf11d' \
--header 'key: YOUR_KEY'

使用預設的 Avatar 生成影片

Request

URL: V2/2davatar
Method: POST

Header

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

Body

Name Type Info
*audioUrl String 音訊URL(音檔放置可讓API訪問的雲端空間e.g. archive.org 或是GCP)
*avatarId String 各Avatar專屬的uid
backgroundUrl String 背景圖片的URL,目前尚未支援
dangerousFlag boolean(optional) 如果這個flag被設置為true,任務將在10秒後返回錯誤。

Error Code

  • 201 (Created): 請求已接受,正在處理。
  • 400 (Bad Request): 請求格式錯誤或者音檔長度超過5分鐘。
  • 403 (Forbidden): 認證失敗。

{
    "avatarId": "uid",
    "audioUrl": "https://XXX.wav"
}

Response

[
   {
       "uid": "313fb766-cf44-421c-b818-6127ed91d739",
       "status": "pending",
       "createdAt": "2022-08-26T11:40:42.401Z",
       "updatedAt": "2022-08-26T11:40:42.401Z"
   }
]

Example Curl command

curl --location 'https://arts.api.yating.tw/v2/2davatar' \
        --header 'key: YOUR_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "audioUrl":"your_audio_url"
        }'

處理狀態查詢

提交音頻文件進行處理後,“狀態”鍵將從“待處理”變為“處理中”,最後變為“完成”。 如果出現問題,就會進入“錯誤”。 您可以發出 GET 請求,如下所示,以檢查轉錄狀態的更新。

您必須重複 GET 請求,直到您的狀態為“完成”或“錯誤”。 一旦狀態鍵顯示為“已完成”,您就可以從 path 拿到新的連結,並且可以直接下載檔案。

Request

URL: /2davatar
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

Response

{
  "page":2,
  "perPage":10,
  "total":21,
  "nextPage":3,
  "data":[
    {
      "uid":"512b978b-3bda-4f01-aeca-a5abc1944cc2",
      "status":"ongoing",
      "path":"",
      "createdAt":"2022-11-22T16:49:25.835Z",
      "updatedAt":"2022-11-22T16:49:35.000Z"
    }
  ]
}

Example Curl command

curl --location 'https://arts.api.yating.tw/v2/2davatar?status=ongoing&perPage=2000&page=1' \
--header 'key: YOUR_KEY' | jq '.data[] | select(.uid == "c9347810-a386-4188-8614-f997fb4515c5")'

Error Code

  • 200 (Success)
  • 201 (Created)
  • 400 (Bad Request)
  • 403(Forbidden)

取得結果

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

請注意,檔案只會保留 24 小時,超過就會自動刪除。

Request

URL: /2davatar/{id}
Method: GET

Header

Name Type Info
*key String Bearer {key}

Query parameter

Name Info
id string, uid

Error Code

  • 200 (Success)
  • 201 (Created)
  • 400 (Bad Request)
  • 403(Forbidden)

Response

{
  "uid":"53267af3-90f8-4b09-97d0-dcf7d7faf798",
  "status":"completed",
  "path":"mp4影片連結",
  "createdAt":"2022-11-23T10:07:50.683Z",
  "updatedAt":"2022-11-23T10:08:10.000Z"
}

Example Curl command

curl --location 'https://arts.api.yating.tw/v2/2davatar/c9347810-a386-4188-8614-f997fb4515c5' \
--header 'key: YOUR_KEY'
curl --location 'https://arts.api.yating.tw/v2/2davatar/c9347810-a386-4188-8614-f997fb4515c5' \
--header 'key: YOUR_KEY'