-
Notifications
You must be signed in to change notification settings - Fork 90
KittenTTS module. #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jsett
wants to merge
17
commits into
brailcom:master
Choose a base branch
from
jsett:kitten
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
KittenTTS module. #1107
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
de1ef6c
kitten tts module for speechd
jsett 8d7a4db
Remove the buffering code. Everything runs fine without it. Fixed an …
jsett 01cb7d1
Added instructions into the readme on building/install
jsett 2b2a6de
small bug
jsett a5ab64f
change stuff in model_change_voice to use Gstring's instead of char*'s.
jsett 3a611e6
mark need to be a char*
jsett 9f5bf7e
updated readme.
jsett a284a5c
updated readme
jsett d188bf5
removed some old dependencies.
jsett 5a8baa9
Updated the make and configure file for optional support. Added depen…
jsett 4a082cc
make sure that if any of our init's fail it get reported as a failure.
jsett 0249b33
placed in license text
jsett b41356a
added checks for a distro path.
jsett acebf8e
forgot to change this comment
jsett b1ce2a2
allow model/voice files to be configured throught the models dot conf…
jsett 9d015f4
Merge branch 'brailcom:master' into kitten
jsett 5198ca7
placed kitten.h into EXTRA_DIST
jsett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| /* | ||
| 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> | ||
| #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 <curl/curl.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); \ | ||
| fprintf(stderr, "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" | ||
|
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 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; | ||
|
|
||
| #define TARGET_SUBDIR ".cache/speech-dispatcher/kitten" | ||
| #define DISTRO_TARGET_SUBDIR "/usr/share/speech-dispatcher/models/kitten" | ||
|
|
||
| typedef struct { | ||
| const char *quality; | ||
| const char *model_url; | ||
| const char *model_filename; | ||
| const char *model_expected_size; | ||
| const char *model_expected_sha256; | ||
| const char *voice_url; | ||
| const char *voice_filename; | ||
| const char *voice_expected_size; | ||
| 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_downloader.c | ||
| int download_models(void); | ||
| bool use_distro_path(void); | ||
| void init_file_hashtable(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(); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.