mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 14:11:15 +00:00
[TextServer] Fix get_word_breaks and it uses.
This commit is contained in:
parent
04a530f91f
commit
b5e3238109
5 changed files with 192 additions and 113 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue