New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-text-to-speech

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-text-to-speech - npm Package Compare versions

Comparing version 0.8.2 to 0.8.3

44

dist/index.js

@@ -23,3 +23,3 @@ var __rest = (this && this.__rest) || function (s, e) {

if (typeof element === "string")
return element.split(" ");
return element.split(/\s/);
if (typeof element === "number")

@@ -32,18 +32,21 @@ return [element.toString()];

function recursiveSearch(subArray, parentIndex) {
for (let i = 0; i < subArray.length; i++) {
const element = subArray[i];
if (Array.isArray(element)) {
const result = recursiveSearch(element, i);
if (result !== null)
return `${parentIndex === null ? "" : parentIndex + "-"}${result}`;
if (subArray.length)
for (let i = 0; i < subArray.length; i++) {
const element = subArray[i];
if (Array.isArray(element)) {
const result = recursiveSearch(element, i);
if (result !== null)
return `${parentIndex === undefined ? "" : parentIndex + "-"}${result}`;
}
else {
currentIndex += element.length + 1;
if (currentIndex > index)
return `${parentIndex === undefined ? "" : parentIndex + "-"}${i}`;
}
}
else if (element) {
currentIndex += element.length + 1;
if (currentIndex > index)
return `${parentIndex === null ? "" : parentIndex + "-"}${i}`;
}
}
else
currentIndex++;
return null;
}
return recursiveSearch(words, null);
return recursiveSearch(words);
}

@@ -67,3 +70,3 @@ export default function Speech({ text, id, pitch = 1, rate = 1, volume = 1, lang, voiceURI, startBtn = React.createElement(HiVolumeUp, null), pauseBtn = React.createElement(HiVolumeOff, null), stopBtn = React.createElement(HiMiniStop, null), useStopOverPause, highlightText = false, highlightProps = { style: { fontWeight: "bold" } }, onError = () => alert("Browser not supported! Try some other browser."), props = {}, children, }) {

synth.cancel();
const utterance = new window.SpeechSynthesisUtterance(words.join(" ").replace(/\s|,/g, " "));
const utterance = new window.SpeechSynthesisUtterance(words.join(" ").replace(",", " "));
utterance.pitch = pitch;

@@ -113,8 +116,11 @@ utterance.rate = rate;

if (typeof element === "string" || typeof element === "number") {
const words = String(element).split(" ");
element = element.toString();
const words = element.split(/\s/);
const index = +highlightedIndex.split("-").at(-1);
const before = index ? words.slice(0, index).join(" ").length : -1;
const highlightedWord = words[index];
return (React.createElement(Fragment, { key: highlightedIndex },
words.slice(0, index).join(" ") + " ",
React.createElement("span", Object.assign({}, highlightProps), words[index]),
" " + words.slice(index + 1).join(" ")));
element.slice(0, before + 1),
React.createElement("span", Object.assign({}, highlightProps), highlightedWord),
element.slice(before + 1 + highlightedWord.length)));
}

@@ -121,0 +127,0 @@ return element;

{
"name": "react-text-to-speech",
"version": "0.8.2",
"version": "0.8.3",
"description": "An easy to use react component for the Web Speech API.",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc