From d5b284e25c7a78bcc04590c1b23d8e55349d7241 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 26 Sep 2022 19:09:50 +0800 Subject: [PATCH] Start at index 3, because the frontend starts two nodes above the backend --- packages/text-to-speech/src/htmlToSsml.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/text-to-speech/src/htmlToSsml.ts b/packages/text-to-speech/src/htmlToSsml.ts index ef55b09b1..8f1ff1d2f 100644 --- a/packages/text-to-speech/src/htmlToSsml.ts +++ b/packages/text-to-speech/src/htmlToSsml.ts @@ -228,9 +228,9 @@ export const htmlToSsmlItems = ( } const items: SSMLItem[] = [] - for (let i = 2; i < parsedNodes.length + 2; i++) { + for (let i = 3; i < parsedNodes.length + 3; i++) { const textItems: string[] = [] - const node = parsedNodes[i - 2] + const node = parsedNodes[i - 3] if (TOP_LEVEL_TAGS.includes(node.nodeName) || hasSignificantText(node)) { const idx = i @@ -342,10 +342,10 @@ export const htmlToSpeechFile = (htmlInput: HtmlInput): SpeechFile => { wordOffset += titleUtterance.wordCount } - // start at 2 to skip the #readability-content and #readability-page-1 elements - for (let i = 2; i < parsedNodes.length + 2; i++) { + // start at 3 to skip the #readability-content and #readability-page-1 elements + for (let i = 3; i < parsedNodes.length + 3; i++) { const textItems: string[] = [] - const node = parsedNodes[i - 2] + const node = parsedNodes[i - 3] if (TOP_LEVEL_TAGS.includes(node.nodeName) || hasSignificantText(node)) { // use paragraph as anchor