diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-16 13:47:05 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-16 13:47:05 +0100 |
commit | 912fd3f0e15c3363809e0d69fb94207166aa4f37 (patch) | |
tree | b41ce89066c4a1baff37877ac82599d7b8dbed65 /platform | |
parent | 49a60b1d1c4d62fec1be89e4878433b6c3220ce0 (diff) | |
parent | 207e52c161a44869f1af022030c3129b8c38a5f7 (diff) |
Merge pull request #64563 from timothyqiu/word-wrap
Fix `String::word_wrap()` for long words
Diffstat (limited to 'platform')
-rw-r--r-- | platform/linuxbsd/tts_linux.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/platform/linuxbsd/tts_linux.cpp b/platform/linuxbsd/tts_linux.cpp index aea1183d3d..8fa708aad6 100644 --- a/platform/linuxbsd/tts_linux.cpp +++ b/platform/linuxbsd/tts_linux.cpp @@ -117,13 +117,12 @@ void TTS_Linux::speech_event_callback(size_t p_msg_id, size_t p_client_id, SPDNo 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]; + 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); + text += "<mark name=\"" + String::num_int64(end, 10) + "\"/>"; } - 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); |