个人工具

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

来自Ubuntu中文

跳转至: 导航, 搜索
 
(未显示2个用户的6个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/TextToSpeech}}
 
{{From|https://help.ubuntu.com/community/TextToSpeech}}
 
{{Languages|UbuntuHelp:TextToSpeech}}
 
{{Languages|UbuntuHelp:TextToSpeech}}
#title Text-to-Speech
+
#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.  
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) out of the box, so some changes are required to get it up and running.
+
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.
 
+
This guide provides instructions on how to get Festival working on Ubuntu with ESD. 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.
+
 
+
 
== Installation ==
 
== Installation ==
 +
Install Festival by typing the following command in a Terminal:
 +
<code><nowiki>sudo apt-get install festival</nowiki></code>
 +
'''Note:''' Additional voices are available in the Ubuntu repositories. Type "festvox" in ''Synaptic Package Manager'' for a list of language packages.
 +
== Configuration for ESD or PulseAudio ==
 +
If you want festival to always use ESD or PulseAudio 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 ''~/.festivalrc''.
 +
<ol><li>Open the configuration file by typing <code><nowiki>gksudo gedit /etc/festival.scm</nowiki></code> or <code><nowiki>gedit ~/.festivalrc</nowiki></code> in a terminal.
 +
</li><li>Add the following lines at the end of the file:</li></ol>
  
* Install Festival by typing the following command in a Terminal:
+
<code><nowiki>(Parameter.set 'Audio_Method 'esdaudio)</nowiki></code>
<pre><nowiki>sudo apt-get install festival
+
1.#3 Save the file.
</nowiki></pre>
+
This is the recommended method for playing audio in Ubuntu.
*#2 Install ''esdplay'', which is part of the ''esound-clients'' package:
+
== Configuration for ALSA ==
<pre><nowiki>sudo apt-get install esound-clients
+
'''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.
</nowiki></pre>
+
Insert at the end of the file <code><nowiki>/etc/festival.scm or ~/.festivalrc</nowiki></code> the lines
 
+
<pre><nowiki>
'''Note:''' Additional voices are available in the Ubuntu respositories. Type "festival" in ''Synaptic Package Manager'' for a list of packages.
+
(Parameter.set 'Audio_Command "aplay -D plug:dmix -q -c 1 -t raw -f s16 -r $SR $FILE")
 
+
== Configuration ==
+
 
+
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.
+
 
+
* Open the file ''/etc/festival.scm'' by typing <code><nowiki>gksudo gedit /etc/festival.scm</nowiki></code> in a Terminal.
+
* Add the following lines at the end of the file:
+
<pre><nowiki>(Parameter.set 'Audio_Command "esdplay $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>
*#3 Save the file.
+
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 <code><nowiki>festival</nowiki></code> in a Terminal.
+
<code><nowiki>festival</nowiki></code>
* You will be presented with a ''>'' prompt. Type <code><nowiki>(Say``Text "Hello"</nowiki></code>.
+
You will be presented with a ''>'' prompt. Type  
* The computer should say "hello".
+
<code><nowiki>(SayText "Hello")</nowiki></code>
* To listen to a text file type <code><nowiki>(tts "FILENAME" nil)</nowiki></code>. ''FILENAME'' must be in quote marks.
+
The computer should say "hello".
 +
To listen to a text file named ''FILENAME'', type  
 +
<code><nowiki>(tts "FILENAME" nil)</nowiki></code>
 +
Note ''FILENAME'' must be in quote marks.
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2009年11月17日 (二) 20:47的最新版本

  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 repositories. Type "festvox" in Synaptic Package Manager for a list of language packages.

Configuration for ESD or PulseAudio

If you want festival to always use ESD or PulseAudio 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 ~/.festivalrc.

  1. Open the configuration file by typing gksudo gedit /etc/festival.scm or gedit ~/.festivalrc in a terminal.
  2. Add the following lines at the end of the file:

(Parameter.set 'Audio_Method 'esdaudio) 1.#3 Save the file. This is the recommended method for playing audio in Ubuntu.

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 at the end of the file /etc/festival.scm or ~/.festivalrc 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.