Paxa Labs

ออกแบบเสียง

POSThttps://api.paxalabs.com/v1/voices/designเปิดใน Playground

POST /v1/voices/design สร้างเสียงจากคำบรรยาย หรือปรับเสียงจาก draft ตามคำสั่ง แล้วคืนข้อมูลของเสียง ประโยคตัวอย่างเป็น MP3 และ draft สำหรับปรับต่อหรือบันทึก

ดูเป็น Markdown
curl -X POST https://api.paxalabs.com/v1/voices/design \
  -H "Authorization: Bearer $PAXA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "A calm Bangkok pharmacist in her thirties who explains dosages slowly and kindly, speaking Thai"
  }' \
  -o design.json

jq -r .audio design.json | base64 --decode > line.mp3
{
  "draft": "kD3v9QxW2mN7pL0sT5yB8cR1fH4jK6zA...",
  "voice": {
    "name": "Nok",
    "role": "Pharmacist",
    "description": "A calm, warm voice that explains each step slowly.",
    "gender": "f",
    "language": "th",
    "line": "ทานยานี้หลังอาหารวันละสามครั้งนะคะ ถ้ามีผื่นขึ้นให้หยุดยาแล้วกลับมาหาเราได้เลยค่ะ",
    "model": "paxa-tts-flash-v2"
  },
  "audio": "SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYy...",
  "usage": {
    "credits": 5
  }
}

บรรยายว่าผู้พูดเป็นใครและเสียงฟังเป็นแบบไหน เช่น อายุ เพศ ระดับเสียง จังหวะ ท่าทีการพูด และภาษาที่พูด เสียงจะพูดภาษาที่คำบรรยายระบุ ถ้าไม่ได้ระบุจะพูดภาษาที่ใช้เขียนคำบรรยาย ชื่อ บทบาท และคำอธิบายของเสียงจะกลับมาเป็นภาษาที่ใช้เขียนคำบรรยาย

ถ้าอยากปรับเสียง ให้ส่ง draft กลับมาพร้อม instruction เช่น "ทุ้มลงอีกนิดและพูดช้าลง" ทุกการตอบกลับมี draft ใหม่ และเสียงจะมีอยู่จริงเมื่อคุณบันทึก draft นั้นแล้วเท่านั้น

แต่ละคำขอคิด 5 เครดิต รวมประโยคตัวอย่างแล้ว คิดก่อนเริ่มทำงาน และคืนให้อัตโนมัติเมื่อไม่ได้เสียงกลับมา การส่งซ้ำจะออกแบบเสียงใหม่และคิดเครดิตอีกครั้ง เอนด์พอยต์นี้จึงปฏิเสธ Idempotency-Key ด้วย 400 validation แต่ละคำขอนับในอัตราจำกัดคำขอและใช้หนึ่งช่องคำขอพร้อมกันฝั่งเสียงพูดของแพ็กเกจ

เฮดเดอร์#

authorizationBearer pxa_...จำเป็น

Authorization: Bearer pxa_... (recommended).

x-api-keypxa_...

Alternative to the Authorization header. Ignored when Authorization is present.

การยืนยันตัวตน

เนื้อหา#

descriptionstring

Who the voice is and how it sounds, in English, Thai, or Chinese, up to 1,000 characters: age, gender, pitch, pace, manner, and the language it speaks. The voice speaks the language this names, else the language this is written in, and its name, role, and description come back in the language this is written in.

1 to 1,000 charactersตัวอย่าง "A calm Bangkok pharmacist in her thirties who explains dosages slowly and kindly, speaking Thai"
draftstring

A draft an earlier design response returned, to refine that voice. Send it with instruction and without description.

1 to 4,096 characters
instructionstring

What to change about the draft's voice, up to 500 characters, such as "a little lower and slower". The rest of the voice stays as it was.

1 to 500 characters

การตอบกลับ#

A designed voice, ready to refine or save.

draftstringจำเป็น

The voice, sealed. Send it back with an instruction to refine the voice, or to POST /v1/voices/designed to save it. It opens only for this account.

voiceobjectจำเป็น

The designed voice's words.

ดูฟิลด์ย่อย
voice.namestringจำเป็น

A name for the voice, which saving keeps unless you send another.

voice.rolestringจำเป็น

Who the voice is, in a few words.

voice.descriptionstringจำเป็น

How the voice sounds, in one sentence.

voice.gender"f" or "m"จำเป็น

Voice gender, "f" or "m".

voice.language"th" or "en" or "zh"จำเป็น

The one language the voice speaks: "th" (Thai), "en" (English), or "zh" (Mandarin Chinese, Simplified script).

voice.linestringจำเป็น

The example line audio speaks, up to 120 characters in the voice's language.

voice.modelstringจำเป็น

The model the voice speaks on, paxa-tts-flash-v2.

audiostringจำเป็น

The example line spoken in the voice, as base64 MP3.

usageobjectจำเป็น

What the request was billed for.

ดูฟิลด์ย่อย
usage.creditsnumberจำเป็น

What this turn cost, 5 credits.

ข้อผิดพลาด#

400validationThe request body, query, or headers failed validation against the endpoint schema, or broke a rule the endpoint's reference states. A field the schema refused adds two fields to the problem body. path names the first failing field by location and name in dot form, such as body.voice or headers.idempotency-key. A body that could not be read gives the path body alone. reason is one stable code from the validation reasons list.
400draft_invalidThe draft field holds no draft this account received from POST /v1/voices/design. It is altered or cut short, belongs to another account, or no longer opens after a platform update. Nothing was charged.
401unauthorizedThe request carried no API key, or the key is invalid or disabled.
402insufficient_creditsThe account does not have enough credits for this request. Nothing was charged.
403key_limitThis API key reached its spending cap. Nothing was charged.
422content_blockedThe upstream safety system declined to process this content. The charge was refunded.
429rate_limitedRequests per minute for the plan are exhausted. One window covers the whole account, across every product and every key.
429concurrency_limitedThe account holds the plan's full count of concurrent requests for this product. Nothing was charged. Each product is limited separately, and an open live connection holds one slot of its product for its lifetime.
500internalRequest state was inconsistent on the server.
502provider_errorModel inference failed after the request was charged.
503provider_unavailableThe model behind this endpoint is not available right now. Nothing was charged.