Skip to content
開發指南

語音合成與轉錄 ​

Vanix AI 提供標準 OpenAI 相容的音訊端點,涵蓋語音合成(/v1/audio/speech)、語音轉錄(/v1/audio/transcriptions)與語音翻譯(/v1/audio/translations)。

文字轉語音 (TTS) ​

POSThttps://api.vanix.io/v1/audio/speech
bash
curl https://api.vanix.io/v1/audio/speech \
  -H "Authorization: Bearer $VANIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "voice": "alloy",
    "input": "Welcome to Vanix AI. Your unified model gateway is ready.",
    "response_format": "mp3"
  }' \
  --output speech.mp3
python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["VANIX_API_KEY"],
    base_url="https://api.vanix.io/v1",
)

with client.audio.speech.with_streaming_response.create(
    model="gpt-4o-mini-tts",
    voice="alloy",
    input="Welcome to Vanix AI. Your unified model gateway is ready.",
) as response:
    response.stream_to_file("speech.mp3")

語音轉文字 (STT 轉錄) ​

POSThttps://api.vanix.io/v1/audio/transcriptions

以 multipart/form-data 格式上傳 mp3、wav、m4a、ogg 或 webm 音訊檔案。將 response_format 設為 verbose_json 即可取得逐段時間戳記。

bash
curl https://api.vanix.io/v1/audio/transcriptions \
  -H "Authorization: Bearer $VANIX_API_KEY" \
  -F "model=whisper-1" \
  -F "file=@meeting.mp3" \
  -F "response_format=verbose_json"

語音翻譯 ​

POSThttps://api.vanix.io/v1/audio/translations

使用與語音轉錄相同的 multipart/form-data 欄位,單次請求即可將非英語音訊直接翻譯為英文文字。

Vanix AI 統一模型閘道 · https://api.vanix.io