espeak

From Lazarus wiki
Revision as of 06:00, 7 March 2013 by Nsunny (talk | contribs) (Basic Article submitted)

Overview

eSpeak is an open source Text-To-Speech (TTS) engine. It is an artificial speech synthesis software which converts text to audio.

Lazarus or Freepascal has many ways of implementing it. The simplest way is to use sysutils.ExecuteProcess() call to execute eSpeak with command line parameters.


Preparing to use eSpeak

We can either use the installation path of eSpeak (path is retrieved from windows registry) or use a stand alone option (by using a copy of the installation directory). Example of the former can be found here (for Delphi). For the rest of this article we will use the stand-alone option (by using --path parameter).

To get the stand-alone flavor of eSpeak we will have to do the following:

  1. Download and install eSpeak for windows. The file would be named something like: espeak-1.46.02-win.zip
  2. Assuming that you have installed eSpeak in C:\Program Files\eSpeak , copy the eSpeak directory in your freepascal/lazarus project directory.
  3. You may remove some unwanted files or folders such as sourcedict, espeaksapi.dll etc. if you want.

Now remember to add --path parameter when calling eSpeak. For example:

espeak.exe --path=eSpeak "Hello World!"

Coding for Freepascal

uses sysutils

...

var
  ExePath,MyText:String;
begin
  ExePath := 'path\to\espeak\command_line\espeak.exe';
  MyText := 'Hello World!';

  ExecuteProcess(ExePath, ' --path "' + MyText + '"', []);
end;