个人工具

“UbuntuHelp:TextToSpeech”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第2行: 第2行:
 
{{Languages|UbuntuHelp:TextToSpeech}}
 
{{Languages|UbuntuHelp:TextToSpeech}}
 
#title Festival - Text-to-Speech
 
#title Festival - Text-to-Speech
You can take advantage of Text-To-Speech in Ubuntu by using a program called ''Festival''. Festival doesn't work with ESD (the default sound mixer) or ALSA out of the box, so some changes are required to get it up and running.
+
You can take advantage of Text-To-Speech in Ubuntu by using a program called ''Festival''. Out of the box, Festival doesn't work with ESD (the default sound server up to Gutsy), Pulse``Audio (the default sound server since Hardy) or ALSA, so some changes are required to get it up and running.
This guide provides instructions on how to get Festival working on Ubuntu with ESD or ALSA.  
+
This guide provides instructions on how to get Festival working on Ubuntu with ESD, Pulse``Audio and ALSA.  
If you don't use Festival with ESD, you will have to disable ESD in the ''Sounds'' preferences dialog. In that case, other multimedia applications won't be able to play audio at the same time.
+
If you are using a version of Ubuntu prior to Hardy, and you don't want to use Festival with ESD, you will have to disable ESD in the ''Sounds'' preferences dialog. In that case, other multimedia applications won't be able to play audio at the same time.
 
== Installation ==
 
== Installation ==
 
Install Festival by typing the following command in a Terminal:
 
Install Festival by typing the following command in a Terminal:
第10行: 第10行:
 
'''Note:''' Additional voices are available in the Ubuntu respositories. Type "festvox" in ''Synaptic Package Manager'' for a list of language packages.
 
'''Note:''' Additional voices are available in the Ubuntu respositories. Type "festvox" in ''Synaptic Package Manager'' for a list of language packages.
 
== Configuration for ESD ==
 
== Configuration for ESD ==
Install ''esdplay'', which is part of the ''esound-clients'' package:
+
Install ''esdplay'' and ''esddsp'', which are part of the ''esound-clients'' package:
 
<code><nowiki>sudo apt-get install esound-clients</nowiki></code>
 
<code><nowiki>sudo apt-get install esound-clients</nowiki></code>
You need to configure festival so that it sends its output through ESD. Otherwise, you will get a ''can't open /dev/dsp'' error when you try to run Festival.
+
If you'd like to use ESD for output on a per-run basis, you can run festival through the esddsp wrapper script. Using this approach, the wrapper must be called every time you run festival, or else you will get an error message saying ''can't open /dev/dsp''.
<ol><li>Open the file ''/etc/festival.scm'' by typing <code><nowiki>gksudo gedit /etc/festival.scm</nowiki></code> in a Terminal.
+
<code><nowiki>esddsp festival</nowiki></code>
 +
If you want festival to always use ESD for output, you can configure this globally, for all users, or on a per-user basis. To configure globally use the configuration file ''/etc/festival.scm''. To configure locally use the configuration file ''~/festival.scm''.
 +
<ol><li>Open the configuration file by typing <code><nowiki>gksudo gedit /etc/festival.scm</nowiki></code> or <code><nowiki>gksudo gedit ~/festival.scm</nowiki></code> in a terminal.
 
</li><li>Add the following lines at the end of the file:</li></ol>
 
</li><li>Add the following lines at the end of the file:</li></ol>
  
