Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
de1ef6c
kitten tts module for speechd
jsett Aug 5, 2026
8d7a4db
Remove the buffering code. Everything runs fine without it. Fixed an …
jsett Aug 8, 2026
01cb7d1
Added instructions into the readme on building/install
jsett Aug 10, 2026
2b2a6de
small bug
jsett Aug 10, 2026
a5ab64f
change stuff in model_change_voice to use Gstring's instead of char*'s.
jsett Aug 11, 2026
3a611e6
mark need to be a char*
jsett Aug 11, 2026
9f5bf7e
updated readme.
jsett Aug 11, 2026
a284a5c
updated readme
jsett Aug 12, 2026
d188bf5
removed some old dependencies.
jsett Aug 12, 2026
5a8baa9
Updated the make and configure file for optional support. Added depen…
jsett Aug 14, 2026
4a082cc
make sure that if any of our init's fail it get reported as a failure.
jsett Aug 14, 2026
0249b33
placed in license text
jsett Aug 15, 2026
b41356a
added checks for a distro path.
jsett Aug 15, 2026
acebf8e
forgot to change this comment
jsett Aug 15, 2026
b1ce2a2
allow model/voice files to be configured throught the models dot conf…
jsett Aug 26, 2026
9d015f4
Merge branch 'brailcom:master' into kitten
jsett Aug 31, 2026
5198ca7
placed kitten.h into EXTRA_DIST
jsett Aug 31, 2026
a8c493d
- Removed the downloader from the speechd module.
jsett Sep 1, 2026
10bf356
libcurl var should have been removed
jsett Sep 1, 2026
356abac
added example configuration file
jsett Sep 1, 2026
4272cc6
moved the example in the readme to be inline.
jsett Sep 1, 2026
a794550
removed curl from the ci
jsett Sep 1, 2026
b6db9f5
- Added a debug conf option that limits the amount of output printed …
jsett Sep 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
gettext help2man texinfo texlive texlive-plain-generic
nlohmann-json3-dev librubberband-dev
pulseaudio ${{ matrix.deps }}
libonnxruntime-dev libxml2-dev
- name: install piper
run: |
wget https://github.com/OHF-Voice/piper1-gpl/archive/refs/tags/v1.7.0.tar.gz
Expand Down Expand Up @@ -144,6 +145,7 @@ jobs:
libdotconf-dev libglib2.0-dev libltdl-dev- libsystemd-dev systemd
gettext help2man texinfo texlive texlive-plain-generic
pulseaudio
libonnxruntime-dev libxml2-dev
- name: autoconf
run: ./build.sh
- name: configure
Expand Down
5 changes: 5 additions & 0 deletions config/modules/kittentts.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
modelPath "/usr/share/kitten"

AddVoiceFile "Normal" "kitten_tts_micro_v0_8.onnx" "95481626fee1ba70ce683e69c534fc7cb38433c46ce42d3abbeafb4b9f1a4123" "voices_micro.bin" "12ad10f1fcce8a458b5cf79769b8edd4ba0e11e9fb6532fd192c3500b2b37a5d"
AddVoiceFile "High" "kitten_tts_mini_v0_8.onnx" "0f5bbae4fc4800c98dbc544a87ecfa79510de2fb8222db30d12e5bfe9177df91" "voices_mini.bin" "0e4965b46333db53ce09c73842623bf7055ea62c67f78803cb7ea9c16da6ac2b"
AddVoiceFile "Low" "kitten_tts_nano_v0_2.onnx" "42fa8809db319cd7c4c83b3c501e2313bf90edf610235291cad605e4adcb242d" "voices_nano.bin" "42a40a24a352a38657d6cb86ceee51bbc2b7780b29e04fb60bcdf959adccea01"
24 changes: 24 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ if test "$enable_libs_only" = "yes"; then
with_baratinoo=no
with_kali=no
with_piper=no
with_kitten=no

