语音02_Delphi

网址 :http://www.exceletel.com/support/whtpapers/speech/delphi.htm

Installing the Microsoft SAPI speech SDK in Delphi

After you install the SAPI 5.1 SDK available from Microsoft by clicking HERE, you will find that it gives you most of the important methods, events, types and constants through a registered type library.  This means that you can access SAPI 5.1 functionality through late bound or early bound Automation. 

From the Delphi menu select "Project | Import Type Library" and select "Microsoft Speech Object Library (Version 5.1) from the list of type libraries.

Check the "Generate Component Wrapper" checkbox.  This will give you component wrapper classes for the Automation objects listed in the file.  Create a new page called "SAPI 5.1" so that the created components will go on their own Component Palette.

Click on the Install button to automatically import the library and place the components on your SAPI 5.1 palette.

You will now have a file called SpeechLib_TLB.pas that you can reference to see all the classes and definitions which will be of help when you need to see how to convert types or see how a function is implemented.  You can create a new package for the resulting new components or use the default, "Borland User Components".


Here is the Install dialog showing the default.  You can click on the "into new package" tab and insert your own filename if you like.

Next click on the "Component | Install Packages" menu item and you will see the dialog box to the right.  Find your package, in this case the default where we added the SAPI 5.1 components to the Borland User Components Package.  Make sure your package is checked and press the "OK" button.


When you are done, you will see 19 new components on your SAPI 5.1 palette page!  Each of these components makes it easy to drop on your forms and access the interface associate with it.  You will see the TSpVoice component which we use in the sample programs to do the speaking with SpVoice events, methods and properties.  There are also the SpMMAudioOut component that lets us link a speech stream to a windows audio output device and SpAudioFormat which lets us control wave formats.  They don't seem to come with unique icons, which makes it hard to tell them apart from each other without getting hover help or memorizing their position in the list, but it sure is nice to have them componentized.

If you look in the Delphi 5, 6 and 7 folders under SAPI 5.1 you will find the component packages for each of these versions.  NOTE:  Delphi 6 had a bug that causes it to not to be able to import the type library properly, so you will have to create it in another version of Delphi and copy it in yourself.

Back to speech page...

X

原文地址:https://www.cnblogs.com/CodeSkill/p/5851820.html