From b5e3238109a67b5c59ddb90c0646655f1d9d506c Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 5 Jul 2023 12:49:16 +0300 Subject: [TextServer] Fix get_word_breaks and it uses. --- platform/linuxbsd/tts_linux.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'platform/linuxbsd') diff --git a/platform/linuxbsd/tts_linux.cpp b/platform/linuxbsd/tts_linux.cpp index 46291bb4da..6c1f49f046 100644 --- a/platform/linuxbsd/tts_linux.cpp +++ b/platform/linuxbsd/tts_linux.cpp @@ -149,12 +149,18 @@ void TTS_Linux::_speech_event(int p_msg_id, int p_type) { } PackedInt32Array breaks = TS->string_get_word_breaks(message.text, language); + int prev_end = -1; for (int i = 0; i < breaks.size(); i += 2) { const int start = breaks[i]; const int end = breaks[i + 1]; - text += message.text.substr(start, end - start + 1); + if (prev_end != -1 && prev_end != start) { + text += message.text.substr(prev_end, start - prev_end); + } + text += message.text.substr(start, end - start); text += ""; + prev_end = end; } + spd_set_synthesis_voice(synth, message.voice.utf8().get_data()); spd_set_volume(synth, message.volume * 2 - 100); spd_set_voice_pitch(synth, (message.pitch - 1) * 100); -- cgit v1.2.3