In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech.
First you need to install the SAPI type library, the type library is attached to this tutorial, into Delphi.
In the Delphi IDE install a new component via the menu:
Component > Install Component... (See Step 1 Image)
Select the 'Into new package' Tab, then click on the 'Browse' button, Select the '.PAS' file included in the type library attachment. (See Step 2 Image)
Create a new package file name such as 'Speech.dpk'. Enter a package description such as 'Windows Speech API'. (See Step 2 Image)
Click on 'OK', when prompted to build then install the package, click on the 'Yes' button. (See Step 3 Image)
You should get a prompt saying that new components have been installed. (See Step 4 Image)
Simple Text To Speech
Create a new application.
Find the 'SpVoice' component, and drag it onto your form. (See Step 5 Image)
Add an edit box and a button to the form and, on the button onclick event handler, enter the following code:
procedure TForm1.Button1Click(Sender: TObject);beginif not (Edit1.Text = '') thenSpVoice1.Speak(Edit1.Text, SVSFDefault);end;