TsgcHTTP_API_OpenAI › Methods › CreateTranslationFromFile
Translates a local non-English audio file into English text using an OpenAI speech model
function CreateTranslationFromFile(const aRequest : TsgcOpenAIClass_Request_Translation) : TsgcOpenAIClass_Response_Translation;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Translation | Translation request where FileName points to a local audio file on disk |
Translation response containing the English text of the audio (TsgcOpenAIClass_Response_Translation)
Calls the POST /v1/audio/translations endpoint with a multipart/form-data body that uploads the local audio file. The source language is auto-detected and output is always English. Supported formats include mp3, wav, m4a, mp4, mpeg, mpga and webm, with a 25MB file size limit.
oRequest := TsgcOpenAIClass_Request_Translation.Create;
oRequest.Model := 'whisper-1';
oRequest.FileName := 'C:\audio\french.mp3';
oResponse := oAPI.CreateTranslationFromFile(oRequest);
ShowMessage(oResponse.Text);