with_pulse=no
with_alsa=no
Expand Down Expand Up @@ -425,6 +426,29 @@ AM_CONDITIONAL([kali_support], [test $with_kali != no])
AM_CONDITIONAL([kali_shim], [test $with_kali = shim])
AS_IF([test $with_kali != no], [output_modules="${output_modules} kali"])

# check for kitten support
AC_ARG_WITH([kitten],
[AS_HELP_STRING([--with-kitten], [Compile with KittenTTS support])],
[],
[with_kitten=check])
AS_IF([test $with_kitten != "no"],
[PKG_CHECK_MODULES([LIBONNXRUNTIME], [libonnxruntime],
[kitten_libonnxruntime="yes"],
[AS_IF([test $with_kitten = "yes"],
[AC_MSG_FAILURE([libonnxruntime is not available])])])
PKG_CHECK_MODULES([LIBXML], [libxml-2.0],
[kitten_libxml="yes"],
[AS_IF([test $with_kitten = "yes"],
[AC_MSG_FAILURE([libxml-2.0 is not available])])])
AS_IF([test "x$kitten_libonnxruntime" = "xyes" -a "x$kitten_libxml" = "xyes"],
[with_kitten="yes"])])
AM_CONDITIONAL([kitten_support], [test $with_kitten = "yes"])
AC_SUBST([LIBONNXRUNTIME_CFLAGS])
AC_SUBST([LIBONNXRUNTIME_LIBS])
AC_SUBST([LIBXML_CFLAGS])
AC_SUBST([LIBXML_LIBS])
AS_IF([test $with_kitten = "yes"], [output_modules="${output_modules} kitten"])

