个人工具

UbuntuHelp:TextToSpeech

来自Ubuntu中文

Wikibot讨论 | 贡献2009年5月14日 (四) 17:43的版本

跳转至: 导航, 搜索
  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 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 ~/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_Method 'esdaudio) 1.#3 Save the file. This is recommended method of 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 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.