react-text-to-speech
Advanced tools
Comparing version
@@ -208,8 +208,7 @@ import { __spreadValues, __objRest, HiVolumeUp, HiVolumeOff, HiMiniStop } from './chunks/chunk-3KTCESQJ.js'; | ||
const key = useMemo(() => NodeToKey(text), [text]); | ||
const { words, sanitizedText, chunks, numChunks } = useMemo(() => { | ||
const { words, sanitizedText } = useMemo(() => { | ||
const words2 = NodeToWords(text); | ||
const sanitizedText2 = sanitize(WordsToText(words2)); | ||
const chunks2 = TextToChunks(sanitizedText2, maxChunkSize); | ||
return { words: words2, sanitizedText: sanitizedText2, chunks: chunks2, numChunks: chunks2.length }; | ||
return { words: words2, sanitizedText: sanitize(WordsToText(words2)) }; | ||
}, [key]); | ||
const chunks = useMemo(() => TextToChunks(sanitizedText, maxChunkSize), [sanitizedText, maxChunkSize]); | ||
const reactContent = useMemo(() => highlightedText(text), [speakingWord, words, highlightText, showOnlyHighlightedText]); | ||
@@ -229,4 +228,3 @@ const Text = useCallback(() => reactContent, [reactContent]); | ||
const stopEventHandler = (event) => { | ||
var _a; | ||
if (state.stopReason === "auto" && currentChunk < numChunks - 1) { | ||
if (state.stopReason === "auto" && currentChunk < chunks.length - 1) { | ||
offset += utterance.text.length; | ||
@@ -240,5 +238,6 @@ currentText = chunks[++currentChunk]; | ||
if (speakingWordRef.current) { | ||
let currentLength = utterance.text.length; | ||
utterance.text = utterance.text.slice(((_a = speakingWordRef.current) == null ? void 0 : _a.charIndex) || 0).trimStart(); | ||
const currentLength = utterance.text.length; | ||
utterance.text = utterance.text.slice(speakingWordRef.current.charIndex).trimStart(); | ||
offset += currentLength - utterance.text.length; | ||
setSpeakingWord(null); | ||
} | ||
@@ -245,0 +244,0 @@ return speakFromQueue(); |
{ | ||
"name": "react-text-to-speech", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "An easy-to-use React.js component that leverages the Web Speech API to convert text to speech.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -57,3 +57,3 @@ # react-text-to-speech | ||
speechStatus, // Current speech status | ||
isInQueue, // Indicates if the speech is active or queued | ||
isInQueue, // Indicates whether the speech is currently playing or waiting in the queue | ||
start, // Starts or queues the speech | ||
@@ -60,0 +60,0 @@ pause, // Pauses the speech |
32302
-0.14%584
-0.17%