Audio

Text-to-Speech

POST /v1/audio/speech

Tạo audio từ text. Response trả về byte stream audio thô.

Request

$curl https://api.staging.tram.ai.vn/v1/audio/speech \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer $TRAM_AI_API_KEY" \
> -d '{
> "model": "~openai/tts-1",
> "input": "Xin chào!",
> "voice": "alloy"
>}' --output speech.mp3

Parameters

ParameterTypeRequiredMô tả
modelstringYesModel ID
inputstringYesText cần chuyển thành giọng nói
voicestringYesGiọng nói (alloy, echo, fable, onyx, nova, shimmer)
response_formatstringNoFormat audio: mp3 (default), opus, aac, flac
speednumberNoTốc độ (0.25-4.0, default 1.0)

Speech-to-Text

POST /v1/audio/transcriptions

Transcribe audio thành text (multipart/form-data).

Request

$curl https://api.staging.tram.ai.vn/v1/audio/transcriptions \
> -H "Authorization: Bearer $TRAM_AI_API_KEY" \
> -F "file=@audio.mp3" \
> -F "model=~openai/whisper-1"

Parameters

ParameterTypeRequiredMô tả
modelstringYesModel ID
filefileYesFile audio
languagestringNoNgôn ngữ (ISO 639-1)
response_formatstringNoFormat output: json (default), text, srt, vtt