Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7645139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:51:50+00:00 2026-05-31T09:51:50+00:00

I’m trying to do some speech recognition with delphi and found this simple project

  • 0

I’m trying to do some speech recognition with delphi and found this simple project which works great but I can’t use it cause I’m not able to import SAPI 5.1.
In the “Import Type Library” Window I can find SAPI 5.4 but sadly I couldn’t get it to work with that. Now I’m wondering whether there is a way to import SAPI 5.1 so I can use the example below and extend it for my needs.

unit Unit3;

interface

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

const SP_GETWHOLEPHRASE = -1;

type
  TForm3 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private-Deklarationen }
  public
    SpSharedRecoContext1: TSpSharedRecoContext;
    MyGrammar : 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);
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 SpSharedRecoContext1.Free;
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
  SpSharedRecoContext1 := TSpSharedRecoContext.Create(self);
  SpSharedRecoContext1.OnRecognition   := SpSharedRecoContext1Recognition;
  SpSharedRecoContext1.OnHypothesis    := SpSharedRecoContext1Hypothesis;
  MyGrammar := SpSharedRecoContext1.CreateGrammar(0);
  MyGrammar.DictationSetState(SGDSActive);
end;

procedure TForm3.SpSharedRecoContext1Recognition(ASender: TObject;
                                                 StreamNumber: Integer;
                                                 StreamPosition: OleVariant;
                                                 RecognitionType: SpeechRecognitionType;
                                                 const Result: ISpeechRecoResult);
begin
 Caption := '';
 Memo1.Lines.Add(Result.PhraseInfo.GetText(SP_GETWHOLEPHRASE,SP_GETWHOLEPHRASE,true));
end;

procedure TForm3.SpSharedRecoContext1Hypothesis(ASender: TObject;
                                                StreamNumber: Integer;
                                                StreamPosition: OleVariant;
                                                const Result: ISpeechRecoResult);
begin
 Caption := 'I am listening...';
end;


end.

Any help is appreciated,

thx timo314

Edit:
I got delphi 6 Personal Edition
SAPI 5.1 is not listed in the “import Type Library” Window
When Compiling I get errors at line 46 and 47 saying “Incompatible Types Parameter Lists differ”

I noticed that the SpeechLib_TLB.pas that came with the example differs from the one the import created in my “Import” Directory.
After I change the Parameter lists of SpSharedRecoContext1Recognition and SpSharedRecoContext1Hypothesis the Application runs but the procedures aren’t called. As if the Programm doesn’t notice that someone is speaking.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:51:51+00:00Added an answer on May 31, 2026 at 9:51 am

    Hard to tell with what you provided, but for me RecognitionType is a TOleEnum and I would use
    Memo1.Lines.Add(Result.PhraseInfo.GetText(0,SP_GETWHOLEPHRASE,true));
    instead of
    Memo1.Lines.Add(Result.PhraseInfo.GetText(SP_GETWHOLEPHRASE,SP_GETWHOLEPHRASE,true));
    As the first param specifies the first element to retrieve.

    I would also set SpSharedRecoContext1.EventInterests := SREAllEvents;

    You might find some useful examples and info on my blog…

    PS: I had no problem with SAPI 5.4, but never tried it on D6….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.