Implement text-to-speech support on Android, iOS, HTML5, Linux, macOS and Windows.

Implement TextServer word break method.
This commit is contained in:
bruvzg 2021-11-04 14:33:37 +02:00
parent 3e1b824c05
commit 6ab672d1ef
54 changed files with 3962 additions and 2 deletions

View file

@ -20,6 +20,9 @@ if "x11" in env and env["x11"]:
"key_mapping_x11.cpp",
]
if "speechd" in env and env["speechd"]:
common_linuxbsd.append(["speechd-so_wrap.c", "tts_linux.cpp"])
if "vulkan" in env and env["vulkan"]:
common_linuxbsd.append("vulkan_context_x11.cpp")

View file

@ -75,6 +75,7 @@ def get_opts():
BoolVariable("use_msan", "Use LLVM compiler memory sanitizer (MSAN)", False),
BoolVariable("pulseaudio", "Detect and use PulseAudio", True),
BoolVariable("dbus", "Detect and use D-Bus to handle screensaver", True),
BoolVariable("speechd", "Detect and use Speech Dispatcher for Text-to-Speech support", True),
BoolVariable("udev", "Use udev for gamepad connection callbacks", True),
BoolVariable("x11", "Enable X11 display", True),
BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True),
@ -337,6 +338,13 @@ def configure(env):
else:
print("Warning: D-Bus development libraries not found. Disabling screensaver prevention.")
if env["speechd"]:
if os.system("pkg-config --exists speech-dispatcher") == 0: # 0 means found
env.Append(CPPDEFINES=["SPEECHD_ENABLED"])
env.ParseConfig("pkg-config speech-dispatcher --cflags") # Only cflags, we dlopen the library.
else:
print("Warning: Speech Dispatcher development libraries not found. Disabling Text-to-Speech support.")
if platform.system() == "Linux":
env.Append(CPPDEFINES=["JOYDEV_ENABLED"])
if env["udev"]:

View file

