diff options
| author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-07-05 12:49:16 +0300 |
|---|---|---|
| committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-06-21 14:56:57 +0300 |
| commit | b5e3238109a67b5c59ddb90c0646655f1d9d506c (patch) | |
| tree | b98007b8996ec5bd79fe6d7bf4c82580d8f2d65b /platform/linuxbsd | |
| parent | 04a530f91fc83b41112007dbd2ce02e9528df682 (diff) | |
| download | redot-engine-b5e3238109a67b5c59ddb90c0646655f1d9d506c.tar.gz | |
[TextServer] Fix get_word_breaks and it uses.
Diffstat (limited to 'platform/linuxbsd')
| -rw-r--r-- | platform/linuxbsd/tts_linux.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
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 += "<mark name=\"" + String::num_int64(end, 10) + "\"/>"; + 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); |
