TsgcHTTP_API_OpenAI › Methods › CreateTranslation
Translates non-English audio into English text using an OpenAI speech model
function CreateTranslation(const aRequest : TsgcOpenAIClass_Request_Translation; const aTime: Cardinal = 10000) : TsgcOpenAIClass_Response_Translation;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Translation | Translation request specifying model, audio source and response format |
aTime | const Cardinal | Read timeout in milliseconds while waiting for the server response (default 10000) |
Translation response containing the English text of the audio (TsgcOpenAIClass_Response_Translation)
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.
oRequest := TsgcOpenAIClass_Request_Translation.Create;
oRequest.Model := 'whisper-1';
oRequest.FileUrl := 'https://example.com/spanish.mp3';
oResponse := oAPI.CreateTranslation(oRequest, 30000);
ShowMessage(oResponse.Text);