Mike0021 commited on
Commit
76584bc
·
verified ·
1 Parent(s): a8d137f

Fix first TTS word boundary

Browse files
Files changed (1) hide show
  1. app.js +2 -2
app.js CHANGED
@@ -2123,10 +2123,10 @@ function findBoundary(text, final) {
2123
  const minSpace = firstChunk ? chunking.firstMinSpaceChars : chunking.minSpaceChars;
2124
  if (text.length >= targetLength) {
2125
  const space = text.lastIndexOf(" ", targetLength);
2126
- if (space > minSpace) return boundaryAt(text, space, "space-before-target");
2127
  const maxForward = targetLength * 2;
2128
  const nextSpace = text.indexOf(" ", targetLength);
2129
- if (nextSpace > minSpace && nextSpace <= maxForward) return boundaryAt(text, nextSpace, "space-after-target");
2130
  if (firstChunk && text.length < maxForward) return null;
2131
  return boundaryAt(text, targetLength, "hard-limit");
2132
  }
 
2123
  const minSpace = firstChunk ? chunking.firstMinSpaceChars : chunking.minSpaceChars;
2124
  if (text.length >= targetLength) {
2125
  const space = text.lastIndexOf(" ", targetLength);
2126
+ if (space >= minSpace) return boundaryAt(text, space, "space-before-target");
2127
  const maxForward = targetLength * 2;
2128
  const nextSpace = text.indexOf(" ", targetLength);
2129
+ if (nextSpace >= minSpace && nextSpace <= maxForward) return boundaryAt(text, nextSpace, "space-after-target");
2130
  if (firstChunk && text.length < maxForward) return null;
2131
  return boundaryAt(text, targetLength, "hard-limit");
2132
  }