Chuyển đến nội dung chính

Âm thanh

Ba nhóm endpoint: chuyển giọng nói thành văn bản, dịch âm thanh và chuyển văn bản thành giọng nói (TTS). Phần transcriptions/translations tải tệp lên dưới dạng multipart/form-data; TTS nhận JSON và trả về dữ liệu âm thanh nhị phân.

Chuyển giọng nói thành văn bản (Transcriptions)​

POST /v1/audio/transcriptions
curl https://test.kailin.com.cn/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-token" \
-F "file=@/path/to/audio.mp3" \
-F "model=whisper-1" \
-F "language=zh"

Các trường (form-data)​

TrườngKiểuBắt buộcMô tả
filefileCóTệp âm thanh (mp3/wav/m4a/webm v.v., ≤25MB)
modelstringCówhisper-1, gpt-4o-transcribe, gpt-4o-mini-transcribe, v.v.
languagestringKhôngMã ISO-639-1 (ví dụ zh) — giúp tăng độ chính xác
promptstringKhôngVăn bản hướng dẫn giúp viết đúng tên riêng
response_formatstringKhôngjson (mặc định) / text / srt / verbose_json / vtt
temperaturenumberKhôngNhiệt độ lấy mẫu

Phản hồi​

{ "text": "This is the transcribed text." }

Định dạng verbose_json trả về thêm các phân đoạn và dấu thời gian (segments / duration).

Dịch âm thanh (Translations)​

POST /v1/audio/translations

Dịch nội dung âm thanh sang tiếng Anh. Các trường giống với phần transcriptions (không có tham số language):

curl https://test.kailin.com.cn/v1/audio/translations \
-H "Authorization: Bearer sk-your-token" \
-F "file=@/path/to/audio.mp3" \
-F "model=whisper-1"
{ "text": "This is the English translation of the audio." }

Chuyển văn bản thành giọng nói (TTS)​

POST /v1/audio/speech
curl https://test.kailin.com.cn/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "Welcome to AI Station."
}' \
--output speech.mp3

Thân yêu cầu​

Tham sốKiểuBắt buộcMô tả
modelstringCótts-1, tts-1-hd, gpt-4o-mini-tts, v.v.
inputstringCóVăn bản cần tổng hợp — tối đa 4096 ký tự
voicestringCóalloy / echo / fable / onyx / nova / shimmer, v.v.
response_formatstringKhôngmp3 (mặc định) / opus / aac / flac / wav / pcm
speednumberKhông0.25–4.0, mặc định 1.0

Phản hồi​

Khi thành công, endpoint trả về các byte âm thanh thô (được mã hóa theo response_format). Hãy lưu nó thành tệp thay vì phân tích cú pháp như JSON.

Cảnh báo

Khi dùng playground trên web cho transcriptions/translations, hãy chuyển sang chế độ biểu mẫu (form) để tải tệp lên. Phản hồi của TTS là một luồng nhị phân — playground nhúng sẵn trình phát âm thanh cho nó, nhưng nên kiểm chứng bằng cURL/SDK.