Speech Dispatcher
repository·master·Indexed 43 days ago
https://github.com/brailcom/speechdA device-independent abstraction layer for speech synthesis that provides a stable interface between client applications and various Text-to-Speech (TTS) engines. It utilizes a client/server model and the Speech Synthesis Interface Protocol (SSIP) to support a wide range of engines including eSpeak-NG, Festival, and Piper, as well as multiple sound output subsystems like PulseAudio and PipeWire.
What's inside Speech Dispatcher
- Speech Dispatcher provides a high-level, device-independent layer for accessing speech synthesis. It acts as a common interface between client applications and various speech synthesis engines (TTS), allowing developers to write applications that work with any supported synthesizer without needing to handle specific engine implementations.
Develop Speech Synthesis Modules
masterSpeech synthesis backends can be integrated as modules. The interface between the
speechdserver and the syntheses is a pipe between processes using a simple protocol. This allows integration of C libraries, external commands, or HTTP services.To simplify module development, a
libspeechd_modulelibrary is provided under a BSD-2 license. For more details, refer to the Output Modules documentation.Understand the Speech Dispatcher architecture
masterSpeech Dispatcher operates on a client/server model.
- Server: Manages concurrent synthesis requests, handles sound output, and resolves conflicts/priorities between incoming requests. It maintains independent state (context switching) for each client connection.
- Clients: Applications that want to produce speech (e.g., assistive technologies). Clients communicate with the server via a Unix socket or Inet TCP connection using the Speech Synthesis Interface Protocol (SSIP).
This architecture allows applications to avoid direct device management, concurrent access handling, and complex sound output logic, acting as a high-level abstraction layer for speech synthesis.
Format C code using GNU indent
masterTo ensure compliance with the Speech Dispatcher coding style, use
indent(version 2.2.10 or later) with the following flags. If using a version older than 2.2.10, omit the-il0flag.indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1 -il0Configure voice and synthesizer settings
masterVoice settings can be configured at three levels, with higher levels overriding lower ones:
- Client Application (e.g., Orca, speechd-el): Highest priority.
- User Level: Settings in
~/.config/speech-dispatcher/spd.conf. - System Level: Settings in
/etc/speech-dispatcher/speechd.conf.
System Configuration
The system-level file
/etc/speech-dispatcher/speechd.confdefines the default:- Synthesizer
- Voice type or symbolic name (e.g.,
MALE1) - Default language
- Default voice parameters:
rate,pitch,pitch range, andvolume.
User Configuration
Use the
spd-confapplication to modify settings.spd-confcan set the synthesizer, language, and voice parameters (rate, pitch, etc.), but it cannot select a specific voice directly.Selecting a Specific Voice
To select a specific voice (e.g., 'bob' or 'viginie'), you must do so from the client application. The client selects from a list provided by the chosen synthesizer. Voice names may include locale codes, such as
(fr-FR)for French from France.Coding Style for non-C components
masterFor components written in languages other than C, please respect the existing coding style established within that specific component.Import symbols dictionaries
masterTo import symbols dictionaries into Speech-Dispatcher, follow these steps to gather the necessary source files and run the import process:
- Prerequisites:
- Ensure
gettextversion 0.20 or later is installed. - Install the latest version of
orcamaster manually.
- Ensure
- Gather Source Files:
- NVDA: Download the NVDA sources (e.g., from
https://github.com/nvaccess/nvda/archive/beta.zip), extract them, and place them in thelocale/symbolsrc/nvda-betasub-directory. - CLDR: Download the latest Unicode CLDR release (
cldr-common-<version>.zip) fromhttps://unicode.org/Public/cldr/latestand extract it intolocale/symbolsrc/cldr. - UnicodeData.txt: Download
UnicodeData.txtfromftp://ftp.unicode.org/Public/UCD/latest/ucd/UnicodeData.txtand place it directly in thelocale/symbolsrcdirectory.
- NVDA: Download the NVDA sources (e.g., from
- Run Import:
Navigate to the
localedirectory and execute the make command:make import-symbols - Register New Dictionaries:
If new dictionaries are generated, you must register them in the
Makefile.amfile located in thelocaledirectory. Add the new files to thenobase_localedata_DATAvariable using the following syntax (ensure a tab character precedes the entry and maintain alphabetical order):lang/file.dic \
make import-symbols- Prerequisites:
Coding Style Guidelines for C Code
masterAll contributions to Speech Dispatcher must follow these C coding standards. The project uses an indentation style similar to the Linux kernel with specific naming conventions:
Naming Conventions
- Functions: lowercase words separated by underscores (e.g.,
my_function_name). Functions that are implementation details within a single source file must be declared asstatic. - Variables:
- Global variables: Follow function naming conventions (e.g.,
output_modules). - Local variables: Verbosity should be appropriate to the variable's scope.
- Global variables: Follow function naming conventions (e.g.,
- Macros: Uppercase words separated by underscores (e.g.,
SPEECHD_OPTION_CB_STR). - Types: Mixed case (e.g.,
MessageType).
Logic
gotostatements should be avoided unless required by very special cases.
- Functions: lowercase words separated by underscores (e.g.,
Access Documentation for Speech Dispatcher
masterDetailed documentation is available in the
doc/directory or online:- Speech Dispatcher Core:
doc/speech-dispatcher.html - spd-say CLI:
doc/spd-say.html - SSIP Protocol:
doc/ssip.html - Python Bindings: Use
pydoc3 speechd(orpydoc speechd) on your shell, or view the speechd.client module documentation online. - General Overview: See
README.overview.mdfor features, supported engines, and troubleshooting.
- Speech Dispatcher Core:
Run a local instance of Speech Dispatcher for testing
masterIf you have built Speech Dispatcher from source and want to test it without installing it (to avoid interfering with an existing instance), you can run the server in a dedicated mode.
To run the server:
./run-speechd -t 0 -sTo use the
spd-sayclient with this instance in another terminal:./run-spd-say fooTo make other clients connect to your dedicated instance, export the
SPEECHD_ADDRESSenvironment variable:export SPEECHD_ADDRESS=inet_socket:127.0.0.1:6561If you also want clients to use the just-built
libspeechdlibrary, update yourLD_LIBRARY_PATH:export LD_LIBRARY_PATH=$PWD/src/api/c/.libsOverview of the Python interface to SSIP
masterThis project provides a Python interface to the Speech Dispatcher Simple Interface Protocol (SSIP). It implements the full range of SSIP commands and includes support for callback handling. For detailed technical specifications of the available commands, refer to the "Python API" section in the official Speech Dispatcher documentation.Use the Speaker class for convenient speech control
masterWhileSSIPClientmaps directly to SSIP commands, theSpeakerclass (implied in the module documentation) provides a more convenient, high-level interface for common speech tasks like speaking text, characters, or keys.