Difference between revisions of "espeak"

From Lazarus wiki
m
(Some typos/capitalization; added category)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
  
[http://espeak.sourceforge.net/ eSpeak] is an open source Text-To-Speech (TTS) engine. It is an artificial speech synthesis software which converts text to audio. Supports a vast number of [http://espeak.sourceforge.net/languages.html languages]. Further Languages can be developed with the help of [http://espeak.sf.net/download.html espeakedit], a GUI interface for preparing and compiling phoneme data. In Windows, eSpeak implements Microsoft [[SAPI]] (Speech API). Besides windows, it supports Mac and Linux platforms.
+
[http://espeak.sourceforge.net/ eSpeak] is an open source Text-To-Speech (TTS) engine. It is an artificial speech synthesis software which converts text to audio. It supports a vast number of [http://espeak.sourceforge.net/languages.html languages]. Further languages can be developed with the help of [http://espeak.sf.net/download.html espeakedit], a GUI interface for preparing and compiling phoneme data. In Windows, eSpeak implements Microsoft [[SAPI]] (Speech API). Besides Windows, it supports Mac and Linux platforms.
  
Lazarus or Freepascal has many ways of implementing it. The simplest way is to use [http://www.freepascal.org/docs-html/rtl/sysutils/executeprocess.html sysutils.ExecuteProcess()] call to execute eSpeak with command line parameters ([[espeak#Coding for Freepascal|discussed below]]). But this could result in a console window while speaking. A better solution is to use a TProcess (changing properties to poUsePipes and swoHide) to run the commands.
+
Lazarus or Freepascal has many ways of implementing it. The simplest way is to use an [http://www.freepascal.org/docs-html/rtl/sysutils/executeprocess.html sysutils.ExecuteProcess()] call to execute eSpeak with command line parameters ([[espeak#Coding for Freepascal|discussed below]]). But this could result in a console window while speaking. A better solution is to use a TProcess (changing properties to poUsePipes and swoHide) to run the commands.
  
  
Line 20: Line 20:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Speaks the text in female voice (thus f2). There are 7 Male voices (m1 to m7) and 4 female voices (f1 to f4)
+
Speaks the text in female voice (thus f2). There are 7 male voices (m1 to m7) and 4 female voices (f1 to f4)
  
 
<syntaxhighlight lang="dos">
 
<syntaxhighlight lang="dos">
Line 53: Line 53:
 
== Preparing to use eSpeak ==
 
== 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 [http://www.rolfware.de/delphi/espeak_example.html here] (for Delphi). For the rest of this article we will use the stand-alone option (by using <code>--path</code> parameter).
+
We can either use the installation path of eSpeak (path is retrieved from the Windows registry) or use a stand alone option (by using a copy of the installation directory). Example of the former can be found [http://www.rolfware.de/delphi/espeak_example.html here] (for Delphi). For the rest of this article we will use the stand-alone option (by using <code>--path</code> parameter).
  
 
To get the stand-alone flavor of eSpeak we will have to do the following:
 
To get the stand-alone flavor of eSpeak we will have to do the following:
Line 73: Line 73:
 
Free pascal can be used to call the eSpeak command line executable to retrieve spoken words. A simple example is given below:
 
Free pascal can be used to call the eSpeak command line executable to retrieve spoken words. A simple example is given below:
  
<syntaxhighlight lang="pascal">
+
<syntaxhighlight>
 
uses sysutils
 
uses sysutils
  
Line 98: Line 98:
  
 
[[Category:FPC]]
 
[[Category:FPC]]
 +
[[Ca
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]

Revision as of 09:15, 7 March 2013

Overview

eSpeak is an open source Text-To-Speech (TTS) engine. It is an artificial speech synthesis software which converts text to audio. It supports a vast number of languages. Further languages can be developed with the help of espeakedit, a GUI interface for preparing and compiling phoneme data. In Windows, eSpeak implements Microsoft SAPI (Speech API). Besides Windows, it supports Mac and Linux platforms.

Lazarus or Freepascal has many ways of implementing it. The simplest way is to use an sysutils.ExecuteProcess() call to execute eSpeak with command line parameters (discussed below). But this could result in a console window while speaking. A better solution is to use a TProcess (changing properties to poUsePipes and swoHide) to run the commands.


Using eSpeak command line

These are some simple examples of using the eSpeak command line. To use this Download and install eSpeak. Then open the command prompt and run cd C:\Program Files\eSpeak\command_line\ then run the commands below:

espeak "Hello World!"

This is the simplest command. Speaks "Hello World!"

espeak -v +f2 "Hello World!"

Speaks the text in female voice (thus f2). There are 7 male voices (m1 to m7) and 4 female voices (f1 to f4)

espeak -v fr+f2 "Bonjour tout le monde"

Speaks the text in French accent and in a female voice.

espeak -g 10 "I have something to say."

Pauses for 10 milliseconds between words. A better understandable option.

espeak -s 400 "I have something to say."

Speaks fluently! The -s (speed) parameter could be 80 to 450. Default is 175.

espeak -v +whisper "I have something secret to say!"

Speaks the text as if in your ear!! (Notice the +whisper part.)


More details about command line parameters can be found here: http://espeak.sourceforge.net/commands.html


Preparing to use eSpeak

We can either use the installation path of eSpeak (path is retrieved from the 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.
  4. Optionally, you may uninstall eSpeak (if you don't want to use the eSpeak installation).

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

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


Coding for Freepascal

Free pascal can be used to call the eSpeak command line executable to retrieve spoken words. A simple example is given below:

uses sysutils

...

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

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

Here only --path parameter is used. There are other parameters that can speak a text file; set the volume, pitch, speed (words per minute), word gap etc. Info about command line parameters can be found here: http://espeak.sourceforge.net/commands.html


Coding for Lazarus

For a tutorial, please see here: http://www.lazarus.freepascal.org/index.php/topic,20153.0.html Or here: http://inkoflife.blogspot.com/2013/03/let-your-software-speak.html [[Ca