react-text-to-speech
Advanced tools
Comparing version 0.14.4 to 0.14.5
@@ -9,3 +9,3 @@ import React, { cloneElement, isValidElement, useEffect, useMemo, useRef, useState } from "react"; | ||
} | ||
export function useSpeech({ text, pitch = 1, rate = 1, volume = 1, lang, voiceURI, highlightText = false, highlightProps = { style: { backgroundColor: "yellow" } }, preserveUtteranceQueue = false, onError = console.error, onStart, onResume, onPause, onStop, onBoundary, onQueueChange, }) { | ||
export function useSpeech({ text, pitch = 1, rate = 1, volume = 1, lang, voiceURI, highlightText = false, highlightProps, preserveUtteranceQueue = false, onError = console.error, onStart, onResume, onPause, onStop, onBoundary, onQueueChange, }) { | ||
const [speechStatus, speechStatusRef, setSpeechStatus] = useStateRef("stopped"); | ||
@@ -122,3 +122,3 @@ const [speakingWord, setSpeakingWord] = useState(); | ||
element.slice(0, before), | ||
React.createElement("span", Object.assign({}, highlightProps), element.slice(before, before + length)), | ||
React.createElement("mark", Object.assign({}, highlightProps), element.slice(before, before + length)), | ||
element.slice(before + length))); | ||
@@ -125,0 +125,0 @@ } |
{ | ||
"name": "react-text-to-speech", | ||
"version": "0.14.4", | ||
"version": "0.14.5", | ||
"description": "An easy to use react component for the Web Speech API.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -370,3 +370,3 @@ # react-text-to-speech | ||
| `highlightText` | `boolean` | No | `false` | Whether the words in the text should be highlighted as they are read or not. | | ||
| `highlightProps` | `React.DetailedHTMLProps` | No | `{ style: { backgroundColor: "yellow" } }` | Props to customise the highlighted word. | | ||
| `highlightProps` | `React.DetailedHTMLProps` | No | - | Props to customize the highlighted word, typically applied to the `<mark>` tag. | | ||
| `preserveUtteranceQueue` | `boolean` | No | `false` | Whether to maintain a queue of speech utterances (true) or clear previous utterances (false). | | ||
@@ -373,0 +373,0 @@ | `onError` | [`SpeechSynthesisErrorHandler`](#speechsynthesiserrorhandler) | No | `console.error` | Function to be executed if browser doesn't support `Web Speech API`. | |
38101