@ -139,6 +139,7 @@ bool DisplayServerX11::has_feature(Feature p_feature) const {
case FEATURE_KEEP_SCREEN_ON:
#endif
case FEATURE_CLIPBOARD_PRIMARY:
case FEATURE_TEXT_TO_SPEECH:
return true;
default: {
}
@ -307,6 +308,45 @@ void DisplayServerX11::_flush_mouse_motion() {
xi.relative_motion.y = 0;
}
#ifdef SPEECHD_ENABLED
bool DisplayServerX11::tts_is_speaking() const {
ERR_FAIL_COND_V(!tts, false);
return tts->is_speaking();
}
bool DisplayServerX11::tts_is_paused() const {
ERR_FAIL_COND_V(!tts, false);
return tts->is_paused();
}
Array DisplayServerX11::tts_get_voices() const {
ERR_FAIL_COND_V(!tts, Array());
return tts->get_voices();
}
void DisplayServerX11::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
ERR_FAIL_COND(!tts);
tts->speak(p_text, p_voice, p_volume, p_pitch, p_rate, p_utterance_id, p_interrupt);
}
void DisplayServerX11::tts_pause() {
ERR_FAIL_COND(!tts);
tts->pause();
}
void DisplayServerX11::tts_resume() {
ERR_FAIL_COND(!tts);
tts->resume();
}
void DisplayServerX11::tts_stop() {
ERR_FAIL_COND(!tts);
tts->stop();
}
#endif
void DisplayServerX11::mouse_set_mode(MouseMode p_mode) {
_THREAD_SAFE_METHOD_
@ -4633,6 +4673,11 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
xdnd_finished = XInternAtom(x11_display, "XdndFinished", False);
xdnd_selection = XInternAtom(x11_display, "XdndSelection", False);
#ifdef SPEECHD_ENABLED
// Init TTS
tts = memnew(TTS_Linux);
#endif
//!!!!!!!!!!!!!!!!!!!!!!!!!!
//TODO - do Vulkan and OpenGL support checks, driver selection and fallback
rendering_driver = p_rendering_driver;
@ -4985,6 +5030,10 @@ DisplayServerX11::~DisplayServerX11() {
memfree(xmbstring);
}
#ifdef SPEECHD_ENABLED
memdelete(tts);
#endif
#ifdef DBUS_ENABLED
memdelete(screensaver);
#endif

View file

@ -46,6 +46,10 @@
#include "servers/rendering/renderer_compositor.h"
#include "servers/rendering_server.h"
#if defined(SPEECHD_ENABLED)
#include "tts_linux.h"
#endif
#if defined(GLES3_ENABLED)
#include "gl_manager_x11.h"
#endif
@ -112,6 +116,10 @@ class DisplayServerX11 : public DisplayServer {
bool keep_screen_on = false;
#endif
#ifdef SPEECHD_ENABLED
TTS_Linux *tts = nullptr;
#endif
struct WindowData {
Window x11_window;
::XIC xic;
@ -298,6 +306,17 @@ public:
virtual bool has_feature(Feature p_feature) const override;
virtual String get_name() const override;
#ifdef SPEECHD_ENABLED
virtual bool tts_is_speaking() const override;
virtual bool tts_is_paused() const override;
virtual Array tts_get_voices() const override;
virtual void tts_speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false) override;
virtual void tts_pause() override;
virtual void tts_resume() override;
virtual void tts_stop() override;
#endif
virtual void mouse_set_mode(MouseMode p_mode) override;
virtual MouseMode mouse_get_mode() const override;

View file

@ -0,0 +1,881 @@
// This file is generated. Do not edit!
// see https://github.com/hpvb/dynload-wrapper for details
// generated by ./dynload-wrapper/generate-wrapper.py 0.3 on 2022-04-28 14:34:21
// flags: ./dynload-wrapper/generate-wrapper.py --sys-include <libspeechd.h> --include /usr/include/speech-dispatcher/libspeechd.h --soname libspeechd.so.2 --init-name speechd --omit-prefix spd_get_client_list --output-header speechd-so_wrap.h --output-implementation speechd-so_wrap.c
//
#include <stdint.h>
#define SPDConnectionAddress__free SPDConnectionAddress__free_dylibloader_orig_speechd
#define spd_get_default_address spd_get_default_address_dylibloader_orig_speechd
#define spd_open spd_open_dylibloader_orig_speechd
#define spd_open2 spd_open2_dylibloader_orig_speechd
#define spd_close spd_close_dylibloader_orig_speechd
#define spd_say spd_say_dylibloader_orig_speechd
#define spd_sayf spd_sayf_dylibloader_orig_speechd
#define spd_stop spd_stop_dylibloader_orig_speechd
#define spd_stop_all spd_stop_all_dylibloader_orig_speechd
#define spd_stop_uid spd_stop_uid_dylibloader_orig_speechd
#define spd_cancel spd_cancel_dylibloader_orig_speechd
#define spd_cancel_all spd_cancel_all_dylibloader_orig_speechd
#define spd_cancel_uid spd_cancel_uid_dylibloader_orig_speechd
#define spd_pause spd_pause_dylibloader_orig_speechd
#define spd_pause_all spd_pause_all_dylibloader_orig_speechd
#define spd_pause_uid spd_pause_uid_dylibloader_orig_speechd
#define spd_resume spd_resume_dylibloader_orig_speechd
#define spd_resume_all spd_resume_all_dylibloader_orig_speechd
#define spd_resume_uid spd_resume_uid_dylibloader_orig_speechd
#define spd_key spd_key_dylibloader_orig_speechd
#define spd_char spd_char_dylibloader_orig_speechd
#define spd_wchar spd_wchar_dylibloader_orig_speechd
#define spd_sound_icon spd_sound_icon_dylibloader_orig_speechd
#define spd_set_voice_type spd_set_voice_type_dylibloader_orig_speechd
#define spd_set_voice_type_all spd_set_voice_type_all_dylibloader_orig_speechd
#define spd_set_voice_type_uid spd_set_voice_type_uid_dylibloader_orig_speechd
#define spd_get_voice_type spd_get_voice_type_dylibloader_orig_speechd
#define spd_set_synthesis_voice spd_set_synthesis_voice_dylibloader_orig_speechd
#define spd_set_synthesis_voice_all spd_set_synthesis_voice_all_dylibloader_orig_speechd
#define spd_set_synthesis_voice_uid spd_set_synthesis_voice_uid_dylibloader_orig_speechd
#define spd_set_data_mode spd_set_data_mode_dylibloader_orig_speechd
#define spd_set_notification_on spd_set_notification_on_dylibloader_orig_speechd
#define spd_set_notification_off spd_set_notification_off_dylibloader_orig_speechd
#define spd_set_notification spd_set_notification_dylibloader_orig_speechd
#define spd_set_voice_rate spd_set_voice_rate_dylibloader_orig_speechd
#define spd_set_voice_rate_all spd_set_voice_rate_all_dylibloader_orig_speechd
#define spd_set_voice_rate_uid spd_set_voice_rate_uid_dylibloader_orig_speechd
#define spd_get_voice_rate spd_get_voice_rate_dylibloader_orig_speechd
#define spd_set_voice_pitch spd_set_voice_pitch_dylibloader_orig_speechd
#define spd_set_voice_pitch_all spd_set_voice_pitch_all_dylibloader_orig_speechd
#define spd_set_voice_pitch_uid spd_set_voice_pitch_uid_dylibloader_orig_speechd
#define spd_get_voice_pitch spd_get_voice_pitch_dylibloader_orig_speechd
#define spd_set_voice_pitch_range spd_set_voice_pitch_range_dylibloader_orig_speechd
#define spd_set_voice_pitch_range_all spd_set_voice_pitch_range_all_dylibloader_orig_speechd
#define spd_set_voice_pitch_range_uid spd_set_voice_pitch_range_uid_dylibloader_orig_speechd
#define spd_set_volume spd_set_volume_dylibloader_orig_speechd
#define spd_set_volume_all spd_set_volume_all_dylibloader_orig_speechd
#define spd_set_volume_uid spd_set_volume_uid_dylibloader_orig_speechd
#define spd_get_volume spd_get_volume_dylibloader_orig_speechd
#define spd_set_punctuation spd_set_punctuation_dylibloader_orig_speechd
#define spd_set_punctuation_all spd_set_punctuation_all_dylibloader_orig_speechd
#define spd_set_punctuation_uid spd_set_punctuation_uid_dylibloader_orig_speechd
#define spd_set_capital_letters spd_set_capital_letters_dylibloader_orig_speechd
#define spd_set_capital_letters_all spd_set_capital_letters_all_dylibloader_orig_speechd
#define spd_set_capital_letters_uid spd_set_capital_letters_uid_dylibloader_orig_speechd
#define spd_set_spelling spd_set_spelling_dylibloader_orig_speechd
#define spd_set_spelling_all spd_set_spelling_all_dylibloader_orig_speechd
#define spd_set_spelling_uid spd_set_spelling_uid_dylibloader_orig_speechd
#define spd_set_language spd_set_language_dylibloader_orig_speechd
#define spd_set_language_all spd_set_language_all_dylibloader_orig_speechd
#define spd_set_language_uid spd_set_language_uid_dylibloader_orig_speechd
#define spd_get_language spd_get_language_dylibloader_orig_speechd
#define spd_set_output_module spd_set_output_module_dylibloader_orig_speechd
#define spd_set_output_module_all spd_set_output_module_all_dylibloader_orig_speechd
#define spd_set_output_module_uid spd_set_output_module_uid_dylibloader_orig_speechd
#define spd_get_message_list_fd spd_get_message_list_fd_dylibloader_orig_speechd
#define spd_list_modules spd_list_modules_dylibloader_orig_speechd
#define free_spd_modules free_spd_modules_dylibloader_orig_speechd
#define spd_get_output_module spd_get_output_module_dylibloader_orig_speechd
#define spd_list_voices spd_list_voices_dylibloader_orig_speechd
#define spd_list_synthesis_voices spd_list_synthesis_voices_dylibloader_orig_speechd
#define free_spd_voices free_spd_voices_dylibloader_orig_speechd
#define spd_execute_command_with_list_reply spd_execute_command_with_list_reply_dylibloader_orig_speechd
#define spd_execute_command spd_execute_command_dylibloader_orig_speechd
#define spd_execute_command_with_reply spd_execute_command_with_reply_dylibloader_orig_speechd
#define spd_execute_command_wo_mutex spd_execute_command_wo_mutex_dylibloader_orig_speechd
#define spd_send_data spd_send_data_dylibloader_orig_speechd
#define spd_send_data_wo_mutex spd_send_data_wo_mutex_dylibloader_orig_speechd
#include <libspeechd.h>
#undef SPDConnectionAddress__free
#undef spd_get_default_address
#undef spd_open
#undef spd_open2
#undef spd_close
#undef spd_say
#undef spd_sayf
#undef spd_stop
#undef spd_stop_all
#undef spd_stop_uid
#undef spd_cancel
#undef spd_cancel_all
#undef spd_cancel_uid
#undef spd_pause
#undef spd_pause_all
#undef spd_pause_uid
#undef spd_resume
#undef spd_resume_all
#undef spd_resume_uid
#undef spd_key
#undef spd_char
#undef spd_wchar
#undef spd_sound_icon
#undef spd_set_voice_type
#undef spd_set_voice_type_all
#undef spd_set_voice_type_uid
#undef spd_get_voice_type
#undef spd_set_synthesis_voice
#undef spd_set_synthesis_voice_all
#undef spd_set_synthesis_voice_uid
#undef spd_set_data_mode
#undef spd_set_notification_on
#undef spd_set_notification_off
#undef spd_set_notification
#undef spd_set_voice_rate
#undef spd_set_voice_rate_all
#undef spd_set_voice_rate_uid
#undef spd_get_voice_rate
#undef spd_set_voice_pitch
#undef spd_set_voice_pitch_all
#undef spd_set_voice_pitch_uid
#undef spd_get_voice_pitch
#undef spd_set_voice_pitch_range
#undef spd_set_voice_pitch_range_all
#undef spd_set_voice_pitch_range_uid
#undef spd_set_volume
#undef spd_set_volume_all
#undef spd_set_volume_uid
#undef spd_get_volume
#undef spd_set_punctuation
#undef spd_set_punctuation_all
#undef spd_set_punctuation_uid
#undef spd_set_capital_letters
#undef spd_set_capital_letters_all
#undef spd_set_capital_letters_uid
#undef spd_set_spelling
#undef spd_set_spelling_all
#undef spd_set_spelling_uid
#undef spd_set_language
#undef spd_set_language_all
#undef spd_set_language_uid
#undef spd_get_language
#undef spd_set_output_module
#undef spd_set_output_module_all
#undef spd_set_output_module_uid
#undef spd_get_message_list_fd
#undef spd_list_modules
#undef free_spd_modules
#undef spd_get_output_module
#undef spd_list_voices
#undef spd_list_synthesis_voices
#undef free_spd_voices
#undef spd_execute_command_with_list_reply
#undef spd_execute_command
#undef spd_execute_command_with_reply
#undef spd_execute_command_wo_mutex
#undef spd_send_data
#undef spd_send_data_wo_mutex
#include <dlfcn.h>
#include <stdio.h>
void (*SPDConnectionAddress__free_dylibloader_wrapper_speechd)( SPDConnectionAddress*);
SPDConnectionAddress* (*spd_get_default_address_dylibloader_wrapper_speechd)( char**);
SPDConnection* (*spd_open_dylibloader_wrapper_speechd)(const char*,const char*,const char*, SPDConnectionMode);
SPDConnection* (*spd_open2_dylibloader_wrapper_speechd)(const char*,const char*,const char*, SPDConnectionMode, SPDConnectionAddress*, int, char**);
void (*spd_close_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_say_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
int (*spd_sayf_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*,...);
int (*spd_stop_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_stop_all_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_stop_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
int (*spd_cancel_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_cancel_all_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_cancel_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
int (*spd_pause_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_pause_all_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_pause_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
int (*spd_resume_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_resume_all_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_resume_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
int (*spd_key_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
int (*spd_char_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
int (*spd_wchar_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority, wchar_t);
int (*spd_sound_icon_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
int (*spd_set_voice_type_dylibloader_wrapper_speechd)( SPDConnection*, SPDVoiceType);
int (*spd_set_voice_type_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDVoiceType);
int (*spd_set_voice_type_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDVoiceType, unsigned int);
SPDVoiceType (*spd_get_voice_type_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_set_synthesis_voice_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
int (*spd_set_synthesis_voice_all_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
int (*spd_set_synthesis_voice_uid_dylibloader_wrapper_speechd)( SPDConnection*,const char*, unsigned int);
int (*spd_set_data_mode_dylibloader_wrapper_speechd)( SPDConnection*, SPDDataMode);
int (*spd_set_notification_on_dylibloader_wrapper_speechd)( SPDConnection*, SPDNotification);
int (*spd_set_notification_off_dylibloader_wrapper_speechd)( SPDConnection*, SPDNotification);
int (*spd_set_notification_dylibloader_wrapper_speechd)( SPDConnection*, SPDNotification,const char*);
int (*spd_set_voice_rate_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_voice_rate_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_voice_rate_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
int (*spd_get_voice_rate_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_set_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_voice_pitch_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_voice_pitch_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
int (*spd_get_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_set_voice_pitch_range_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
int (*spd_set_volume_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_volume_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
int (*spd_set_volume_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
int (*spd_get_volume_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_set_punctuation_dylibloader_wrapper_speechd)( SPDConnection*, SPDPunctuation);
int (*spd_set_punctuation_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDPunctuation);
int (*spd_set_punctuation_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDPunctuation, unsigned int);
int (*spd_set_capital_letters_dylibloader_wrapper_speechd)( SPDConnection*, SPDCapitalLetters);
int (*spd_set_capital_letters_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDCapitalLetters);
int (*spd_set_capital_letters_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDCapitalLetters, unsigned int);
int (*spd_set_spelling_dylibloader_wrapper_speechd)( SPDConnection*, SPDSpelling);
int (*spd_set_spelling_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDSpelling);
int (*spd_set_spelling_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDSpelling, unsigned int);
int (*spd_set_language_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
int (*spd_set_language_all_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
int (*spd_set_language_uid_dylibloader_wrapper_speechd)( SPDConnection*,const char*, unsigned int);
char* (*spd_get_language_dylibloader_wrapper_speechd)( SPDConnection*);
int (*spd_set_output_module_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
int (*spd_set_output_module_all_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
int (*spd_set_output_module_uid_dylibloader_wrapper_speechd)( SPDConnection*,const char*, unsigned int);
int (*spd_get_message_list_fd_dylibloader_wrapper_speechd)( SPDConnection*, int, int*, char**);
char** (*spd_list_modules_dylibloader_wrapper_speechd)( SPDConnection*);
void (*free_spd_modules_dylibloader_wrapper_speechd)( char**);
char* (*spd_get_output_module_dylibloader_wrapper_speechd)( SPDConnection*);
char** (*spd_list_voices_dylibloader_wrapper_speechd)( SPDConnection*);
SPDVoice** (*spd_list_synthesis_voices_dylibloader_wrapper_speechd)( SPDConnection*);
void (*free_spd_voices_dylibloader_wrapper_speechd)( SPDVoice**);
char** (*spd_execute_command_with_list_reply_dylibloader_wrapper_speechd)( SPDConnection*, char*);
int (*spd_execute_command_dylibloader_wrapper_speechd)( SPDConnection*, char*);
int (*spd_execute_command_with_reply_dylibloader_wrapper_speechd)( SPDConnection*, char*, char**);
int (*spd_execute_command_wo_mutex_dylibloader_wrapper_speechd)( SPDConnection*, char*);
char* (*spd_send_data_dylibloader_wrapper_speechd)( SPDConnection*,const char*, int);
char* (*spd_send_data_wo_mutex_dylibloader_wrapper_speechd)( SPDConnection*,const char*, int);
int initialize_speechd(int verbose) {
void *handle;
char *error;
handle = dlopen("libspeechd.so.2", RTLD_LAZY);
if (!handle) {
if (verbose) {
fprintf(stderr, "%s\n", dlerror());
}
return(1);
}
dlerror();
// SPDConnectionAddress__free
*(void **) (&SPDConnectionAddress__free_dylibloader_wrapper_speechd) = dlsym(handle, "SPDConnectionAddress__free");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_default_address
*(void **) (&spd_get_default_address_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_default_address");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_open
*(void **) (&spd_open_dylibloader_wrapper_speechd) = dlsym(handle, "spd_open");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_open2
*(void **) (&spd_open2_dylibloader_wrapper_speechd) = dlsym(handle, "spd_open2");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_close
*(void **) (&spd_close_dylibloader_wrapper_speechd) = dlsym(handle, "spd_close");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_say
*(void **) (&spd_say_dylibloader_wrapper_speechd) = dlsym(handle, "spd_say");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_sayf
*(void **) (&spd_sayf_dylibloader_wrapper_speechd) = dlsym(handle, "spd_sayf");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_stop
*(void **) (&spd_stop_dylibloader_wrapper_speechd) = dlsym(handle, "spd_stop");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_stop_all
*(void **) (&spd_stop_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_stop_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_stop_uid
*(void **) (&spd_stop_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_stop_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_cancel
*(void **) (&spd_cancel_dylibloader_wrapper_speechd) = dlsym(handle, "spd_cancel");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_cancel_all
*(void **) (&spd_cancel_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_cancel_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_cancel_uid
*(void **) (&spd_cancel_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_cancel_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_pause
*(void **) (&spd_pause_dylibloader_wrapper_speechd) = dlsym(handle, "spd_pause");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_pause_all
*(void **) (&spd_pause_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_pause_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_pause_uid
*(void **) (&spd_pause_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_pause_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_resume
*(void **) (&spd_resume_dylibloader_wrapper_speechd) = dlsym(handle, "spd_resume");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_resume_all
*(void **) (&spd_resume_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_resume_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_resume_uid
*(void **) (&spd_resume_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_resume_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_key
*(void **) (&spd_key_dylibloader_wrapper_speechd) = dlsym(handle, "spd_key");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_char
*(void **) (&spd_char_dylibloader_wrapper_speechd) = dlsym(handle, "spd_char");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_wchar
*(void **) (&spd_wchar_dylibloader_wrapper_speechd) = dlsym(handle, "spd_wchar");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_sound_icon
*(void **) (&spd_sound_icon_dylibloader_wrapper_speechd) = dlsym(handle, "spd_sound_icon");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_type
*(void **) (&spd_set_voice_type_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_type");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_type_all
*(void **) (&spd_set_voice_type_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_type_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_type_uid
*(void **) (&spd_set_voice_type_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_type_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_voice_type
*(void **) (&spd_get_voice_type_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_voice_type");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_synthesis_voice
*(void **) (&spd_set_synthesis_voice_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_synthesis_voice");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_synthesis_voice_all
*(void **) (&spd_set_synthesis_voice_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_synthesis_voice_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_synthesis_voice_uid
*(void **) (&spd_set_synthesis_voice_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_synthesis_voice_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_data_mode
*(void **) (&spd_set_data_mode_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_data_mode");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_notification_on
*(void **) (&spd_set_notification_on_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_notification_on");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_notification_off
*(void **) (&spd_set_notification_off_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_notification_off");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_notification
*(void **) (&spd_set_notification_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_notification");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_rate
*(void **) (&spd_set_voice_rate_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_rate");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_rate_all
*(void **) (&spd_set_voice_rate_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_rate_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_rate_uid
*(void **) (&spd_set_voice_rate_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_rate_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_voice_rate
*(void **) (&spd_get_voice_rate_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_voice_rate");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_pitch
*(void **) (&spd_set_voice_pitch_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_pitch_all
*(void **) (&spd_set_voice_pitch_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_pitch_uid
*(void **) (&spd_set_voice_pitch_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_voice_pitch
*(void **) (&spd_get_voice_pitch_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_voice_pitch");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_pitch_range
*(void **) (&spd_set_voice_pitch_range_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_range");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_pitch_range_all
*(void **) (&spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_range_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_voice_pitch_range_uid
*(void **) (&spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_range_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_volume
*(void **) (&spd_set_volume_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_volume");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_volume_all
*(void **) (&spd_set_volume_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_volume_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_volume_uid
*(void **) (&spd_set_volume_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_volume_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_volume
*(void **) (&spd_get_volume_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_volume");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_punctuation
*(void **) (&spd_set_punctuation_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_punctuation");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_punctuation_all
*(void **) (&spd_set_punctuation_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_punctuation_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_punctuation_uid
*(void **) (&spd_set_punctuation_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_punctuation_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_capital_letters
*(void **) (&spd_set_capital_letters_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_capital_letters");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_capital_letters_all
*(void **) (&spd_set_capital_letters_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_capital_letters_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_capital_letters_uid
*(void **) (&spd_set_capital_letters_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_capital_letters_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_spelling
*(void **) (&spd_set_spelling_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_spelling");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_spelling_all
*(void **) (&spd_set_spelling_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_spelling_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_spelling_uid
*(void **) (&spd_set_spelling_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_spelling_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_language
*(void **) (&spd_set_language_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_language");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_language_all
*(void **) (&spd_set_language_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_language_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_language_uid
*(void **) (&spd_set_language_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_language_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_language
*(void **) (&spd_get_language_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_language");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_output_module
*(void **) (&spd_set_output_module_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_output_module");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_output_module_all
*(void **) (&spd_set_output_module_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_output_module_all");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_set_output_module_uid
*(void **) (&spd_set_output_module_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_output_module_uid");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_message_list_fd
*(void **) (&spd_get_message_list_fd_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_message_list_fd");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_list_modules
*(void **) (&spd_list_modules_dylibloader_wrapper_speechd) = dlsym(handle, "spd_list_modules");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// free_spd_modules
*(void **) (&free_spd_modules_dylibloader_wrapper_speechd) = dlsym(handle, "free_spd_modules");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_get_output_module
*(void **) (&spd_get_output_module_dylibloader_wrapper_speechd) = dlsym(handle, "spd_get_output_module");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_list_voices
*(void **) (&spd_list_voices_dylibloader_wrapper_speechd) = dlsym(handle, "spd_list_voices");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_list_synthesis_voices
*(void **) (&spd_list_synthesis_voices_dylibloader_wrapper_speechd) = dlsym(handle, "spd_list_synthesis_voices");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// free_spd_voices
*(void **) (&free_spd_voices_dylibloader_wrapper_speechd) = dlsym(handle, "free_spd_voices");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_execute_command_with_list_reply
*(void **) (&spd_execute_command_with_list_reply_dylibloader_wrapper_speechd) = dlsym(handle, "spd_execute_command_with_list_reply");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_execute_command
*(void **) (&spd_execute_command_dylibloader_wrapper_speechd) = dlsym(handle, "spd_execute_command");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_execute_command_with_reply
*(void **) (&spd_execute_command_with_reply_dylibloader_wrapper_speechd) = dlsym(handle, "spd_execute_command_with_reply");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_execute_command_wo_mutex
*(void **) (&spd_execute_command_wo_mutex_dylibloader_wrapper_speechd) = dlsym(handle, "spd_execute_command_wo_mutex");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_send_data
*(void **) (&spd_send_data_dylibloader_wrapper_speechd) = dlsym(handle, "spd_send_data");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
// spd_send_data_wo_mutex
*(void **) (&spd_send_data_wo_mutex_dylibloader_wrapper_speechd) = dlsym(handle, "spd_send_data_wo_mutex");
if (verbose) {
error = dlerror();
if (error != NULL) {
fprintf(stderr, "%s\n", error);
}
}
return 0;
}

View file

@ -0,0 +1,330 @@
#ifndef DYLIBLOAD_WRAPPER_SPEECHD
#define DYLIBLOAD_WRAPPER_SPEECHD
// This file is generated. Do not edit!
// see https://github.com/hpvb/dynload-wrapper for details
// generated by ./dynload-wrapper/generate-wrapper.py 0.3 on 2022-04-28 14:34:21
// flags: ./dynload-wrapper/generate-wrapper.py --sys-include <libspeechd.h> --include /usr/include/speech-dispatcher/libspeechd.h --soname libspeechd.so.2 --init-name speechd --omit-prefix spd_get_client_list --output-header speechd-so_wrap.h --output-implementation speechd-so_wrap.c
//
#include <stdint.h>
#define SPDConnectionAddress__free SPDConnectionAddress__free_dylibloader_orig_speechd
#define spd_get_default_address spd_get_default_address_dylibloader_orig_speechd
#define spd_open spd_open_dylibloader_orig_speechd
#define spd_open2 spd_open2_dylibloader_orig_speechd
#define spd_close spd_close_dylibloader_orig_speechd
#define spd_say spd_say_dylibloader_orig_speechd
#define spd_sayf spd_sayf_dylibloader_orig_speechd
#define spd_stop spd_stop_dylibloader_orig_speechd
#define spd_stop_all spd_stop_all_dylibloader_orig_speechd
#define spd_stop_uid spd_stop_uid_dylibloader_orig_speechd
#define spd_cancel spd_cancel_dylibloader_orig_speechd
#define spd_cancel_all spd_cancel_all_dylibloader_orig_speechd
#define spd_cancel_uid spd_cancel_uid_dylibloader_orig_speechd
#define spd_pause spd_pause_dylibloader_orig_speechd
#define spd_pause_all spd_pause_all_dylibloader_orig_speechd
#define spd_pause_uid spd_pause_uid_dylibloader_orig_speechd
#define spd_resume spd_resume_dylibloader_orig_speechd
#define spd_resume_all spd_resume_all_dylibloader_orig_speechd
#define spd_resume_uid spd_resume_uid_dylibloader_orig_speechd
#define spd_key spd_key_dylibloader_orig_speechd
#define spd_char spd_char_dylibloader_orig_speechd
#define spd_wchar spd_wchar_dylibloader_orig_speechd
#define spd_sound_icon spd_sound_icon_dylibloader_orig_speechd
#define spd_set_voice_type spd_set_voice_type_dylibloader_orig_speechd
#define spd_set_voice_type_all spd_set_voice_type_all_dylibloader_orig_speechd
#define spd_set_voice_type_uid spd_set_voice_type_uid_dylibloader_orig_speechd
#define spd_get_voice_type spd_get_voice_type_dylibloader_orig_speechd
#define spd_set_synthesis_voice spd_set_synthesis_voice_dylibloader_orig_speechd
#define spd_set_synthesis_voice_all spd_set_synthesis_voice_all_dylibloader_orig_speechd
#define spd_set_synthesis_voice_uid spd_set_synthesis_voice_uid_dylibloader_orig_speechd
#define spd_set_data_mode spd_set_data_mode_dylibloader_orig_speechd
#define spd_set_notification_on spd_set_notification_on_dylibloader_orig_speechd
#define spd_set_notification_off spd_set_notification_off_dylibloader_orig_speechd
#define spd_set_notification spd_set_notification_dylibloader_orig_speechd
#define spd_set_voice_rate spd_set_voice_rate_dylibloader_orig_speechd
#define spd_set_voice_rate_all spd_set_voice_rate_all_dylibloader_orig_speechd
#define spd_set_voice_rate_uid spd_set_voice_rate_uid_dylibloader_orig_speechd
#define spd_get_voice_rate spd_get_voice_rate_dylibloader_orig_speechd
#define spd_set_voice_pitch spd_set_voice_pitch_dylibloader_orig_speechd
#define spd_set_voice_pitch_all spd_set_voice_pitch_all_dylibloader_orig_speechd
#define spd_set_voice_pitch_uid spd_set_voice_pitch_uid_dylibloader_orig_speechd
#define spd_get_voice_pitch spd_get_voice_pitch_dylibloader_orig_speechd
#define spd_set_voice_pitch_range spd_set_voice_pitch_range_dylibloader_orig_speechd
#define spd_set_voice_pitch_range_all spd_set_voice_pitch_range_all_dylibloader_orig_speechd
#define spd_set_voice_pitch_range_uid spd_set_voice_pitch_range_uid_dylibloader_orig_speechd
#define spd_set_volume spd_set_volume_dylibloader_orig_speechd
#define spd_set_volume_all spd_set_volume_all_dylibloader_orig_speechd
#define spd_set_volume_uid spd_set_volume_uid_dylibloader_orig_speechd
#define spd_get_volume spd_get_volume_dylibloader_orig_speechd
#define spd_set_punctuation spd_set_punctuation_dylibloader_orig_speechd
#define spd_set_punctuation_all spd_set_punctuation_all_dylibloader_orig_speechd
#define spd_set_punctuation_uid spd_set_punctuation_uid_dylibloader_orig_speechd
#define spd_set_capital_letters spd_set_capital_letters_dylibloader_orig_speechd
#define spd_set_capital_letters_all spd_set_capital_letters_all_dylibloader_orig_speechd
#define spd_set_capital_letters_uid spd_set_capital_letters_uid_dylibloader_orig_speechd
#define spd_set_spelling spd_set_spelling_dylibloader_orig_speechd
#define spd_set_spelling_all spd_set_spelling_all_dylibloader_orig_speechd
#define spd_set_spelling_uid spd_set_spelling_uid_dylibloader_orig_speechd
#define spd_set_language spd_set_language_dylibloader_orig_speechd
#define spd_set_language_all spd_set_language_all_dylibloader_orig_speechd
#define spd_set_language_uid spd_set_language_uid_dylibloader_orig_speechd
#define spd_get_language spd_get_language_dylibloader_orig_speechd
#define spd_set_output_module spd_set_output_module_dylibloader_orig_speechd
#define spd_set_output_module_all spd_set_output_module_all_dylibloader_orig_speechd
#define spd_set_output_module_uid spd_set_output_module_uid_dylibloader_orig_speechd
#define spd_get_message_list_fd spd_get_message_list_fd_dylibloader_orig_speechd
#define spd_list_modules spd_list_modules_dylibloader_orig_speechd
#define free_spd_modules free_spd_modules_dylibloader_orig_speechd
#define spd_get_output_module spd_get_output_module_dylibloader_orig_speechd
#define spd_list_voices spd_list_voices_dylibloader_orig_speechd
#define spd_list_synthesis_voices spd_list_synthesis_voices_dylibloader_orig_speechd
#define free_spd_voices free_spd_voices_dylibloader_orig_speechd
#define spd_execute_command_with_list_reply spd_execute_command_with_list_reply_dylibloader_orig_speechd
#define spd_execute_command spd_execute_command_dylibloader_orig_speechd
#define spd_execute_command_with_reply spd_execute_command_with_reply_dylibloader_orig_speechd
#define spd_execute_command_wo_mutex spd_execute_command_wo_mutex_dylibloader_orig_speechd
#define spd_send_data spd_send_data_dylibloader_orig_speechd
#define spd_send_data_wo_mutex spd_send_data_wo_mutex_dylibloader_orig_speechd
#include <libspeechd.h>
#undef SPDConnectionAddress__free
#undef spd_get_default_address
#undef spd_open
#undef spd_open2
#undef spd_close
#undef spd_say
#undef spd_sayf
#undef spd_stop
#undef spd_stop_all
#undef spd_stop_uid
#undef spd_cancel
#undef spd_cancel_all
#undef spd_cancel_uid
#undef spd_pause
#undef spd_pause_all
#undef spd_pause_uid
#undef spd_resume
#undef spd_resume_all
#undef spd_resume_uid
#undef spd_key
#undef spd_char
#undef spd_wchar
#undef spd_sound_icon
#undef spd_set_voice_type
#undef spd_set_voice_type_all
#undef spd_set_voice_type_uid
#undef spd_get_voice_type
#undef spd_set_synthesis_voice
#undef spd_set_synthesis_voice_all
#undef spd_set_synthesis_voice_uid
#undef spd_set_data_mode
#undef spd_set_notification_on
#undef spd_set_notification_off
#undef spd_set_notification
#undef spd_set_voice_rate
#undef spd_set_voice_rate_all
#undef spd_set_voice_rate_uid
#undef spd_get_voice_rate
#undef spd_set_voice_pitch
#undef spd_set_voice_pitch_all
#undef spd_set_voice_pitch_uid
#undef spd_get_voice_pitch
#undef spd_set_voice_pitch_range
#undef spd_set_voice_pitch_range_all
#undef spd_set_voice_pitch_range_uid
#undef spd_set_volume
#undef spd_set_volume_all
#undef spd_set_volume_uid
#undef spd_get_volume
#undef spd_set_punctuation
#undef spd_set_punctuation_all
#undef spd_set_punctuation_uid
#undef spd_set_capital_letters
#undef spd_set_capital_letters_all
#undef spd_set_capital_letters_uid
#undef spd_set_spelling
#undef spd_set_spelling_all
#undef spd_set_spelling_uid
#undef spd_set_language
#undef spd_set_language_all
#undef spd_set_language_uid
#undef spd_get_language
#undef spd_set_output_module
#undef spd_set_output_module_all
#undef spd_set_output_module_uid
#undef spd_get_message_list_fd
#undef spd_list_modules
#undef free_spd_modules
#undef spd_get_output_module
#undef spd_list_voices
#undef spd_list_synthesis_voices
#undef free_spd_voices
#undef spd_execute_command_with_list_reply
#undef spd_execute_command
#undef spd_execute_command_with_reply
#undef spd_execute_command_wo_mutex
#undef spd_send_data
#undef spd_send_data_wo_mutex
#ifdef __cplusplus
extern "C" {
#endif
#define SPDConnectionAddress__free SPDConnectionAddress__free_dylibloader_wrapper_speechd
#define spd_get_default_address spd_get_default_address_dylibloader_wrapper_speechd
#define spd_open spd_open_dylibloader_wrapper_speechd
#define spd_open2 spd_open2_dylibloader_wrapper_speechd
#define spd_close spd_close_dylibloader_wrapper_speechd
#define spd_say spd_say_dylibloader_wrapper_speechd
#define spd_sayf spd_sayf_dylibloader_wrapper_speechd
#define spd_stop spd_stop_dylibloader_wrapper_speechd
#define spd_stop_all spd_stop_all_dylibloader_wrapper_speechd
#define spd_stop_uid spd_stop_uid_dylibloader_wrapper_speechd
#define spd_cancel spd_cancel_dylibloader_wrapper_speechd
#define spd_cancel_all spd_cancel_all_dylibloader_wrapper_speechd
#define spd_cancel_uid spd_cancel_uid_dylibloader_wrapper_speechd
#define spd_pause spd_pause_dylibloader_wrapper_speechd
#define spd_pause_all spd_pause_all_dylibloader_wrapper_speechd
#define spd_pause_uid spd_pause_uid_dylibloader_wrapper_speechd
#define spd_resume spd_resume_dylibloader_wrapper_speechd
#define spd_resume_all spd_resume_all_dylibloader_wrapper_speechd
#define spd_resume_uid spd_resume_uid_dylibloader_wrapper_speechd
#define spd_key spd_key_dylibloader_wrapper_speechd
#define spd_char spd_char_dylibloader_wrapper_speechd
#define spd_wchar spd_wchar_dylibloader_wrapper_speechd
#define spd_sound_icon spd_sound_icon_dylibloader_wrapper_speechd
#define spd_set_voice_type spd_set_voice_type_dylibloader_wrapper_speechd
#define spd_set_voice_type_all spd_set_voice_type_all_dylibloader_wrapper_speechd
#define spd_set_voice_type_uid spd_set_voice_type_uid_dylibloader_wrapper_speechd
#define spd_get_voice_type spd_get_voice_type_dylibloader_wrapper_speechd
#define spd_set_synthesis_voice spd_set_synthesis_voice_dylibloader_wrapper_speechd
#define spd_set_synthesis_voice_all spd_set_synthesis_voice_all_dylibloader_wrapper_speechd
#define spd_set_synthesis_voice_uid spd_set_synthesis_voice_uid_dylibloader_wrapper_speechd
#define spd_set_data_mode spd_set_data_mode_dylibloader_wrapper_speechd
#define spd_set_notification_on spd_set_notification_on_dylibloader_wrapper_speechd
#define spd_set_notification_off spd_set_notification_off_dylibloader_wrapper_speechd
#define spd_set_notification spd_set_notification_dylibloader_wrapper_speechd
#define spd_set_voice_rate spd_set_voice_rate_dylibloader_wrapper_speechd
#define spd_set_voice_rate_all spd_set_voice_rate_all_dylibloader_wrapper_speechd
#define spd_set_voice_rate_uid spd_set_voice_rate_uid_dylibloader_wrapper_speechd
#define spd_get_voice_rate spd_get_voice_rate_dylibloader_wrapper_speechd
#define spd_set_voice_pitch spd_set_voice_pitch_dylibloader_wrapper_speechd
#define spd_set_voice_pitch_all spd_set_voice_pitch_all_dylibloader_wrapper_speechd
#define spd_set_voice_pitch_uid spd_set_voice_pitch_uid_dylibloader_wrapper_speechd
#define spd_get_voice_pitch spd_get_voice_pitch_dylibloader_wrapper_speechd
#define spd_set_voice_pitch_range spd_set_voice_pitch_range_dylibloader_wrapper_speechd
#define spd_set_voice_pitch_range_all spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd
#define spd_set_voice_pitch_range_uid spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd
#define spd_set_volume spd_set_volume_dylibloader_wrapper_speechd
#define spd_set_volume_all spd_set_volume_all_dylibloader_wrapper_speechd
#define spd_set_volume_uid spd_set_volume_uid_dylibloader_wrapper_speechd
#define spd_get_volume spd_get_volume_dylibloader_wrapper_speechd
#define spd_set_punctuation spd_set_punctuation_dylibloader_wrapper_speechd
#define spd_set_punctuation_all spd_set_punctuation_all_dylibloader_wrapper_speechd
#define spd_set_punctuation_uid spd_set_punctuation_uid_dylibloader_wrapper_speechd
#define spd_set_capital_letters spd_set_capital_letters_dylibloader_wrapper_speechd
#define spd_set_capital_letters_all spd_set_capital_letters_all_dylibloader_wrapper_speechd
#define spd_set_capital_letters_uid spd_set_capital_letters_uid_dylibloader_wrapper_speechd
#define spd_set_spelling spd_set_spelling_dylibloader_wrapper_speechd
#define spd_set_spelling_all spd_set_spelling_all_dylibloader_wrapper_speechd
#define spd_set_spelling_uid spd_set_spelling_uid_dylibloader_wrapper_speechd
#define spd_set_language spd_set_language_dylibloader_wrapper_speechd
#define spd_set_language_all spd_set_language_all_dylibloader_wrapper_speechd
#define spd_set_language_uid spd_set_language_uid_dylibloader_wrapper_speechd
#define spd_get_language spd_get_language_dylibloader_wrapper_speechd
#define spd_set_output_module spd_set_output_module_dylibloader_wrapper_speechd
#define spd_set_output_module_all spd_set_output_module_all_dylibloader_wrapper_speechd
#define spd_set_output_module_uid spd_set_output_module_uid_dylibloader_wrapper_speechd
#define spd_get_message_list_fd spd_get_message_list_fd_dylibloader_wrapper_speechd
#define spd_list_modules spd_list_modules_dylibloader_wrapper_speechd
#define free_spd_modules free_spd_modules_dylibloader_wrapper_speechd
#define spd_get_output_module spd_get_output_module_dylibloader_wrapper_speechd
#define spd_list_voices spd_list_voices_dylibloader_wrapper_speechd
#define spd_list_synthesis_voices spd_list_synthesis_voices_dylibloader_wrapper_speechd
#define free_spd_voices free_spd_voices_dylibloader_wrapper_speechd
#define spd_execute_command_with_list_reply spd_execute_command_with_list_reply_dylibloader_wrapper_speechd
#define spd_execute_command spd_execute_command_dylibloader_wrapper_speechd
#define spd_execute_command_with_reply spd_execute_command_with_reply_dylibloader_wrapper_speechd
#define spd_execute_command_wo_mutex spd_execute_command_wo_mutex_dylibloader_wrapper_speechd
#define spd_send_data spd_send_data_dylibloader_wrapper_speechd
#define spd_send_data_wo_mutex spd_send_data_wo_mutex_dylibloader_wrapper_speechd
extern void (*SPDConnectionAddress__free_dylibloader_wrapper_speechd)( SPDConnectionAddress*);
extern SPDConnectionAddress* (*spd_get_default_address_dylibloader_wrapper_speechd)( char**);
extern SPDConnection* (*spd_open_dylibloader_wrapper_speechd)(const char*,const char*,const char*, SPDConnectionMode);
extern SPDConnection* (*spd_open2_dylibloader_wrapper_speechd)(const char*,const char*,const char*, SPDConnectionMode, SPDConnectionAddress*, int, char**);
extern void (*spd_close_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_say_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
extern int (*spd_sayf_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*,...);
extern int (*spd_stop_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_stop_all_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_stop_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
extern int (*spd_cancel_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_cancel_all_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_cancel_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
extern int (*spd_pause_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_pause_all_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_pause_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
extern int (*spd_resume_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_resume_all_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_resume_uid_dylibloader_wrapper_speechd)( SPDConnection*, int);
extern int (*spd_key_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
extern int (*spd_char_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
extern int (*spd_wchar_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority, wchar_t);
extern int (*spd_sound_icon_dylibloader_wrapper_speechd)( SPDConnection*, SPDPriority,const char*);
extern int (*spd_set_voice_type_dylibloader_wrapper_speechd)( SPDConnection*, SPDVoiceType);
extern int (*spd_set_voice_type_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDVoiceType);
extern int (*spd_set_voice_type_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDVoiceType, unsigned int);
extern SPDVoiceType (*spd_get_voice_type_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_set_synthesis_voice_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
extern int (*spd_set_synthesis_voice_all_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
extern int (*spd_set_synthesis_voice_uid_dylibloader_wrapper_speechd)( SPDConnection*,const char*, unsigned int);
extern int (*spd_set_data_mode_dylibloader_wrapper_speechd)( SPDConnection*, SPDDataMode);
extern int (*spd_set_notification_on_dylibloader_wrapper_speechd)( SPDConnection*, SPDNotification);
extern int (*spd_set_notification_off_dylibloader_wrapper_speechd)( SPDConnection*, SPDNotification);
extern int (*spd_set_notification_dylibloader_wrapper_speechd)( SPDConnection*, SPDNotification,const char*);
extern int (*spd_set_voice_rate_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_voice_rate_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_voice_rate_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
extern int (*spd_get_voice_rate_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_set_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_voice_pitch_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_voice_pitch_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
extern int (*spd_get_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_set_voice_pitch_range_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
extern int (*spd_set_volume_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_volume_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int);
extern int (*spd_set_volume_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int);
extern int (*spd_get_volume_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_set_punctuation_dylibloader_wrapper_speechd)( SPDConnection*, SPDPunctuation);
extern int (*spd_set_punctuation_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDPunctuation);
extern int (*spd_set_punctuation_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDPunctuation, unsigned int);
extern int (*spd_set_capital_letters_dylibloader_wrapper_speechd)( SPDConnection*, SPDCapitalLetters);
extern int (*spd_set_capital_letters_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDCapitalLetters);
extern int (*spd_set_capital_letters_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDCapitalLetters, unsigned int);
extern int (*spd_set_spelling_dylibloader_wrapper_speechd)( SPDConnection*, SPDSpelling);
extern int (*spd_set_spelling_all_dylibloader_wrapper_speechd)( SPDConnection*, SPDSpelling);
extern int (*spd_set_spelling_uid_dylibloader_wrapper_speechd)( SPDConnection*, SPDSpelling, unsigned int);
extern int (*spd_set_language_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
extern int (*spd_set_language_all_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
extern int (*spd_set_language_uid_dylibloader_wrapper_speechd)( SPDConnection*,const char*, unsigned int);
extern char* (*spd_get_language_dylibloader_wrapper_speechd)( SPDConnection*);
extern int (*spd_set_output_module_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
extern int (*spd_set_output_module_all_dylibloader_wrapper_speechd)( SPDConnection*,const char*);
extern int (*spd_set_output_module_uid_dylibloader_wrapper_speechd)( SPDConnection*,const char*, unsigned int);
extern int (*spd_get_message_list_fd_dylibloader_wrapper_speechd)( SPDConnection*, int, int*, char**);
extern char** (*spd_list_modules_dylibloader_wrapper_speechd)( SPDConnection*);
extern void (*free_spd_modules_dylibloader_wrapper_speechd)( char**);
extern char* (*spd_get_output_module_dylibloader_wrapper_speechd)( SPDConnection*);
extern char** (*spd_list_voices_dylibloader_wrapper_speechd)( SPDConnection*);
extern SPDVoice** (*spd_list_synthesis_voices_dylibloader_wrapper_speechd)( SPDConnection*);
extern void (*free_spd_voices_dylibloader_wrapper_speechd)( SPDVoice**);
extern char** (*spd_execute_command_with_list_reply_dylibloader_wrapper_speechd)( SPDConnection*, char*);
extern int (*spd_execute_command_dylibloader_wrapper_speechd)( SPDConnection*, char*);
extern int (*spd_execute_command_with_reply_dylibloader_wrapper_speechd)( SPDConnection*, char*, char**);
extern int (*spd_execute_command_wo_mutex_dylibloader_wrapper_speechd)( SPDConnection*, char*);
extern char* (*spd_send_data_dylibloader_wrapper_speechd)( SPDConnection*,const char*, int);
extern char* (*spd_send_data_wo_mutex_dylibloader_wrapper_speechd)( SPDConnection*,const char*, int);
int initialize_speechd(int verbose);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,261 @@
/*************************************************************************/
/* tts_linux.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* 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 "tts_linux.h"
#include "core/config/project_settings.h"
#include "servers/text_server.h"
TTS_Linux *TTS_Linux::singleton = nullptr;
void TTS_Linux::speech_init_thread_func(void *p_userdata) {
TTS_Linux *tts = (TTS_Linux *)p_userdata;
if (tts) {
MutexLock thread_safe_method(tts->_thread_safe_);
#ifdef DEBUG_ENABLED
int dylibloader_verbose = 1;
#else
int dylibloader_verbose = 0;
#endif
if (initialize_speechd(dylibloader_verbose) == 0) {
CharString class_str;
String config_name = GLOBAL_GET("application/config/name");
if (config_name.length() == 0) {
class_str = "Godot_Engine";
} else {
class_str = config_name.utf8();
}
tts->synth = spd_open(class_str, "Godot_Engine_Speech_API", "Godot_Engine", SPD_MODE_THREADED);
if (tts->synth) {
tts->synth->callback_end = &speech_event_callback;
tts->synth->callback_cancel = &speech_event_callback;
tts->synth->callback_im = &speech_event_index_mark;
spd_set_notification_on(tts->synth, SPD_END);
spd_set_notification_on(tts->synth, SPD_CANCEL);
print_verbose("Text-to-Speech: Speech Dispatcher initialized.");
} else {
print_verbose("Text-to-Speech: Cannot initialize Speech Dispatcher synthesizer!");
}
} else {
print_verbose("Text-to-Speech: Cannot load Speech Dispatcher library!");
}
}
}
void TTS_Linux::speech_event_index_mark(size_t p_msg_id, size_t p_client_id, SPDNotificationType p_type, char *p_index_mark) {
TTS_Linux *tts = TTS_Linux::get_singleton();
if (tts && tts->ids.has(p_msg_id)) {
MutexLock thread_safe_method(tts->_thread_safe_);
// Get word offset from the index mark injected to the text stream.
String mark = String::utf8(p_index_mark);
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_BOUNDARY, tts->ids[p_msg_id], mark.to_int());
}
}
void TTS_Linux::speech_event_callback(size_t p_msg_id, size_t p_client_id, SPDNotificationType p_type) {
TTS_Linux *tts = TTS_Linux::get_singleton();
if (tts) {
MutexLock thread_safe_method(tts->_thread_safe_);
List<DisplayServer::TTSUtterance> &queue = tts->queue;
if (!tts->paused && tts->ids.has(p_msg_id)) {
if (p_type == SPD_EVENT_END) {
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_ENDED, tts->ids[p_msg_id]);
tts->ids.erase(p_msg_id);
tts->last_msg_id = -1;
tts->speaking = false;
} else if (p_type == SPD_EVENT_CANCEL) {
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, tts->ids[p_msg_id]);
tts->ids.erase(p_msg_id);
tts->last_msg_id = -1;
tts->speaking = false;
}
}
if (!tts->speaking && queue.size() > 0) {
DisplayServer::TTSUtterance &message = queue.front()->get();
// Inject index mark after each word.
String text;
String language;
SPDVoice **voices = spd_list_synthesis_voices(tts->synth);
if (voices != nullptr) {
SPDVoice **voices_ptr = voices;
while (*voices_ptr != nullptr) {
if (String::utf8((*voices_ptr)->name) == message.voice) {
language = String::utf8((*voices_ptr)->language);
break;
}
voices_ptr++;
}
free_spd_voices(voices);
}
PackedInt32Array breaks = TS->string_get_word_breaks(message.text, language);
int prev = 0;
for (int i = 0; i < breaks.size(); i++) {
text += message.text.substr(prev, breaks[i] - prev);
text += "<mark name=\"" + String::num_int64(breaks[i], 10) + "\"/>";
prev = breaks[i];
}
text += message.text.substr(prev, -1);
spd_set_synthesis_voice(tts->synth, message.voice.utf8().get_data());
spd_set_volume(tts->synth, message.volume * 2 - 100);
spd_set_voice_pitch(tts->synth, (message.pitch - 1) * 100);
float rate = 0;
if (message.rate > 1.f) {
rate = log10(MIN(message.rate, 2.5f)) / log10(2.5f) * 100;
} else if (message.rate < 1.f) {
rate = log10(MAX(message.rate, 0.5f)) / log10(0.5f) * -100;
}
spd_set_voice_rate(tts->synth, rate);
spd_set_data_mode(tts->synth, SPD_DATA_SSML);
tts->last_msg_id = spd_say(tts->synth, SPD_TEXT, text.utf8().get_data());
tts->ids[tts->last_msg_id] = message.id;
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_STARTED, message.id);
queue.pop_front();
tts->speaking = true;
}
}
}
bool TTS_Linux::is_speaking() const {
return speaking;
}
bool TTS_Linux::is_paused() const {
return paused;
}
Array TTS_Linux::get_voices() const {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND_V(!synth, Array());
Array list;
SPDVoice **voices = spd_list_synthesis_voices(synth);
if (voices != nullptr) {
SPDVoice **voices_ptr = voices;
while (*voices_ptr != nullptr) {
Dictionary voice_d;
voice_d["name"] = String::utf8((*voices_ptr)->name);
voice_d["id"] = String::utf8((*voices_ptr)->name);
voice_d["language"] = String::utf8((*voices_ptr)->language) + "_" + String::utf8((*voices_ptr)->variant);
list.push_back(voice_d);
voices_ptr++;
}
free_spd_voices(voices);
}
return list;
}
void TTS_Linux::speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!synth);
if (p_interrupt) {
stop();
}
if (p_text.is_empty()) {
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, p_utterance_id);
return;
}
DisplayServer::TTSUtterance message;
message.text = p_text;
message.voice = p_voice;
message.volume = CLAMP(p_volume, 0, 100);
message.pitch = CLAMP(p_pitch, 0.f, 2.f);
message.rate = CLAMP(p_rate, 0.1f, 10.f);
message.id = p_utterance_id;
queue.push_back(message);
if (is_paused()) {
resume();
} else {
speech_event_callback(0, 0, SPD_EVENT_BEGIN);
}
}
void TTS_Linux::pause() {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!synth);
if (spd_pause(synth) == 0) {
paused = true;
}
}
void TTS_Linux::resume() {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!synth);
spd_resume(synth);
paused = false;
}
void TTS_Linux::stop() {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!synth);
for (DisplayServer::TTSUtterance &message : queue) {
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, message.id);
}
if ((last_msg_id != -1) && ids.has(last_msg_id)) {
DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, ids[last_msg_id]);
}
queue.clear();
ids.clear();
last_msg_id = -1;
spd_cancel(synth);
spd_resume(synth);
speaking = false;
paused = false;
}
TTS_Linux *TTS_Linux::get_singleton() {
return singleton;
}
TTS_Linux::TTS_Linux() {
singleton = this;
// Speech Dispatcher init can be slow, it might wait for helper process to start on background, so run it in the thread.
init_thread.start(speech_init_thread_func, this);
}
TTS_Linux::~TTS_Linux() {
init_thread.wait_to_finish();
if (synth) {
spd_close(synth);
}
singleton = nullptr;
}

View file

@ -0,0 +1,78 @@
/*************************************************************************/
/* tts_linux.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* 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. */
/*************************************************************************/
#ifndef TTS_LINUX_H
#define TTS_LINUX_H
#include "core/os/thread.h"
#include "core/os/thread_safe.h"
#include "core/string/ustring.h"
#include "core/templates/list.h"
#include "core/templates/map.h"
#include "core/variant/array.h"
#include "servers/display_server.h"
#include "speechd-so_wrap.h"
class TTS_Linux {
_THREAD_SAFE_CLASS_
List<DisplayServer::TTSUtterance> queue;
SPDConnection *synth = nullptr;
bool speaking = false;
bool paused = false;
int last_msg_id = -1;
Map<int, int> ids;
Thread init_thread;
static void speech_init_thread_func(void *p_userdata);
static void speech_event_callback(size_t p_msg_id, size_t p_client_id, SPDNotificationType p_type);
static void speech_event_index_mark(size_t p_msg_id, size_t p_client_id, SPDNotificationType p_type, char *p_index_mark);
static TTS_Linux *singleton;
public:
static TTS_Linux *get_singleton();
bool is_speaking() const;
bool is_paused() const;
Array get_voices() const;
void speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false);
void pause();
void resume();
void stop();
TTS_Linux();
~TTS_Linux();
};
#endif // TTS_LINUX_H