TsgcAIOpenAIChatBotEvents › OnTranscription

OnTranscription Event

Fires when Whisper returns the speech-to-text result; lets you edit the text or reject it.

Syntax

property OnTranscription: TsgcOpenAITranscription;
// TsgcOpenAITranscription = procedure(Sender: TObject; var Text: string; var Accept: Boolean) of object

Default Value

Remarks

Raised after the Whisper call completes. Both parameters are var: set Text to edit or normalise the transcription before it is forwarded to ChatCompletion, or set Accept to False to discard the turn (nothing is sent to the LLM). Typical use: filter wake words, redact sensitive tokens, or drop empty recordings.

Example

procedure TForm1.sgcChatBotTranscription(Sender: TObject; var Text: string; var Accept: Boolean);
begin
  Accept := Trim(Text) <> '';
  if Accept then
    Text := StringReplace(Text, 'Hey bot,', '', [rfIgnoreCase]);
end;

Back to Events