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。