ส่วนประกอบ react.js ที่ใช้งานง่ายที่ใช้ประโยชน์จากเว็บ Speech API เพื่อแปลงข้อความเป็นคำพูด
useSpeechSpeechuseSpeechSpeechuseSpeechSpeechuseSpeechSpeech ติดตั้ง 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-speech React-text-to-speech มีสองวิธีหลักในการรวมฟังก์ชันการพูดแบบข้อความกับการพูดเข้ากับแอปพลิเคชัน React.js ของคุณ: hook useSpeech และส่วนประกอบ <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 >
) ;
} สำหรับรายละเอียดเพิ่มเติมเกี่ยวกับการใช้ Hook 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 Speech Highlight, React Text to Speech ด้วยการเน้นคำและประโยคที่ถูกพูดจริงโดยใช้ไฟล์เสียง API ข้อความเป็นคำพูดและ API การสังเคราะห์เว็บคำพูด นอกจากนี้ยังมี API โปรแกรมที่มีประสิทธิภาพและยืดหยุ่นสำหรับหลายกรณีการใช้งาน