uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.OleServer,
SpeechLib_TLB,
ActiveX, ComObj;
type
TForm17 =
class(TForm)
btn1: TButton;
mmo1: TMemo;
spshrdrcntxt1: TSpSharedRecoContext;
procedure btn1Click(Sender: TObject);
private
FSAPI: ISpeechRecognizer;
FRecoContext: ISpeechRecoContext;
FRecoGrammar: ISpeechRecoGrammar;
{ Private-Deklarationen }
public
procedure OnRecognition(ASender: TObject;
const StreamNumber: Integer; StreamPosition: OleVariant; RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
{ Public-Deklarationen }
end;
var
Form17: TForm17;
SpVoice: ISpeechVoice;
implementation
{$R *.dfm}
{ TForm17 }
procedure TForm17.btn1Click(Sender: TObject);
begin
FSAPI := CreateOleObject('
SAPI.SpVoice')
as ISpeechRecognizer;
FRecoContext := FSAPI.CreateRecoContext;
FRecoGrammar := FRecoContext.CreateGrammar(0);
FRecoGrammar.DictationSetState(SGDSActive);
FRecoContext.OnRecognition := OnRecognition;
end;
procedure TForm17.OnRecognition(ASender: TObject;
const StreamNumber: Integer; StreamPosition: OleVariant; RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
begin
mmo1.Lines.Add(Result.PhraseInfo.GetText(0, -1, True));
end;