Skip to content

Commit

Permalink
Add libspeechd-module library
Browse files Browse the repository at this point in the history
for making it simpler to create external spd modules.

Fixes #918
  • Loading branch information
sthibaul committed May 12, 2024
1 parent 61d45b9 commit 5f4f5a5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 26 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Version 0.12 (unreleased)
* Add openjtalk module.
* Add socket activation.
* Add language and variant parameters to "list voice" command.
* Add libspeechd-module library for making it simpler to create external spd modules.
* libspeechd: Simplify buffer management.
* Fix use of semaphores on MacOS.
* Fix splitting long UTF-8 sequences.
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ that GPL licensing propagation doesn't apply.

The speech modules are connected to the central server through a pipe with
a very simple protocol similar to SSIP, in such a way that GPL licensing
propagation doesn't apply either. To make writing speech modules simpler, some
module helpers are provided under a BSD-2 license, which can thus be combined
with essentially any other license. Some more advanced module helpers are also
provided under LGPLv2.1-or-later, but they are not mandatory.
propagation doesn't apply either.

To make writing speech modules simpler, a libspeechd_module library is provided
under a BSD-2 license, which can thus be combined with essentially any other
license.

Some more advanced module helpers are also provided under LGPLv2.1-or-later, but
they are not mandatory.



Expand Down
14 changes: 8 additions & 6 deletions doc/speech-dispatcher.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions doc/speech-dispatcher.texi
Original file line number Diff line number Diff line change
Expand Up @@ -3044,10 +3044,9 @@ ways to do it.
Either you can program it all yourself, which is fine as long as you stick to
the definition of an output module and its communication protocol.

You can also use our @file{module_main.c}, @file{module_readline.c},
@file{module_process.c}, and @file{module_main.h}, which deal with the
You can also use our @file{libspeechd_module} library, which deals with the
communication protocol and other formal things that are common for all modules.
They are provided under a BSD licence and thus allow to integrate them along
It is provided under a BSD license and thus allows to integrate it along
proprietary software. You will have to provide a series of functions, an example
is provided in @code{src/modules/skeleton0.c}, which can freely serve as a basic
for your module. You can also read @code{src/modules/skeleton0_espeak-ng*.c},
Expand Down Expand Up @@ -3093,9 +3092,8 @@ If you go for the BSD-provided skeleton way, you can start
with @code{skeleton0.c}. Add the synthesis initialization call
with default parameters to @code{module_init}, the synchronous
synthesizing call to @code{module_speak_sync}, and the synthesis
shutdown call to @code{module_close}. Compile this along
@file{module_main.c}, @file{module_readline.c}, @file{module_process.c}, and
@file{module_main.h}. Install this along other modules, and create an empty
shutdown call to @code{module_close}. Link this with
@file{libspeechd-module}. Install this along other modules, and create an empty
configuration file for it. This should already provide you with a working
module, though with very limited support.

Expand Down Expand Up @@ -3187,6 +3185,10 @@ accordingly.
@node The Skeleton of an Output Module, Output Module Functions, How to Write New Output Module, Output Modules
@subsection The Skeleton of an Output Module

The previous section documented how to write an output module in general. In this
section, we document the preferred way for writing modules to be shipped with
speech-dispatcher.

Each output module should include @file{module_utils.h} where the
SPDMsgSettings structure is defined to be able to handle the different
speech synthesis settings. This file also provides tools which help
Expand Down
1 change: 1 addition & 0 deletions src/modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/TAGS
/dummy-message.wav
/libbaratinoo.so
/libspeechd_module.la
/libvoxin.so
/sd_baratinoo
/sd_cicero
Expand Down
31 changes: 21 additions & 10 deletions src/modules/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EXTRA_DIST = baratinoo_shim.c README.baratinoo
EXTRA_DIST += kali_Kali_shim.cpp kali_KGlobal_shim.cpp kali_KTrans_shim.cpp kali_KParle_shim.cpp kali_KAnalyse_shim.cpp
EXTRA_DIST += ibmtts_shim.c eci.h
EXTRA_DIST += voxin_shim.c voxin.h
EXTRA_DIST += module_main.h module_utils.h
EXTRA_DIST += module_utils.h
EXTRA_DIST += dummy-message-default.wav
EXTRA_DIST += dummy-message.txt
CLEANFILES = dummy-message.wav
Expand All @@ -37,6 +37,15 @@ AM_CFLAGS = $(ERROR_CFLAGS)
AM_CXXFLAGS = $(ERROR_CFLAGS)
AM_CPPFLAGS = $(inc_local) -DDATADIR=\"$(snddatadir)\" $(GLIB_CFLAGS)

