Recent

Author Topic: Any successful experience with SpeechToText API on Windows?  (Read 20024 times)

typo

  • Hero Member
  • *****
  • Posts: 3051
I could not run any example I have found.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Any successful experience with SpeechToText API on Windows?
« Reply #1 on: July 03, 2015, 02:38:21 am »
What's wrong with ones you posted?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Any successful experience with SpeechToText API on Windows?
« Reply #2 on: July 03, 2015, 02:40:17 am »
Which ones? I refer to Speech Recognition.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Any successful experience with SpeechToText API on Windows?
« Reply #3 on: July 03, 2015, 01:29:06 pm »
I am trying to run some Delphi samples, without success. I got a SpeechLib_TLB unit with some modifications to compile in FPC, but my project has a SIGSEGV on the following lines:

Code: [Select]
  SpSharedRecoContext1 := TSpSharedRecoContext.Create(self);
  SpSharedRecoContext1.EventInterests := SREAllEvents;  //<<<<<<<<<<<<<< SIGSEGV here
  SpSharedRecoContext1.OnHypothesis := @SpSharedRecoContext1Hypothesis;
  SpSharedRecoContext1.OnRecognition := @SpSharedRecoContext1Recognition;
  fMyGrammar := SpSharedRecoContext1.CreateGrammar(0);  //<<<<<<<<<<<<<<  SIGSEGV here
  fMyGrammar.DictationSetState(SGDSActive);

Unit attached.
« Last Edit: July 03, 2015, 01:37:09 pm by typo »

balazsszekely

  • Guest
Re: Any successful experience with SpeechToText API on Windows?
« Reply #4 on: July 03, 2015, 02:35:26 pm »
@typo

To make a long debugging story short, the line: 
Code: [Select]
SpSharedRecoContext1.EventInterests := SREAllEvents;fails, because the following procedure:
Code: [Select]
ConnectEvents(const Obj: IUnknown); is not implemented in OleServer.pp(line 160).

It should be something like this:
Code: [Select]
procedure TOleServer.ConnectEvents(const Obj: IUnknown);
begin
  ComObj.InterfaceConnect(Obj, FServerData^.EventIID, FEventDispatch, FEventsConnection);
end;


typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Any successful experience with SpeechToText API on Windows?
« Reply #5 on: July 03, 2015, 02:51:30 pm »
I have made this modification in OleServer.pp and TSpSharedRecoContext.Set_EventInterests still causes SIGSEGV.

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: Any successful experience with SpeechToText API on Windows?
« Reply #6 on: July 03, 2015, 02:54:43 pm »
I am trying to run some Delphi samples, without success. I got a SpeechLib_TLB unit with some modifications to compile in FPC
Why didn't you use "Tools > Import Type Library..." in Lazarus to generate a new SpeechLib_5_4_TLB ???

You can just use your own sapi.dll (in C:\Windows\SysWOW64\Speech\Common\sapi.dll) to create the TLB-file.


typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Any successful experience with SpeechToText API on Windows?
« Reply #7 on: July 03, 2015, 03:05:02 pm »
I am trying to run some Delphi samples, without success. I got a SpeechLib_TLB unit with some modifications to compile in FPC
Why didn't you use "Tools > Import Type Library..." in Lazarus to generate a new SpeechLib_5_4_TLB ???

You can just use your own sapi.dll (in C:\Windows\SysWOW64\Speech\Common\sapi.dll) to create the TLB-file.

Do you refer to Delphi conversion feature?

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: Any successful experience with SpeechToText API on Windows?
« Reply #8 on: July 03, 2015, 03:17:19 pm »
I am trying to run some Delphi samples, without success. I got a SpeechLib_TLB unit with some modifications to compile in FPC
Why didn't you use "Tools > Import Type Library..." in Lazarus to generate a new SpeechLib_5_4_TLB ???

You can just use your own sapi.dll (in C:\Windows\SysWOW64\Speech\Common\sapi.dll) to create the TLB-file.

Do you refer to Delphi conversion feature?
No, "Tools > Import Type Library..." is for importing definitions of a dll, etc. and creating a TLB-file (just like you can in Delphi).

It will create a TLB-file which should be compatible with FPC/Lazarus without any modification needed.

There is no need to use a TLB generated by Delphi. You can look in the headers of that file to see from which dll it is generated and you can generate your own TLB with the tool from Lazarus.

I'll attach a small example of my version of import. It doesn't work yet but you can look at the imported SpeechLib_5_4_TLB.
« Last Edit: July 03, 2015, 03:29:28 pm by rvk »

balazsszekely

  • Guest
Re: Any successful experience with SpeechToText API on Windows?
« Reply #9 on: July 03, 2015, 03:18:29 pm »
Code: [Select]
@typo
I have made this modification in OleServer.pp
It's not the only missing code +  OleServer.pp is located in \fpc\x.x.x\source\... you have to rebuild fpc.


rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: Any successful experience with SpeechToText API on Windows?
« Reply #11 on: July 03, 2015, 04:16:59 pm »
http://bugs.freepascal.org/view.php?id=28377
Where does FEventsConnection come from in your patch?

(maybe it's just me but I can't find FEventsConnection anywhere in the whole source of FPC/Lazarus)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Any successful experience with SpeechToText API on Windows?
« Reply #12 on: July 03, 2015, 04:26:35 pm »
http://bugs.freepascal.org/view.php?id=28377
Where does FEventsConnection come from in your patch?

(maybe it's just me but I can't find FEventsConnection anywhere in the whole source of FPC/Lazarus)


Hahaha, thanks. And sorry.

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: Any successful experience with SpeechToText API on Windows?
« Reply #13 on: July 03, 2015, 05:13:42 pm »
Now I'm getting
Quote
oleserver.pp(51,5) Error: Duplicate identifier "FEventDispatch"
oleserver.pp(88,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

Your latest patch also adds FEventDispatch which was already present in trunk :)

Code: [Select]
  TOleServer = class(TComponent, IUnknown)
  private
    FRemoteMachineName: string;
    FEventDispatch: TServerEventDispatch;
    FServerData: PServerData;
    FEventDispatch:     TServerEventDispatch;       // <----- duplicate !!
    FEventsConnection:  Longint;
  protected

After fixing that I get:
Quote
oleserver.pp(164,88) Error: Call by var for arg no. 4 has to match exactly: Got "LongInt" expected "LongWord"
oleserver.pp(170,75) Error: Call by var for arg no. 3 has to match exactly: Got "LongInt" expected "LongWord"
oleserver.pp(210) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted

So I think FEventsConnection should be a LongWord.

How does this compile correctly at your end??
« Last Edit: July 03, 2015, 05:18:05 pm by rvk »

balazsszekely

  • Guest
Re: Any successful experience with SpeechToText API on Windows?
« Reply #14 on: July 03, 2015, 05:18:10 pm »
Quote
http://bugs.freepascal.org/view.php?id=28377
Nice, but you should also implement InterfaceConnect, InterfaceDisconnect in ComObj.  FEventsConnection=> make it DWord instead of LongInt.

 

TinyPortal © 2005-2018