TsgcHTTP_API_OpenAI › Methods › CreateTranscription
Transcribes an audio recording into text using an OpenAI speech-to-text model such as Whisper
function CreateTranscription(const aRequest : TsgcOpenAIClass_Request_Transcription; const aTime: Cardinal = 10000) : TsgcOpenAIClass_Response_Transcription;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Transcription | Transcription request specifying model, audio source, language and response format |
aTime | const Cardinal | Read timeout in milliseconds while waiting for the server response (default 10000) |
Transcription response containing the recognized text and optional metadata (TsgcOpenAIClass_Response_Transcription)
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.
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);