Difference between revisions of "espeak"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "== Overview == eSpeak is a text-to-speech (TTS) engine. It converts text to audio. == Sample == to do fill in Category:FPC Category:Tutorials")
 
(Expanded espial description; fixed syntax highlighting; added link to Speech Synthesis meta page)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
eSpeak is a text-to-speech (TTS) engine. It converts text to audio.
 
  
== Sample ==
+
[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.
to do fill in
+
 
 +
eSpeak does text to speech synthesis for the following languages, some better than others: Afrikaans, Albanian, Aragonese, Armenian, Bulgarian, Cantonese, Catalan, Croatian, Czech, Danish, Dutch, English, Esperanto, Estonian, Farsi, Finnish, French, Georgian, German, Greek, Hindi, Hungarian, Icelandic, Indonesian, Irish, Italian, Kannada, Kurdish, Latvian, Lithuanian, Lojban, Macedonian, Malaysian, Malayalam, Mandarin, Nepalese, Norwegian, Polish, Portuguese, Punjabi, Romanian, Russian, Serbian, Slovak, Spanish, Swahili, Swedish, Tamil, Turkish, Vietnamese, Welsh.
 +
 
 +
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.
 +
 
 +
== Using eSpeak command line ==
 +
 
 +
These are some simple examples of using the eSpeak command line. To use this [http://espeak.sourceforge.net/download.html Download] and install eSpeak. Then open the command prompt and run <code>cd C:\Program Files\eSpeak\command_line\</code> then run the commands below:
 +
 
 +
<syntaxhighlight lang="dos">
 +
espeak "Hello World!"
 +
</syntaxhighlight>
 +
 
 +
This is the simplest command. Speaks "Hello World!"
 +
 
 +
<syntaxhighlight lang="dos">
 +
espeak -v +f2 "Hello World!"
 +
</syntaxhighlight>
 +
 
 +
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">
 +
espeak -v fr+f2 "Bonjour tout le monde"
 +
</syntaxhighlight>
 +
 
 +
Speaks the text in French accent and in a female voice.
 +
 
 +
<syntaxhighlight lang="dos">
 +
espeak -g 10 "I have something to say."
 +
</syntaxhighlight>
 +
 
 +
Pauses for 10 milliseconds between words. A better understandable option.
 +
 
 +
<syntaxhighlight lang="dos">
 +
espeak -s 400 "I have something to say."
 +
</syntaxhighlight>
 +
 
 +
Speaks fluently! The -s (speed) parameter could be 80 to 450. Default is 175.
 +
 
 +
<syntaxhighlight lang="dos">
 +
espeak -v +whisper "I have something secret to say!"
 +
</syntaxhighlight>
 +
 
 +
Speaks the text as if in your ear!! (Notice the <code>+whisper</code> 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 [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:
 +
# [http://espeak.sourceforge.net/download.html Download] and install eSpeak for windows. The file would be named something like: espeak-1.46.02-win.zip
 +
# Assuming that you have installed eSpeak in <code>C:\Program Files\eSpeak</code> , copy the eSpeak directory in your freepascal/lazarus project directory.
 +
# You may remove some unwanted files or folders such as sourcedict, espeaksapi.dll etc. if you want.
 +
# Optionally, you may uninstall eSpeak (if you don't want to use the eSpeak installation).
 +
 
 +
Now remember to add <code>--path</code> parameter when calling eSpeak. For example:
 +
 
 +
<syntaxhighlight lang="dos">
 +
espeak.exe --path=eSpeak "Hello World!"
 +
</syntaxhighlight>
 +
 
 +
== Coding for Free Pascal ==
 +
 
 +
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">
 +
uses sysutils
 +
 
 +
...
 +
 
 +
var
 +
  ExePath,MyText:String;
 +
begin
 +
  ExePath := 'path\to\espeak\command_line\espeak.exe';
 +
  MyText := 'Hello World!';
 +
 
 +
  ExecuteProcess(ExePath, ' --path=eSpeak "' + MyText + '"', []);
 +
</syntaxhighlight>
 +
 
 +
Here only <code>--path</code> 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
 +
 
 +
== See also ==
 +
 
 +
* [[Speech Synthesis]] for cross-platform and native operating system speech synthesis solutions.
  
 
[[Category:FPC]]
 
[[Category:FPC]]
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]
 +
[[Category:Speech synthesis]]

Latest revision as of 01:22, 19 December 2019

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.

eSpeak does text to speech synthesis for the following languages, some better than others: Afrikaans, Albanian, Aragonese, Armenian, Bulgarian, Cantonese, Catalan, Croatian, Czech, Danish, Dutch, English, Esperanto, Estonian, Farsi, Finnish, French, Georgian, German, Greek, Hindi, Hungarian, Icelandic, Indonesian, Irish, Italian, Kannada, Kurdish, Latvian, Lithuanian, Lojban, Macedonian, Malaysian, Malayalam, Mandarin, Nepalese, Norwegian, Polish, Portuguese, Punjabi, Romanian, Russian, Serbian, Slovak, Spanish, Swahili, Swedish, Tamil, Turkish, Vietnamese, Welsh.

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 Free Pascal

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

See also

  • Speech Synthesis for cross-platform and native operating system speech synthesis solutions.