Skip to content

Commit

Permalink
Fix #2823 (Non bible tts should split more aggressively)
Browse files Browse the repository at this point in the history
Set max length of 250 char to end sentence anyway
  • Loading branch information
tuomas2 committed Sep 9, 2023
1 parent 5facf08 commit c120561
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SpeakCommandArray: ArrayList<SpeakCommand>() {
}
private val endsWithSentenceBreak = Regex(""".*[.?!]+[\p{Pf}"']*\W*""", RegexOption.DOT_MATCHES_ALL)
private val splitIntoTwoSentences = Regex("""(.*)([.?!]+[\p{Pf}"']*)(\W*.+)""", RegexOption.DOT_MATCHES_ALL)
private val startsWithDelimeter = Regex("""([,.?!"':;()]+|'s)(\p{Zs}.*|)""", RegexOption.DOT_MATCHES_ALL)
private val startsWithDelimiter = Regex("""([,.?!"':;()]+|'s)(\p{Zs}.*|)""", RegexOption.DOT_MATCHES_ALL)

fun copy(): SpeakCommandArray {
val cmds = SpeakCommandArray()
Expand All @@ -108,7 +108,7 @@ class SpeakCommandArray: ArrayList<SpeakCommand>() {
get() {
val lastCommand = this.lastOrNull()
if (lastCommand is TextCommand) {
return lastCommand.text.matches(endsWithSentenceBreak)
return lastCommand.text.matches(endsWithSentenceBreak) || lastCommand.text.length > 250
}
return true
}
Expand Down Expand Up @@ -148,7 +148,7 @@ class SpeakCommandArray: ArrayList<SpeakCommand>() {
if(element.text.isEmpty())
return false
return if(lastCommand is TextCommand) {
val newText = if(startsWithDelimeter.matches(element.text))
val newText = if(startsWithDelimiter.matches(element.text))
"${lastCommand.text}${element.text}"
else
"${lastCommand.text} ${element.text}"
Expand Down

0 comments on commit c120561

Please sign in to comment.