Lisp HUG Maillist Archive

Speech SDK

Bruce Weimar asked recently about calling the
Microsoft Speech API from within Lispworks for
Windows.  I can't make it work and here is what I
found:

There is a web demo in the Speech SDK. The crucial
parts seem to be:

<SCRIPT LANGUAGE="JavaScript">

// Create the Sapi SpVoice object
var VoiceObj = new ActiveXObject("Sapi.SpVoice");
....
// Speak the string in the edit box
  try
    {
	VoiceObj.Speak( idTextBox.value, 1 );
    }
  catch(exception)
    {
	alert("Speak error");
    }
</SCRIPT>

<SCRIPT FOR="window" EVENT="OnQuit()"
LANGUAGE="JavaScript">
	// Clean up voice object
	delete VoiceObj;
</SCRIPT>

Doesn't seem like a whole lot, does it? Heh. I go to
the LWW COM manual and...

(require "com")
<many messages>
(com:midl "sapi.idl")
<many messages and then...>

Error: [c:\cygwin\home\owner\temp\sapi.idl:971]:
Unexpected symbol "struct"
Skipping rest of statement.

Line 971 and following is:

[hidden] struct SPPHRASERULE
{
    const WCHAR *           pszName;


I comment out the structs that begin with [hidden] but
then I get in trouble with sapiaut.idl (I did not
specifically request sapiaut.idl, it is used in
spapi.idl):

Error: [c:\cygwin\home\owner\temp\sapiaut.idl:13]:
Unexpected symbol "import"
Skipping rest of statement.

Line 13 is the first import below:

//  Includes                
import "oaidl.idl";
import "ocidl.idl";

If I try sapiaut.idl by itself:

(com:midl "sapiaut.idl")

I get:

Error: [c:\cygwin\home\owner\temp\sapiaut.idl:99]:
Unexpected symbol "HKEY_CURRENT_USER"
Skipping rest of statement.

I don't think that approach is giving results so I try
automation. We have to have a type library (tlb),
which doesn't seem to come with the SDK, so I:

$ midl /proxy nul /header nul /iid nujl /dlldata nul
/win32 sapiaut.idl

and get sapiaut.tlb, which I copy to the appropriate
directory. I create a system file containing:

(defpackage "speech"
  (:use "COMMON-LISP")
  (:export "SAY"))

(defsystem speech-system
    (:default-pathname "c:/my/lisp/projects/"
     :default-type :lisp-file)
  :members
  (("sapi.lib" :type :midl-type-library-file)
   "speech"))

and in the listener I try:

(require "com")
(require "automation")

(load "speech.system")
<goes OK>

(compile-system 'speech-system)

;;; Compiling type library
c:\my\lisp\projects\sapi.tlb.


**++++ Error between functions:
  #<function COM::MAKE-COCLASS-DESCRIPTOR 21CCE53A> 

is called with unknown keyword :RESTRICTED 

amoung the arguments 

(:NAME SP-NOTIFY-TRANSLATOR 
 :INTERFACES 
  ((:INTERFACE I-SP-NOTIFY-TRANSLATOR 
   (:DEFAULT T))) 
 :TYPE-LIBRARY SPEECH-LIB   
 :HELPSTRING  "SpNotify" :HELPCONTEXT 0 
 :UUID "E2AE5372-5D40-11D2-960E-00C04F8EE628" 
 :FOREIGN-NAME "SpNotifyTranslator" 
 :HIDDEN T :RESTRICTED T) 

which is not one of 

(:NAME :FOREIGN-NAME 
 :TYPE-LIBRARY :INTERFACES :APPOBJECT 
 :HELPSTRING :HELPCONTEXT :LICENSED 
 :VERSION :CONTROL :HIDDEN :UUID 
 :NONCREATABLE :AGGREGATABLE).

; *** 1 error detected, no fasl file produced.

I'll appreciate any tips.

Thanks,

Jeff

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com


Updated at: 2020-12-10 09:00 UTC