How to Create a Simple Dictation Pad in Delphi2009+Vista
- by XBasic3000
the code are not so complecated..
private
{ Private declarations }
SpSharedRecoContext1 : TSpSharedRecoContext;
fMyGrammar : ISpeechRecoGrammar;
procedure SpSharedRecoContext1Recognition(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
procedure SpSharedRecoContext1Hypothesis(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
procedure TForm1.FormCreate(Sender: TObject);
begin
SpSharedRecoContext1 := TSpSharedRecoContext.Create(self);
SpSharedRecoContext1.OnHypothesis := SpSharedRecoContext1Hypothesis;
SpSharedRecoContext1.OnRecognition :=SpSharedRecoContext1Recognition;
fMyGrammar := SpSharedRecoContext1.CreateGrammar(0);
fMyGrammar.DictationSetState(SGDSActive);
end;
procedure TForm1.SpSharedRecoContext1Recognition(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
begin
Memo1.Text := Result.PhraseInfo.GetText(0,-1,true);
end;
procedure TForm1.SpSharedRecoContext1Hypothesis(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
begin
Memo1.Text := Result.PhraseInfo.GetText(0,-1,true);
end;
My Problem, was the vista-OS voice command will intercept on my program. if i say "START", instead of writing start on memo1 it press the start menu on my desktop. or what ever command like START CANCEL EDIT DELETE SELECT etc. please help..... sorry for my english