TsgcHTTP_API_OpenAIMethods › CreateTranscription

CreateTranscription Method

Transcribes an audio recording into text using an OpenAI speech-to-text model such as Whisper

Syntax

function CreateTranscription(const aRequest : TsgcOpenAIClass_Request_Transcription; const aTime: Cardinal = 10000) : TsgcOpenAIClass_Response_Transcription;

Parameters

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

Return Value

Transcription response containing the recognized text and optional metadata (TsgcOpenAIClass_Response_Transcription)

Remarks

Calls the POST /v1/audio/transcriptions endpoint. This overload sends a URL or pre-encoded audio reference through the request object. Supported input formats include mp3, mp4, mpeg, mpga, m4a, wav and webm, with maximum size of 25MB. For local files it is usually more convenient to use CreateTranscriptionFromFile instead.

Example

oRequest := TsgcOpenAIClass_Request_Transcription.Create;
oRequest.Model := 'whisper-1';
oRequest.FileUrl := 'https://example.com/audio.mp3';
oRequest.Language := 'en';
oResponse := oAPI.CreateTranscription(oRequest, 30000);
ShowMessage(oResponse.Text);

Back to Methods