diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-08-18 16:20:20 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-12-16 13:18:57 +0800 |
commit | 207e52c161a44869f1af022030c3129b8c38a5f7 (patch) | |
tree | 3df831f12e9ded2b734b37d61837d2a35afbf685 /platform/linuxbsd | |
parent | f18f2740da9cce7383c2aa41fe8d081d56c8b6cf (diff) |
Fix String::word_wrap() for long words
- Changes `TextServer.string_get_word_breaks()`
- Returns pairs of boundary start and end offsets
- Accepts `chars_per_line` to return line breaks
- Removes `String::word_wrap()`
Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
Diffstat (limited to 'platform/linuxbsd')
-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); |