TsgcHTTP_API_OpenAIMethods › CreateTranslation

CreateTranslation Method

Translates non-English audio into English text using an OpenAI speech model

Syntax

function CreateTranslation(const aRequest : TsgcOpenAIClass_Request_Translation; const aTime: Cardinal = 10000) : TsgcOpenAIClass_Response_Translation;

Parameters

NameTypeDescription
aRequestconst TsgcOpenAIClass_Request_TranslationTranslation request specifying model, audio source and response format
aTimeconst CardinalRead timeout in milliseconds while waiting for the server response (default 10000)

Return Value

Translation response containing the English text of the audio (TsgcOpenAIClass_Response_Translation)

Remarks

Calls the POST /v1/audio/translations endpoint. The service automatically detects the source language and returns the translated content in English. Use this overload when the audio source is specified by URL or reference; use CreateTranslationFromFile to upload a local recording.

Example

oRequest := TsgcOpenAIClass_Request_Translation.Create;
oRequest.Model := 'whisper-1';
oRequest.FileUrl := 'https://example.com/spanish.mp3';
oResponse := oAPI.CreateTranslation(oRequest, 30000);
ShowMessage(oResponse.Text);

Back to Methods