Einzelnen Beitrag anzeigen

ZYLAGON

Registriert seit: 11. Nov 2015
49 Beiträge
 
Delphi 10.3 Rio
 
#3

AW: Windows Speech to Text Sapi 5.4

  Alt 26. Jan 2023, 16:38
Ich hatte vor mehr als ein Jahrzehnt mal ein kleines Testprogramm geschrieben, was auch tatsächlich funktionierte (die Spracherkennung war allerdings sehr dürftig).
SAPI-Version war auf alle Fälle älter als 5.4.
Sieht sehr ähnlich aus wie Dein Code, ich stelle den mal hier rein, vielleicht hilft´s ja ein wenig:

Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleServer, SpeechLib_TLB, ActiveX;

type
  TForm2 = class(TForm)
    SpSharedRecoContext1: TSpSharedRecoContext;
    Memo1: TMemo;
    procedure cre(Sender: TObject);
    procedure SpSharedRecoContext1Hypothesis(ASender: TObject;
      StreamNumber: Integer; StreamPosition: OleVariant;
      const Result: ISpeechRecoResult);
    procedure SpSharedRecoContext1Recognition(ASender: TObject;
      StreamNumber: Integer; StreamPosition: OleVariant;
      RecognitionType: TOleEnum; const Result: ISpeechRecoResult);
  private
    { Private-Deklarationen }
    fMyGrammar:ISpeechRecoGrammar;
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.cre(Sender: TObject);
begin
  fMyGrammar:=SpSharedRecoContext1.CreateGrammar(0);
  fMyGrammar.DictationSetState(SGDSActive);
end;


procedure TForm2.SpSharedRecoContext1Hypothesis(ASender: TObject;
  StreamNumber: Integer; StreamPosition: OleVariant;
  const Result: ISpeechRecoResult);
begin
  Memo1.Text := Result.PhraseInfo.GetText(0,-1,true);
end;

procedure TForm2.SpSharedRecoContext1Recognition(ASender: TObject;
  StreamNumber: Integer; StreamPosition: OleVariant; RecognitionType: TOleEnum;
  const Result: ISpeechRecoResult);
begin
  Memo1.Text := Result.PhraseInfo.GetText(0,-1,true);
end;

end.
VG ZYL
  Mit Zitat antworten Zitat