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
125
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

to
0.17.0

2

dist/hooks.d.ts

@@ -9,3 +9,3 @@ import React from "react";

};
export declare function useSpeech({ text, pitch, rate, volume, lang, voiceURI, highlightText, highlightProps, preserveUtteranceQueue, onError, onStart, onResume, onPause, onStop, onBoundary, onQueueChange, }: useSpeechProps): {
export declare function useSpeech({ text, pitch, rate, volume, lang, voiceURI, highlightText, highlightProps, preserveUtteranceQueue, maxChunkSize, onError, onStart, onResume, onPause, onStop, onBoundary, onQueueChange, }: useSpeechProps): {
Text: () => React.ReactNode;

@@ -12,0 +12,0 @@ speechStatus: SpeechStatus;

@@ -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, 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, maxChunkSize, onError = console.error, onStart, onResume, onPause, onStop, onBoundary, onQueueChange, }) {
const [speechStatus, speechStatusRef, setSpeechStatus] = useStateRef("stopped");

@@ -27,3 +27,3 @@ const [speakingWord, setSpeakingWord] = useState();

return;
const chunks = TextToChunks(sanitize(ArrayToText(words)));
const chunks = TextToChunks(sanitize(ArrayToText(words)), maxChunkSize);
const numChunks = chunks.length;

@@ -30,0 +30,0 @@ let currentChunk = 0, offset = 0;

@@ -16,2 +16,3 @@ import { DetailedHTMLProps, HTMLAttributes, ReactNode } from "react";

preserveUtteranceQueue?: boolean;
maxChunkSize?: number;
onError?: SpeechSynthesisErrorHandler;

@@ -18,0 +19,0 @@ onStart?: SpeechSynthesisEventHandler;

@@ -6,3 +6,3 @@ import { ReactNode } from "react";

export declare function cancel(): void;
export declare function TextToChunks(text: string, desktopSize?: number, mobileSize?: number): string[];
export declare function TextToChunks(text: string, size?: number): string[];
export declare function findCharIndex(words: StringArray, index: number): string;

@@ -9,0 +9,0 @@ export declare const getIndex: (parentIndex: Index, index: Index) => string;

@@ -21,5 +21,6 @@ import { isValidElement } from "react";

}
export function TextToChunks(text, desktopSize = 1000, mobileSize = 250) {
export function TextToChunks(text, size) {
const length = text.length;
const size = isMobile() ? mobileSize : desktopSize;
if (!size)
size = isMobile() ? 250 : 1000;
const result = [];

@@ -26,0 +27,0 @@ let startIndex = 0;

{
"name": "react-text-to-speech",
"version": "0.16.3",
"version": "0.17.0",
"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",

@@ -7,9 +7,10 @@ # react-text-to-speech

- Text-to-speech
- Text-to-speech functionality
- Easy to use
- Highlights words as they are read. See highlighting text using [useSpeech Hook](https://rtts.vercel.app/docs/usage/useSpeech#highlight-text) and [Speech Component](https://rtts.vercel.app/docs/usage/speech#highlight-text)
- Provides API to handle errors and events. See [Handling Errors and Events](https://rtts.vercel.app/docs/usage/useSpeech#handling-errors-and-events)
- Handles multiple speech instances easily. See handling using [useSpeech Hook](https://rtts.vercel.app/docs/usage/useSpeech#multiple-instance-usage) and [Speech Component](https://rtts.vercel.app/docs/usage/speech#multiple-instance-usage)
- Fully Customizable. See [useSpeech Hook Usage](https://rtts.vercel.app/docs/usage/useSpeech) and [usage with FaC](https://rtts.vercel.app/docs/usage/speech#full-customization)
- Stops speech instance on component unmount.
- Highlights words as they are read (see highlighting text using [useSpeech Hook](/docs/usage/useSpeech#highlight-text) and [Speech Component](/docs/usage/speech#highlight-text)).
- Provides API to handle errors and events (see [Handling Errors and Events](/docs/usage/useSpeech#handling-errors-and-events)).
- Handles multiple speech instances easily (see handling using [useSpeech Hook](/docs/usage/useSpeech#multiple-instance-usage) and [Speech Component](/docs/usage/speech#multiple-instance-usage)).
- Fully Customizable (see [useSpeech Hook Usage](/docs/usage/useSpeech) and [usage with FaC](/docs/usage/speech#full-customization)).
- Overcomes the [Web Speech API's text limit](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/text), allowing for infinite text input.
- Automatically stops speech instances on component unmount.

@@ -16,0 +17,0 @@ ## Installation