cofercatu Aprendiz
Registrado: Segunda-Feira, 30 de Outubro de 2006 Mensagens: 249
|
Enviada: Ter Mai 28, 2024 9:01 am Assunto: Falar no microfone e gravar em um memo |
|
|
Bom dia,
encontrei o código abaixo para que seja possível falar no microfone e escrever em um memo, mas estou com erro: OLE error 80045077, classID.
Delphi 10.1
Windows 10
Código: | unit UPrincipal;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, SpeechLib_TLB,
ActiveX;
type
TForm1 = class(TForm)
SpSharedRecoContext1: TSpSharedRecoContext;
Memo1: TMemo;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure SpSharedRecoContext1Recognition(ASender: TObject;
StreamNumber: Integer; StreamPosition: OleVariant;
RecognitionType: TOleEnum; const Result: ISpeechRecoResult);
procedure Button1Click(Sender: TObject);
procedure SpSharedRecoContext1Hypothesis(ASender: TObject;
StreamNumber: Integer; StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
private
{ Private declarations }
Gramatica: ISpeechRecoGrammar;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
SpSharedRecoContext1.Free;
Form1.Close
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SpSharedRecoContext1 := TSpSharedRecoContext.Create(self);
SpSharedRecoContext1.OnRecognition := SpSharedRecoContext1Recognition;
SpSharedRecoContext1.OnHypothesis := SpSharedRecoContext1Hypothesis;
SpSharedRecoContext1.EventInterests := SREAllEvents;
Gramatica := SpSharedRecoContext1.CreateGrammar(0);
Gramatica.DictationSetState(SGDSActive);
end;
procedure TForm1.SpSharedRecoContext1Hypothesis(ASender: TObject;
StreamNumber: Integer; StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
begin
Caption := 'Aguardando conversa microfone';
end;
procedure TForm1.SpSharedRecoContext1Recognition(ASender: TObject;
StreamNumber: Integer; StreamPosition: OleVariant; RecognitionType: TOleEnum;
const Result: ISpeechRecoResult);
begin
Memo1.SelText := Result.PhraseInfo.GetText(0, -1, True) + #32;
end;
end. |
|
|