TsgcAIOpenAIChatBot › Events › OnTranscription
Fires when Whisper returns the speech-to-text result; lets you edit the text or reject it.
property OnTranscription: TsgcOpenAITranscription;
// TsgcOpenAITranscription = procedure(Sender: TObject; var Text: string; var Accept: Boolean) of object
—
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.
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;