react-text-to-speech
Version:
An easy-to-use React.js library that leverages the Web Speech API to convert text to speech.
45 lines (41 loc) • 2.16 kB
TypeScript
import React, { ReactNode } from 'react';
import { SpeechUtterancesQueue, UseSpeakOptions, DivProps, SpeechStatus, SpeechSynthesisUtteranceProps, UseSpeechOptions, UseSpeechOptionsInternal } from './types.js';
declare function dequeue(index?: number): void;
declare function useQueue(): {
queue: SpeechUtterancesQueue;
dequeue: typeof dequeue;
clearQueue: () => void;
};
declare function useSpeak(options?: UseSpeakOptions): {
Text: React.ForwardRefExoticComponent<Omit<DivProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
speechStatus: SpeechStatus;
isInQueue: boolean;
pause: () => void;
stop: () => void;
speak: (text: ReactNode, options?: SpeechSynthesisUtteranceProps) => void;
start: () => void;
};
declare function useSpeech(speechProps: UseSpeechOptions): {
Text: React.ForwardRefExoticComponent<Omit<DivProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
speechStatus: SpeechStatus;
isInQueue: boolean;
start: () => void;
pause: () => void;
stop: () => void;
};
declare function useSpeechInternal({ id, text, pitch, rate, volume, lang, voiceURI, autoPlay, preserveUtteranceQueue, highlightText, showOnlyHighlightedText, highlightMode, highlightProps, highlightContainerProps, enableDirectives, updateMode, updateDelay, maxChunkSize, onError, onStart, onResume, onPause, onStop, onBoundary, onQueueChange, }: UseSpeechOptionsInternal): {
uniqueId: string;
normalizedText: string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
reactContent: React.ReactNode;
Text: React.ForwardRefExoticComponent<Omit<DivProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
speechStatus: SpeechStatus;
isInQueue: boolean;
start: () => void;
pause: () => void;
stop: () => void;
};
declare function useVoices(): {
languages: string[];
voices: SpeechSynthesisVoice[];
};
export { useQueue, useSpeak, useSpeech, useSpeechInternal, useVoices };