API âm thanh

Các đường dẫn đang hoạt động

Dùng các API âm thanh tương thích OpenAI đã cấu hình và nhân bản giọng nói, TTS gốc của Qwen.

Các đường dẫn

Đường dẫnPhương thứcTrạng thái
/v1/audio/transcriptionsPOSTĐang hoạt động
/v1/audio/translationsPOSTĐang hoạt động
/v1/audio/speechPOSTĐang hoạt động

POST /v1/audio/speech

Tạo âm thanh giọng nói từ văn bản đầu vào. Yêu cầu dùng envelope JSON cho speech theo giao thức OpenAI-compatible và chấp nhận model, input, voice, response format, speed, instructions, metadata cùng các trường relay riêng của provider khi được cấu hình.

Tạo giọng nói
curl https://www.token168.cc/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -d '{
    "model": "<MODEL_ID>",
    "input": "Token168 unifies native model APIs.",
    "voice": "alloy",
    "instructions": "Neutral narration.",
    "response_format": "mp3",
    "speed": 1,
    "stream_format": "none",
    "metadata": {"trace_id": "trace_123"},
    "task_type": "tts",
    "language": "en",
    "ref_audio": "",
    "ref_text": "",
    "x_vector_only_mode": false,
    "max_new_tokens": 1024,
    "initial_codec_chunk_frames": 0
  }'

POST /api/v1/services/audio/tts/customization

Tạo giọng với model=voice-enrollment và action=create_voice. Gửi URL âm thanh công khai hoặc Base64 Data URI rồi lưu output.voice_id gốc do Alibaba trả về. Quản lý giọng là miễn phí.

create_voice
curl https://www.token168.cc/api/v1/services/audio/tts/customization \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "voice-enrollment",
  "input": {
    "action": "create_voice",
    "target_model": "qwen-audio-3.1-tts-plus",
    "prefix": "myvoice",
    "audio": "https://example.com/reference.wav",
    "language_hints": [
      "zh"
    ]
  }
}'

query_voice

Gọi query_voice với voice_id nhận được đến khi trạng thái là OK. Cùng endpoint customization hỗ trợ list_voice, update_voice và delete_voice.

query_voice
curl https://www.token168.cc/api/v1/services/audio/tts/customization \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "voice-enrollment",
  "input": {
    "action": "query_voice",
    "voice_id": "VOICE_ID_FROM_CREATE"
  }
}'

POST /api/v1/services/audio/tts/SpeechSynthesizer

Dùng qwen-audio-3.1-tts-plus và đặt voice_id gốc vào input.voice. Chế độ không phát trực tiếp trả về output.audio.url. Thêm X-DashScope-SSE: enable để nhận các khối âm thanh Base64 trong output.audio.data theo thứ tự. Tính phí theo usage.characters cuối cùng, không tính thêm phí Token. Dùng API Key Token168.

qwen-audio-3.1-tts-plus
curl https://www.token168.cc/api/v1/services/audio/tts/SpeechSynthesizer \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "qwen-audio-3.1-tts-plus",
  "input": {
    "text": "你好,欢迎使用语音合成。",
    "voice": "VOICE_ID_FROM_CREATE",
    "format": "wav",
    "sample_rate": 24000
  }
}'

cosyvoice-v3-plus

Dùng cosyvoice-v3-plus với giọng hệ thống được hỗ trợ, chẳng hạn longanyang. Điểm cuối tổng hợp giọng nói hiện có chấp nhận khóa API Token168. JSON trả về output.audio.url có thời hạn. Gửi X-DashScope-SSE: enable để nhận các đoạn âm thanh Base64 tuần tự và số usage.characters cuối cùng. Mỗi yêu cầu giới hạn 20.000 ký tự đầu vào.

cosyvoice-v3-plus
curl https://www.token168.cc/api/v1/services/audio/tts/SpeechSynthesizer \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "cosyvoice-v3-plus",
  "input": {
    "text": "你好,欢迎使用语音合成。",
    "voice": "longanyang",
    "format": "wav",
    "sample_rate": 24000
  }
}'

POST /v1/audio/transcriptions

Phiên âm một tệp âm thanh bằng qwen3-asr-flash. Bắt buộc model và file; tùy chọn language, prompt, response_format (json hoặc text). Giới hạn 7 MiB và 5 phút. Không hỗ trợ streaming, phụ đề, input và speed.

Phiên âm thanh
curl https://www.token168.cc/v1/audio/transcriptions \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -F model="qwen3-asr-flash" \
  -F file="@speech.wav" \
  -F response_format="json" \
  -F language="en"

POST /v1/audio/translations

Dịch âm thanh đã tải lên thành văn bản tiếng Anh qua relay âm thanh của giao thức OpenAI-compatible. Yêu cầu dùng cùng cấu trúc multipart như phiên âm, với hành vi upstream dành cho dịch thuật do route lựa chọn.

Dịch âm thanh
curl https://www.token168.cc/v1/audio/translations \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -F model="<MODEL_ID>" \
  -F file="@speech.wav" \
  -F input="speech.wav" \
  -F response_format="json" \
  -F language="en" \
  -F speed="1"

Phạm vi

Xem Models & Pricing để biết mẫu khả dụng và giá. API gốc Qwen giữ nguyên JSON và SSE của nhà cung cấp. Âm thanh thời gian thực và nhạc dùng API riêng.