react text to speech
1.0.0
一个易于使用的React.js组件,它利用Web语音API将文本转换为语音。
useSpeech挂钩突出显示文字。Speech组件突出显示文本。useSpeech挂钩处理错误。Speech组件处理错误。useSpeech挂钩。Speech组件的多个实例。useSpeech挂钩。Speech组件。使用您的首选软件包管理器安装react-text-to-speech :
# Using npm:
npm install react-text-to-speech --save
# Using Yarn:
yarn add react-text-to-speech
# Using pnpm:
pnpm add react-text-to-speech
# Using Bun:
bun add react-text-to-speechReact-Text到Speech提供了两种主要方法,将文本到语音功能集成到您的React.js应用程序中: useSpeech Hook和<Speech>组件。
useSpeech钩 import React from "react" ;
import { useSpeech } from "react-text-to-speech" ;
export default function App ( ) {
const {
Text , // Component that renders the processed text
speechStatus , // Current speech status
isInQueue , // Indicates if the speech is active or queued
start , // Starts or queues the speech
pause , // Pauses the speech
stop , // Stops or removes the speech from the queue
} = useSpeech ( { text : "This library is awesome!" } ) ;
return (
< div style = { { display : "flex" , flexDirection : "column" , rowGap : "1rem" } } >
< Text />
< div style = { { display : "flex" , columnGap : "0.5rem" } } >
{ speechStatus !== "started" ? < button onClick = { start } > Start </ button > : < button onClick = { pause } > Pause </ button > }
< button onClick = { stop } > Stop </ button >
</ div >
</ div >
) ;
} 有关使用useSpeech挂钩的更多详细信息,请参阅文档。
<Speech>组件 import React from "react" ;
import Speech from "react-text-to-speech" ;
export default function App ( ) {
return < Speech text = "This library is awesome!" /> ;
} 有关使用<Speech>组件的更多详细信息,请参阅文档。
查看实时演示以查看它的作用。
探索文档以快速入门。
通过在github上给予您的❤️和支持。您还可以通过投票和分享产品狩猎来支持该项目。欢迎任何建议!看看贡献指南。
该项目已根据MIT许可获得许可。
React语音突出显示,对语音进行反应文本,并突出显示使用音频文件,文本到语音API和Web语音综合API所使用的单词和句子。此外,它还为许多用例提供了强大的灵活的程序性API。