Hướng dẫn

Tài liệu API

Tài liệu API:

Hiện tại, API đang beta test, chỉ áp dụng đối với một số nhóm khách hàng.

# CURL command:

curl -XPOST \
-H 'Authorization: Bearer {nhq_token} \
-d 'provider={provider}& \language={language}&d_token={d_token}&text={text}&voice_id={voice_id}&speed={speed}&stability={stability}&similarity_boost={similarity_boost}' \
https://api.nhqtools.com

Tham số:

- nhq_token: Truy cập https://nhq.tools/dashboard để lấy token
- provider: Nhà cung cấp (hiện tại chỉ áp dụng với **elevenlabs**)
- language: Ngôn ngữ tạo giọng đọc
- d_token: (tuỳ chọn)
- text: Văn bản cần chuyển thành giọng đọc
- voice_id: ID voice (hiện tại chỉ áp dụng với elevenlabs)
- speed: Tốc độ giọng đọc (**0.7-1.2**) - Ngầm định **1.0**
- stability (tuỳ chọn): ngầm định **0.5**
- similarity_boost (tuỳ chọn): Ngầm định **0.75**

Ví dụ:

curl -XPOST \
-H 'Authorization: Bearer xxx' \
-d 'provider=elevenlabs&language=en&d_token=&text=Hello, this is a test&voice_id=YXpFCvM1S3JbWEJhoskW&speed=1&stability=0.5&similarity_boost=0.75' \
https://api.nhqtools.com

# Kết quả:

- status: boolean (True or False)
- message: Thông tin trả về
- error: Lỗi trả về nếu có
- audio: Dữ liệu âm thanh base64
- total_chars: Số ký tự đã sử dụng
- used_credits: Phí sử dụng

API v2: #


1. Tạo task => lấy task ID

Ví dụ:

curl -XPOST https://api.nhq.tools/text-to-speech \
-H 'Authorization: Bearer abcxyz=' \
-d 'action=create_task&provider=elevenlabs&d_token=&text=Hello, this is a test&model_id=eleven_flash_v2_5&language=en&voice_id=pNInz6obpgDQGcFmaJgB&speed=1.0&stability=0.5&similarity_boost=0.5&style=0'

Kết quả trả về là json chứa task_id.

{
    "status":true,
    "task_id":"182811a0-6550-4427-8a25-baaccec8e11b"
}

2. Lấy audio thông qua task_id:

Ví dụ:

curl -XPOST https://api.nhq.tools/text-to-speech \
-H 'Authorization: Bearer abcxyz' \
-d 'action=get_task&provider=elevenlabs&d_token=&task_id=182811a0-6550-4427-8a25-baaccec8e11b'

Kết quả trả về là json:

{
    "status":true,
    "used_price":"4.4",
    "total_chars":"22",
    "state":"completed",
    "url":"https://api-cdn.nhqtools.com/files/182811a0-6550-4427-8a25-baaccec8e11b.mp3"
}

Change Language

Do you want to change language to en?