<pre><nowiki>(Parameter.set 'Audio_Command "esdplay $FILE")
+
<pre><nowiki>
 +
(Parameter.set 'Audio_Command "esdplay $FILE")
 +
(Parameter.set 'Audio_Method 'Audio_Command)
 +
(Parameter.set 'Audio_Required_Format 'snd)</nowiki></pre>
 +
1.#3 Save the file.
 +
== Configuration for PulseAudio ==
 +
'''Note:''' Festival may work with Pulse``Audio out of the box. If so, nothing further needs to be done and this section can be skipped.
 +
Install ''paplay'' and ''padsp'', which are part of the ''pulseaudio-utils'' package:
 +
<code><nowiki>sudo apt-get install pulseaudio-utils</nowiki></code>
 +
If you'd like to use Pulse``Audio for output on a per-run basis, you can run festival through the padsp wrapper script. Using this approach, the wrapper must be called every time you run festival, or else you will get an error message saying ''can't open /dev/dsp''.
 +
<code><nowiki>padsp festival</nowiki></code>
 +
If you want festival to always use Pulse``Audio for output, you can configure this globally, for all users, or on a per-user basis. To configure globally use the configuration file ''/etc/festival.scm''. To configure locally use the configuration file ''~/festival.scm''.
 +
<ol><li>Open the configuration file by typing <code><nowiki>gksudo gedit /etc/festival.scm</nowiki></code> or <code><nowiki>gksudo gedit ~/festival.scm</nowiki></code> in a terminal.
 +
</li><li>Add the following lines at the end of the file:</li></ol>
 +
 
 +
<pre><nowiki>
 +
(Parameter.set 'Audio_Command "paplay $FILE")
 
(Parameter.set 'Audio_Method 'Audio_Command)
 
(Parameter.set 'Audio_Method 'Audio_Command)
 
(Parameter.set 'Audio_Required_Format 'snd)</nowiki></pre>
 
(Parameter.set 'Audio_Required_Format 'snd)</nowiki></pre>
 
1.#3 Save the file.
 
1.#3 Save the file.
 
== Configuration for ALSA ==
 
== Configuration for ALSA ==
('''Note''' it is hard to use ALSA and ESD on the same system, if it is possible at all.  Here it is assumed that you are using ALSA ''instead of'' ESD.)
+
'''Note:''' It is hard to use ALSA and ESD on the same system, if it is possible at all.  Here it is assumed that you are using ALSA ''instead of'' ESD.
 
Insert of the end of the file <code><nowiki>/etc/festival.scm</nowiki></code> the lines
 
Insert of the end of the file <code><nowiki>/etc/festival.scm</nowiki></code> the lines
<pre><nowiki>(Parameter.set 'Audio_Command "aplay -D plug:dmix -q -c 1 -t raw -f s16 -r $SR $FILE")
+
<pre><nowiki>
 +
(Parameter.set 'Audio_Command "aplay -D plug:dmix -q -c 1 -t raw -f s16 -r $SR $FILE")
 
(Parameter.set 'Audio_Method 'Audio_Command)
 
(Parameter.set 'Audio_Method 'Audio_Command)
 
(Parameter.set 'Audio_Required_Format 'snd)</nowiki></pre>
 
(Parameter.set 'Audio_Required_Format 'snd)</nowiki></pre>
Some sources leave off the <code><nowiki>-D plug:dmix </nowiki></code>; maybe that works for older systems, but it didn't work in my Feisty.
+
On some configurations it may be necessary to remove the "-D plug:dmix" part of the aplay command above.
 
== Testing ==
 
== Testing ==
 
Test your setup by typing in a Terminal
 
Test your setup by typing in a Terminal

2009年5月12日 (二) 19:06的版本

  1. title Festival - Text-to-Speech

You can take advantage of Text-To-Speech in Ubuntu by using a program called Festival. Out of the box, Festival doesn't work with ESD (the default sound server up to Gutsy), Pulse``Audio (the default sound server since Hardy) or ALSA, so some changes are required to get it up and running. This guide provides instructions on how to get Festival working on Ubuntu with ESD, Pulse``Audio and ALSA. If you are using a version of Ubuntu prior to Hardy, and you don't want to use Festival with ESD, you will have to disable ESD in the Sounds preferences dialog. In that case, other multimedia applications won't be able to play audio at the same time.

Installation

Install Festival by typing the following command in a Terminal: sudo apt-get install festival Note: Additional voices are available in the Ubuntu respositories. Type "festvox" in Synaptic Package Manager for a list of language packages.

Configuration for ESD

Install esdplay and esddsp, which are part of the esound-clients package: sudo apt-get install esound-clients If you'd like to use ESD for output on a per-run basis, you can run festival through the esddsp wrapper script. Using this approach, the wrapper must be called every time you run festival, or else you will get an error message saying can't open /dev/dsp. esddsp festival If you want festival to always use ESD for output, you can configure this globally, for all users, or on a per-user basis. To configure globally use the configuration file /etc/festival.scm. To configure locally use the configuration file ~/festival.scm.

  1. Open the configuration file by typing gksudo gedit /etc/festival.scm or gksudo gedit ~/festival.scm in a terminal.
  2. Add the following lines at the end of the file:
(Parameter.set 'Audio_Command "esdplay $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Required_Format 'snd)

1.#3 Save the file.

Configuration for PulseAudio

Note: Festival may work with Pulse``Audio out of the box. If so, nothing further needs to be done and this section can be skipped. Install paplay and padsp, which are part of the pulseaudio-utils package: sudo apt-get install pulseaudio-utils If you'd like to use Pulse``Audio for output on a per-run basis, you can run festival through the padsp wrapper script. Using this approach, the wrapper must be called every time you run festival, or else you will get an error message saying can't open /dev/dsp. padsp festival If you want festival to always use Pulse``Audio for output, you can configure this globally, for all users, or on a per-user basis. To configure globally use the configuration file /etc/festival.scm. To configure locally use the configuration file ~/festival.scm.

  1. Open the configuration file by typing gksudo gedit /etc/festival.scm or gksudo gedit ~/festival.scm in a terminal.
  2. Add the following lines at the end of the file:
(Parameter.set 'Audio_Command "paplay $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Required_Format 'snd)

1.#3 Save the file.

Configuration for ALSA

Note: It is hard to use ALSA and ESD on the same system, if it is possible at all. Here it is assumed that you are using ALSA instead of ESD. Insert of the end of the file /etc/festival.scm the lines

(Parameter.set 'Audio_Command "aplay -D plug:dmix -q -c 1 -t raw -f s16 -r $SR $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Required_Format 'snd)

On some configurations it may be necessary to remove the "-D plug:dmix" part of the aplay command above.

Testing

Test your setup by typing in a Terminal festival You will be presented with a > prompt. Type (SayText "Hello") The computer should say "hello". To listen to a text file named FILENAME, type (tts "FILENAME" nil) Note FILENAME must be in quote marks.