diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-01-11 11:51:46 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-01-11 11:51:46 +0300 |
| commit | 287ac9871576cfbdee6997d89ce1f9df555e640e (patch) | |
| tree | fa4433c1406a736c6c2f40f6c96ba9bf59844d73 /extra/tts.go | |
| parent | 1c818cce863836e7c9cb535651dd2ce3c39c2bc9 (diff) | |
Enha(tts): split remaining text on sentences; update build tags
Diffstat (limited to 'extra/tts.go')
| -rw-r--r-- | extra/tts.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/extra/tts.go b/extra/tts.go index e5bbec5..96c8859 100644 --- a/extra/tts.go +++ b/extra/tts.go @@ -165,17 +165,18 @@ func (o *KokoroOrator) readroutine() { } } } - // INFO: if there is a lot of text it will take some time to make with tts at once - // to avoid this pause, it might be better to keep splitting on sentences - // but keepinig in mind that remainder could be ommited by tokenizer - // Flush remaining text + // flush remaining text remaining := o.textBuffer.String() remaining = cleanText(remaining) o.textBuffer.Reset() - if remaining != "" { - o.logger.Debug("calling Speak with remainder", "rem", remaining) - if err := o.Speak(remaining); err != nil { - o.logger.Error("tts failed", "sentence", remaining, "error", err) + if remaining == "" { + continue + } + o.logger.Debug("calling Speak with remainder", "rem", remaining) + sentencesRem := tokenizer.Tokenize(remaining) + for _, rs := range sentencesRem { // to avoid dumping large volume of text + if err := o.Speak(rs.Text); err != nil { + o.logger.Error("tts failed", "sentence", rs, "error", err) } } } @@ -364,10 +365,14 @@ func (o *GoogleTranslateOrator) readroutine() { remaining := o.textBuffer.String() remaining = cleanText(remaining) o.textBuffer.Reset() - if remaining != "" { - o.logger.Debug("calling Speak with remainder", "rem", remaining) - if err := o.Speak(remaining); err != nil { - o.logger.Error("tts failed", "sentence", remaining, "error", err) + if remaining == "" { + continue + } + o.logger.Debug("calling Speak with remainder", "rem", remaining) + sentencesRem := tokenizer.Tokenize(remaining) + for _, rs := range sentencesRem { // to avoid dumping large volume of text + if err := o.Speak(rs.Text); err != nil { + o.logger.Error("tts failed", "sentence", rs.Text, "error", err) } } } |
