Âm thanh & TTS Doubao
Hỗ trợ cả tuyến tương thích OpenAI (nhị phân) và tuyến gốc Volcengine (JSONL/SSE/JSON). Tài liệu Audio 1.5 · Tài liệu 3.0 · Tài liệu 2.0
[!NOTE] ID mô hình trong ví dụ chỉ để tham khảo; khi gọi thực tế, hãy dùng ID thật tại Chợ mô hình.
Tra nhanh mô hình & tuyến
| Mô hình | Tính năng | OpenAI (Nhị phân) | Tuyến gốc Volcengine | Giọng / Định dạng / Tốc độ | Tính phí |
|---|---|---|---|---|---|
doubao-seed-audio-1-5-261128 (Khuyên dùng Tạo âm thanh) | ≤6 phút, tham chiếu âm thanh/ảnh/video, tách track (≤6), lồng tiếng 30 ngôn ngữ | POST /v1/audio/speech | POST /api/v3/contents/generations (JSON) | 2.0 speaker:// (≤6); wav/mp3/pcm/ogg_opus; -50–100 | usage.duration_ms (4 mức/phút) |
doubao-seed-tts-3.0 (Khuyên) | 100+ ngôn ngữ, thẻ cảm xúc, instructions, dấu thời gian | POST /v1/audio/speech | POST /api/v3/text-to-speech/{voice_id}/streaming (JSONL) | Chỉ 3.0; mp3/ogg_opus/pcm; 0.5–2.0 | Ký tự đầu vào (Hán=2, khác=1) |
seed-tts-2.0 | Đa ngôn ngữ kinh điển, SSE/Chunked, mix_speaker | POST /v1/audio/speech | POST /api/v3/tts/unidirectional/sse (SSE)POST /api/v3/tts/unidirectional (Chunked) | Giọng 2.0; mp3/wav/pcm/ogg_opus; -50–100 | usage.text_words thượng nguồn |
seed-audio-1.0 | Hội thoại/hiệu ứng/môi trường (≤120s), tham chiếu ảnh/âm thanh | POST /v1/audio/speech | POST /api/v3/tts/create (JSON) | Tùy chọn speaker 2.0 (trích @音频N); như trên | Giây original_duration |
[!TIP] Cần tệp âm thanh phát ngay chọn
POST /v1/audio/speech; dùng SDK Volcengine hoặc cầnalignment/JSON gốc chọn/api/v3/.... Xác thực bằngAuthorization: Bearer sk-...hoặcX-Api-Key: sk-...(2.0 gốc ưu tiênX-Api-Key).
1. Tạo âm thanh 1.5 (doubao-seed-audio-1-5-261128)
Endpoint đồng bộ Volcengine Ark hỗ trợ văn bản thành âm thanh, tham chiếu đa phương thức (âm thanh/ảnh/video), tách track (≤6) và lồng tiếng video 30 ngôn ngữ (tối đa 6 phút, 10.000 ký tự).
Gọi nhanh tương thích OpenAI (POST /v1/audio/speech)
curl -X POST https://www.roookey.com/v1/audio/speech \
-H "Authorization: Bearer sk-your_token" \
-H "Content-Type: application/json" -o scene.wav \
-d '{
"model": "doubao-seed-audio-1-5-261128",
"input": "Female narrator (@音频1): [0.5s:5.0s] Welcome to Doubao Seed Audio 1.5.",
"voice": "zh_female_vv_uranus_bigtts",
"response_format": "wav",
"sample_rate": 44100,
"watermark": false
}'
voiceauto-prefixesspeaker://; flatimage_url(≤1),audio_urls(≤6),video_url(≤1),watermarksupported. Defaultwav/44100Hz (40000removed;ogg_opusonly48000).
Volcengine Ark Nguyên bản (POST /api/v3/contents/generations)
# Multimodal ref (reference_audio / reference_image / reference_video), Stem Separation (role: "separate_audio"), or Video Dubbing (role: "dubbing_video" + dubbing_config)
curl -X POST https://www.roookey.com/api/v3/contents/generations \
-H "Authorization: Bearer sk-your_token" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-audio-1-5-261128",
"content": [
{ "type": "text", "text": "Use @音频1 voice with gentle rain ambience: We finally arrived." },
{ "type": "audio_url", "audio_url": { "url": "speaker://zh_female_vv_uranus_bigtts" }, "role": "reference_audio" },
{ "type": "video_url", "video_url": { "url": "https://example.com/scene.mp4" }, "role": "reference_video" }
],
"output_format": "wav",
"audio_config": { "sample_rate": 44100 },
"include": ["video_url", "subtitles.srt"]
}'
- Tính phí theo
usage.duration_ms(làm tròn lên giây nguyên rồi quy phút; tốc độ không ảnh hưởng; lỗi = 0): Văn bản/Tham chiếu không video1.00, Tham chiếu video6.00, Lồng tiếng4.00, Tách track0.35CNY/phút. URL hết hạn sau 24 giờ.
2. Doubao Seed TTS 3.0 (doubao-seed-tts-3.0)
Tương thích OpenAI (POST /v1/audio/speech)
curl -X POST https://www.roookey.com/v1/audio/speech \
-H "Authorization: Bearer sk-your_token" \
-H "Content-Type: application/json" -o output.mp3 \
-d '{
"model": "doubao-seed-tts-3.0",
"input": "Xin chào, chào mừng đến với Doubao Seed TTS 3.0.",
"voice": "multi_female_tuanzi_v3_uranus_bigtts",
"response_format": "mp3",
"sample_rate": 24000,
"speed": 1.0,
"instructions": "nhẹ nhàng tự nhiên"
}'
- Lưu ý tương thích:
wav→mp3,pcmbỏbit_rate,instructionsnhận chuỗi/mảng; các trườngoutput_format/voice_settingscùngsession_id/pronunciation_dictionary/watermark/text_normalization/enable_markdown_filter/silence_durationđều truyền phẳng được.
Tuyến gốc (POST /api/v3/text-to-speech/{voice_id}/streaming)
curl -X POST https://www.roookey.com/api/v3/text-to-speech/multi_female_tuanzi_v3_uranus_bigtts/streaming \
-H "X-Api-Key: sk-your_token" \
-H "Content-Type: application/json" \
-d '{
"text": "Xin chào, chào mừng đến với Doubao Seed TTS 3.0.",
"model_id": "doubao-seed-tts-3.0",
"language_code": "auto",
"output_format": { "format": "mp3", "sample_rate": 24000, "bit_rate": 64000 },
"voice_settings": { "speed": 1.0, "volume": 1.0, "pitch": 0, "instructions": ["nhẹ nhàng tự nhiên"] },
"enable_subtitle": true
}'
- Truyền thẳng luồng JSONL (
ready/audioBase64/alignment/final); gặp{"event":"error",...}tự hoàn tiền 0 phí.
| Tham số | Bắt buộc | Mô tả |
|---|---|---|
voice_id (đường dẫn)/voice | Có | ID giọng 3.0 hoặc nhân bản (không hỗ trợ 1.0/2.0) |
text / input | Có* | Văn bản (≤10.000 ký tự, thẻ cảm xúc); tuyến gốc loại trừ với ssml |
ssml | Không | SSML trên tuyến gốc (loại trừ text) |
model_id / model | Không* | Bắt buộc ở /v1/audio/speech (doubao-seed-tts-3.0); tuyến gốc mặc định như vậy |
language_code | Không | Mã ngôn ngữ/phương ngữ, mặc định auto (vd. zh-CN-x-sichuan) |
output_format | Không | format (mp3/ogg_opus/pcm), sample_rate (48000 cho ogg_opus, mặc định 24000), bit_rate (64000/160000) |
voice_settings | Không | speed/volume (0.5–2.0), pitch (-12–12), instructions (mảng), similarity_boost, dialect_boost |
enable_subtitle | Không | Xuất dấu thời gian alignment trong JSONL (mặc định false) |
[!NOTE] Tính ký tự 3.0: Chữ Hán/Kanji = 2, còn lại (chữ Latinh/số/kana/dấu câu/khoảng trắng/xuống dòng) = 1. Vd:
你好,world!= 11,日本のアニメ= 8.
3. Doubao TTS 2.0 (seed-tts-2.0)
Tương thích OpenAI (POST /v1/audio/speech)
curl -X POST https://www.roookey.com/v1/audio/speech \
-H "Authorization: Bearer sk-your_token" \
-H "Content-Type: application/json" -o output.mp3 \
-d '{
"model": "seed-tts-2.0",
"input": "Xin chào, chào mừng đến với Doubao TTS 2.0.",
"voice": "zh_female_vv_uranus_bigtts",
"response_format": "mp3",
"sample_rate": 24000,
"speed": 0
}'
speedánh xạaudio_params.speech_rate(-50–100,0bình thường,100=2x,-50=0.5x); hỗ trợmix_speaker.
Tuyến gốc (SSE / Chunked)
- Đường dẫn:
POST /api/v3/tts/unidirectional/sse(SSE) hoặc/api/v3/tts/unidirectional(Chunked); chỉ định mô hình quaX-Api-Resource-Idhoặcmodel.
curl -X POST https://www.roookey.com/api/v3/tts/unidirectional/sse \
-H "X-Api-Key: sk-your_token" \
-H "X-Api-Resource-Id: seed-tts-2.0" \
-H "Content-Type: application/json" \
-d '{
"user": { "uid": "demo_user" },
"req_params": {
"text": "Xin chào, chào mừng đến với Doubao TTS 2.0.",
"speaker": "zh_female_vv_uranus_bigtts",
"audio_params": { "format": "mp3", "sample_rate": 24000, "speech_rate": 0 }
}
}'
- Truyền thẳng khung JSON gốc (
code: 0/3000Base64data,code: 20000000kết thúc kèmusage.text_words).
4. Tạo âm thanh 1.0 (seed-audio-1.0)
Tạo hội thoại, hiệu ứng hoặc tiếng môi trường (≤120s), tính phí theo giây original_duration (không ảnh hưởng bởi speech_rate).
Tương thích OpenAI (POST /v1/audio/speech)
curl -X POST https://www.roookey.com/v1/audio/speech \
-H "Authorization: Bearer sk-your_token" \
-H "Content-Type: application/json" -o scene.mp3 \
-d '{
"model": "seed-audio-1.0",
"input": "Nhân vật A (giọng nữ dịu) 声音@音频1\nTrong mưa đêm, nhân vật A thì thầm: Cuối cùng cũng tới.",
"voice": "zh_female_vv_uranus_bigtts",
"response_format": "mp3",
"sample_rate": 44100,
"speech_rate": 0, "loudness_rate": 0, "pitch_rate": 0
}'
- Lưu ý tương thích:
voicetùy chọn; hỗ trợimage_url(≤1) hoặcaudio_urls(≤3), ảnh loại trừ với giọng/âm thanh (400).
Tuyến gốc (POST /api/v3/tts/create)
curl -X POST https://www.roookey.com/api/v3/tts/create \
-H "X-Api-Key: sk-your_token" \
-H "Content-Type: application/json" \
-d '{
"model": "seed-audio-1.0",
"text_prompt": "Nhân vật A (giọng nữ dịu) 声音@音频1\nTrong mưa đêm, nhân vật A thì thầm: Cuối cùng cũng tới.",
"references": [{ "speaker": "zh_female_vv_uranus_bigtts" }],
"audio_config": { "format": "mp3", "sample_rate": 44100, "speech_rate": 0, "loudness_rate": 0, "pitch_rate": 0 }
}'
| Tham số | Bắt buộc | Mô tả |
|---|---|---|
model | Có | seed-audio-1.0 (hoặc header X-Api-Resource-Id) |
text_prompt | Có | Prompt (≤3000 ký tự); mọi speaker/âm thanh trong references phải trích dẫn đúng thứ tự @音频1–@音频3 |
references | Không | {"speaker":"..."}, {"image_url":"..."} (image_bytes, ≤1), {"audio_url":"..."} (audio_data, ≤3); ảnh loại trừ speaker/âm thanh (400) |
audio_config | Không | format (mp3/wav/pcm/ogg_opus), sample_rate (48000 cho ogg_opus, 40000 wav/pcm, 44100 mp3), speech_rate/loudness_rate (-50–100), pitch_rate (-12–12) |
- Truyền thẳng JSON gốc (
audioBase64 và/hoặcurltạm,original_duration,duration).
Tránh lỗi: Gắn references bằng @音频N (Nhiều vai)
Truyền speaker/âm thanh mà thiếu @音频N sẽ báo 55001309: audio generate internal error; trích dẫn 1-1 theo thứ tự mảng:
{
"model": "seed-audio-1.0",
"text_prompt": "Vai A (nam trầm ấm) 声音@音频1, Vai B (nam trung niên hơi khàn) 声音@音频2\nĐiện thoại rung trong mưa nhẹ. Vai A hỏi: \"Phương án đã duyệt chưa?\" Vai B đáp: \"Đã xong, mai triển khai.\" Tiếng bước chân nhẹ.",
"references": [{ "speaker": "zh_male_example_speaker_1" }, { "speaker": "zh_male_example_speaker_2" }],
"audio_config": { "format": "mp3", "sample_rate": 48000, "speech_rate": 0, "loudness_rate": 0, "pitch_rate": 0 }
}
5. Tra nhanh giọng đọc
Giọng 3.0 và 1.0/2.0 không tương thích (hỗ trợ ID nhân bản). Tìm, sao chép và nghe thử toàn bộ giọng ở danh mục dưới.
| Mô hình | Giọng phổ biến |
|---|---|
| TTS 3.0 (ZH) | Tuanzi multi_female_tuanzi_v3_uranus_bigtts · Xiaotian multi_male_taocheng_v3_uranus_bigtts · Yunzhou multi_male_m191_v3_uranus_bigtts |
| TTS 3.0 (Phương ngữ/EN) | Quảng Đông multi_male_cantonesemalevoicedb_3_v3_uranus_bigtts · Tứ Xuyên multi_female_sichuandialectfemalevoicedb_3_v3_uranus_bigtts · Jamie multi_male_jamie_v3_uranus_bigtts |
| TTS 2.0 / Audio 1.0 / 1.5 | Vivi zh_female_vv_uranus_bigtts · Xiaohe zh_female_xiaohe_uranus_bigtts · Ahu zh_male_wennuanahu_uranus_bigtts · Xiaoming zh_male_jieshuoxiaoming_uranus_bigtts |
5. Mã lỗi Thường gặp & Khắc phục sự cố
Mã trạng thái HTTP, định dạng nội dung lỗi và hướng dẫn khắc phục theo từng tình huống đã được duy trì thống nhất tại một trang chuyên biệt, tránh trùng lặp và lệch thông tin với các ví dụ gọi API.
👉 Mã lỗi Thường gặp & Khắc phục sự cố Gateway
Tham khảo nhanh (xem chi tiết tại trang chuyên biệt):
| Mã | Ý nghĩa |
|---|---|
| 400 | Tham số không hợp lệ / kiểm duyệt nội dung hoặc chặn bản quyền |
| 402 | Số dư tài khoản không đủ (không phải 429) |
| 429 | Giới hạn tốc độ RPS/RPM của token, hoặc quá nhiều tác vụ đang chạy khi số dư thấp |
| 403 | Quyền token / IP / mô hình (số dư xem 402; chặn nội dung xem 400) |
200 + status: failed | Lỗi nghiệp vụ của tác vụ dài như video bất đồng bộ (thường gặp khi polling) |
Mã phản hồi HTTP khớp với status_code trong nhật ký gọi API trên bảng điều khiển, có thể truy vết theo log_id.