#
# This is the BSD-licensed helper library that people can use to create their
# own speech-dispatcher module
#
spdinclude_HEADERS = module_main.h
lib_LTLIBRARIES = libspeechd_module.la
libspeechd_module_la_SOURCES = module_main.c module_readline.c module_process.c
libspeechd_module_la_LDFLAGS = -version-info 0:0:0

#
# These are some common helper that speech-dispatcher-provided modules share to
# process configuration, process ssml, audio, etc.
Expand All @@ -54,14 +63,16 @@ module_utils_play_CPPFLAGS = $(AM_CPPFLAGS) \
# skeleton0 example module
#
noinst_PROGRAMS = sd_skeleton0
sd_skeleton0_SOURCES = skeleton0.c module_main.c module_readline.c module_process.c
sd_skeleton0_SOURCES = skeleton0.c
sd_skeleton0_LDADD = libspeechd_module.la

#
# skeleton example module
#
noinst_PROGRAMS += sd_skeleton_config
sd_skeleton_config_SOURCES = skeleton_config.c $(common_SOURCES)
sd_skeleton_config_LDADD = $(top_builddir)/src/common/libcommon.la \
libspeechd_module.la \
$(audio_dlopen_modules) \
$(common_LDADD)

Expand Down Expand Up @@ -173,33 +184,33 @@ install-exec-hook: install-exec-hook-espeak
# espeak-ng-based skeleton0 example module
#
noinst_PROGRAMS += sd_skeleton0_espeak-ng-sync
sd_skeleton0_espeak_ng_sync_SOURCES = skeleton0_espeak-ng-sync.c module_main.c module_readline.c module_process.c
sd_skeleton0_espeak_ng_sync_SOURCES = skeleton0_espeak-ng-sync.c
sd_skeleton0_espeak_ng_sync_CFLAGS = $(ESPEAK_NG_CFLAGS)
sd_skeleton0_espeak_ng_sync_LDADD = $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)
sd_skeleton0_espeak_ng_sync_LDADD = libspeechd_module.la $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)

#
# espeak-ng-based skeleton0 example module with asynchronous support
#
noinst_PROGRAMS += sd_skeleton0_espeak-ng-async
sd_skeleton0_espeak_ng_async_SOURCES = skeleton0_espeak-ng-async.c module_main.c module_readline.c module_process.c
sd_skeleton0_espeak_ng_async_SOURCES = skeleton0_espeak-ng-async.c
sd_skeleton0_espeak_ng_async_CFLAGS = $(ESPEAK_NG_CFLAGS)
sd_skeleton0_espeak_ng_async_LDADD = $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)
sd_skeleton0_espeak_ng_async_LDADD = libspeechd_module.la $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)

#
# espeak-ng-based skeleton0 example module with server audio
#
noinst_PROGRAMS += sd_skeleton0_espeak-ng-sync-server
sd_skeleton0_espeak_ng_sync_server_SOURCES = skeleton0_espeak-ng-sync-server.c module_main.c module_readline.c module_process.c
sd_skeleton0_espeak_ng_sync_server_SOURCES = skeleton0_espeak-ng-sync-server.c
sd_skeleton0_espeak_ng_sync_server_CFLAGS = $(ESPEAK_NG_CFLAGS)
sd_skeleton0_espeak_ng_sync_server_LDADD = $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)
sd_skeleton0_espeak_ng_sync_server_LDADD = libspeechd_module.la $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)

#
# espeak-ng-based skeleton0 example module with asynchronous support and server audio
#
noinst_PROGRAMS += sd_skeleton0_espeak-ng-async-server
sd_skeleton0_espeak_ng_async_server_SOURCES = skeleton0_espeak-ng-async-server.c module_main.c module_readline.c module_process.c
sd_skeleton0_espeak_ng_async_server_SOURCES = skeleton0_espeak-ng-async-server.c
sd_skeleton0_espeak_ng_async_server_CFLAGS = $(ESPEAK_NG_CFLAGS)
sd_skeleton0_espeak_ng_async_server_LDADD = $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)
sd_skeleton0_espeak_ng_async_server_LDADD = libspeechd_module.la $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS)
endif

#
Expand Down

0 comments on commit 5f4f5a5

Please sign in to comment.