# check for piper support
AC_ARG_WITH([piper],
[AS_HELP_STRING([--with-piper[[=yes|no|check|/path]]], [include Piper TTS support])],
Expand Down
1 change: 1 addition & 0 deletions src/modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
/sd_kali
/sd_openjtalk
/sd_pico
/sd_kittentts
/sd_skeleton0
/sd_skeleton0_espeak-ng-async
/sd_skeleton0_espeak-ng-async-server
Expand Down
11 changes: 11 additions & 0 deletions src/modules/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ EXTRA_DIST += voxin_shim.c voxin.h
EXTRA_DIST += module_utils.h
EXTRA_DIST += dummy-message-default.wav
EXTRA_DIST += dummy-message.txt
EXTRA_DIST += kitten.h
CLEANFILES = dummy-message.wav

if HAVE_PYTHON
Expand Down Expand Up @@ -133,6 +134,16 @@ sd_flite_LDADD = $(top_builddir)/src/common/libcommon.la \
$(common_LDADD)
endif

#
# kitten tts module
#
if kitten_support
modulebin_PROGRAMS += sd_kittentts
sd_kittentts_SOURCES = kitten_server.c kitten_utilities.c kitten_model.c kitten_worker.c
sd_kittentts_CFLAGS = $(ESPEAK_NG_CFLAGS) $(GLIB_CFLAGS) $(LIBONNXRUNTIME_CFLAGS) $(LIBXML_CFLAGS) $(DOTCONF_CFLAGS)
sd_kittentts_LDADD = $(top_builddir)/src/common/libcommon_la-common.o libspeechd_module.la $(ESPEAK_NG_LIBS) $(EXTRA_ESPEAK_LIBS) $(GLIB_LIBS) $(LIBONNXRUNTIME_LIBS) $(LIBXML_LIBS) $(DOTCONF_LIBS)
endif

#
# ibmtts module
#
Expand Down
49 changes: 49 additions & 0 deletions src/modules/README.kitten.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Module conf file options.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rather put an example configuration file, otherwise it will be too hard for users to work out what it should look like. You can then stuff this information in the example configuration file.

@sthibaul sthibaul Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, rather put the information of README.kitten.md in the configuration file example. That's the best way that users will see it and know how to configure it. Otherwise distributions will at worse not install the readme file, at best put it in /usr/share/doc/speech-dispatcher, where users won't find it, and be at a loss when trying to configure /etc/speech-dispatcher/config/kitten.conf


The modules dot conf file can be used to configure the module using `AddVoiceFile` and `modelPath`. `AddVoiceFile` let you set models/voices in the case of updated models. `modelPath` let you set the modes/voices search path.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set the model in the example file to /usr/share/kitten, to give people an idea where the files should be put as a distribution (to be shared with other software using kitten models)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the readme with examples.


## AddVoiceFile

AddVoiceFile should be formated like such.
```
AddVoiceFile "voice_quality" "model filename" "model sha256" "voices filename" "voices sha256"
```

you can find an example config here using `AddVoiceFile`

```
AddVoiceFile "Normal" "kitten_tts_micro_v0_8.onnx" "95481626fee1ba70ce683e69c534fc7cb38433c46ce42d3abbeafb4b9f1a4123" "voices_micro.bin" "12ad10f1fcce8a458b5cf79769b8edd4ba0e11e9fb6532fd192c3500b2b37a5d"
AddVoiceFile "High" "kitten_tts_mini_v0_8.onnx" "0f5bbae4fc4800c98dbc544a87ecfa79510de2fb8222db30d12e5bfe9177df91" "voices_mini.bin" "0e4965b46333db53ce09c73842623bf7055ea62c67f78803cb7ea9c16da6ac2b"
AddVoiceFile "Low" "kitten_tts_nano_v0_2.onnx" "42fa8809db319cd7c4c83b3c501e2313bf90edf610235291cad605e4adcb242d" "voices_nano.bin" "42a40a24a352a38657d6cb86ceee51bbc2b7780b29e04fb60bcdf959adccea01"
```

## modelPath

modelPath should be formated like such.
```
modelPath "<your path>"
```

you can find an example config here using `modelPath`

```
modelPath "/usr/share/kitten"
```

## Example configuration file

Full example configuation using all options.

`kittentts.conf`

```
modelPath "/usr/share/kitten"

AddVoiceFile "Normal" "kitten_tts_micro_v0_8.onnx" "95481626fee1ba70ce683e69c534fc7cb38433c46ce42d3abbeafb4b9f1a4123" "voices_micro.bin" "12ad10f1fcce8a458b5cf79769b8edd4ba0e11e9fb6532fd192c3500b2b37a5d"
AddVoiceFile "High" "kitten_tts_mini_v0_8.onnx" "0f5bbae4fc4800c98dbc544a87ecfa79510de2fb8222db30d12e5bfe9177df91" "voices_mini.bin" "0e4965b46333db53ce09c73842623bf7055ea62c67f78803cb7ea9c16da6ac2b"
AddVoiceFile "Low" "kitten_tts_nano_v0_2.onnx" "42fa8809db319cd7c4c83b3c501e2313bf90edf610235291cad605e4adcb242d" "voices_nano.bin" "42a40a24a352a38657d6cb86ceee51bbc2b7780b29e04fb60bcdf959adccea01"
Comment thread
jsett marked this conversation as resolved.
```

# Downloading models+voices.

A simple downloader for downloading the models and voices is provided [here](https://github.com/jsett/kitten_models_downloader)
158 changes: 158 additions & 0 deletions src/modules/kitten.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
The MIT License (MIT)

Copyright © 2026 John Settlemyer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <glib/gstdio.h>
Comment thread
jsett marked this conversation as resolved.
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <stdbool.h>
#include <glib.h>
#include <onnxruntime_c_api.h>
#include <inttypes.h>
#include <sndfile.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h>
#include "module_utils.h"

#include <speechd_types.h>
#include "spd_module_main.h"

#define CHECK_STATUS(expr) \
do { \
OrtStatus* status = (expr); \
if (status != NULL) { \
const char* msg = g_ort->GetErrorMessage(status); \
MSG(2, "ERROR: ONNX Runtime Error: %s\n", msg); \
g_ort->ReleaseStatus(status); \
exit(1); \
} \
} while (0)

extern int model_type;
extern int ROWS;
#define COLS 256

#define PAD "$"
#define PUNCTUATION ";:,.!?¡¿—…\"«»\"\" "
#define LETTERS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Comment thread
jsett marked this conversation as resolved.
#define LETTERS_IPA "ɑɐɒæɓʙβɔɕçɗɖðʤəɘɚɛɜɝɞɟʄɡɠɢʛɦɧħɥʜɨɪʝɭɬɫɮʟɱɯɰŋɳɲɴøɵɸθœɶʘɹɺɾɻʀʁɽʂʃʈʧʉʊʋⱱʌɣɤʍχʎʏʑʐʒʔʡʕʢǀǁǂǃˈˌːˑʼʴʰʱʲʷˠˤ˞↓↑→↗↘'̩'ᵻ"

#define SYMBOLS PAD PUNCTUATION LETTERS LETTERS_IPA

// setting var's
extern float speed;
//['Leo','Kiki','Hugo','Rosie','Bruno','Luna','Jasper','Bella']
extern GString *voice;
extern GString *voice_setting;
// paths var's
extern GString *model_path;
extern GString *voices_path;
extern const char *home_dir;
extern GString *model_dir;

extern GString *distro_target_subdir;

extern bool stop_generation;

// holds and array of values that must be passed to the model based off the requested voice and length of the text.
extern float *voice_styles;

extern const OrtApi* g_ort;
extern OrtEnv* env;
extern OrtSessionOptions* session_options;
extern OrtSession* session;

extern GHashTable *files_hash_table;

extern bool debug_module;

#define DEBUG_PRINT(...) \
do { \
if (debug_module) { \
MSG(5, __VA_ARGS__); \
} \
} while (0)

#define TARGET_SUBDIR ".cache/speech-dispatcher/kitten"

typedef struct {
const char *quality;
const char *model_filename;
const char *model_expected_sha256;
const char *voice_filename;
const char *voice_expected_sha256;
} FileInfo;

#define VOICE_LIST(X) \
X(Leo) \
X(Kiki) \
X(Hugo) \
X(Rosie) \
X(Bruno) \
X(Luna) \
X(Jasper) \
X(Bella) \
X(Leo_Low) \
X(Kiki_Low) \
X(Hugo_Low) \
X(Rosie_Low) \
X(Bruno_Low) \
X(Luna_Low) \
X(Jasper_Low) \
X(Bella_Low) \
X(Leo_High) \
X(Kiki_High) \
X(Hugo_High) \
X(Rosie_High) \
X(Bruno_High) \
X(Luna_High) \
X(Jasper_High) \
X(Bella_High)

#define DEFINE_VOICE(name_token) static SPDVoice voice_##name_token = { .name = #name_token, .language = "en" };
#define VOICE_PTR_ITEM(name_token) &voice_##name_token,

// kitten_utilities.c
void init_file_hashtable_and_distro_subdir(void);
int init_paths(void);
void build_hash_from_defaults(GHashTable *ht);
void file_hash_add_sub_key(GHashTable *ht, const char* quality, const char* key, const char* value);
char* file_hash_get_value(GHashTable *ht, const char* quality, const char* key);

// kitten_model.c
int init_voice_style(const char* voices_path);
void cleanup_voice_style();
GArray *get_style(const char *text, const char *voice);
GArray *get_char_indices(const gchar *locate, const gchar *index_str);
GString *get_phonemes(const char *text);
int init_model(const char* model_path);
void cleanup_model();
GArray* run_model(GArray *inputs_array, GArray *styles_array, float speed);
void convert_float_to_short(const float* in_buffer, GArray* out_buffer, size_t num_samples);
GArray* kitten_speak(const char* data);
int reload_models_and_voices(const char *model_filename, const char* voice_filename);

// kitten_worker.c
int init_model_thread_pool();
int cleanup_threads();
int model_change_voice(const char *var, const char *val);
int model_change_speed(const char *var, const char *val);
int add_generate_speech_task(const char* data, size_t bytes);
int model_stop_generation();
Loading