Skip to content

Commit

Permalink
fix: voice
Browse files Browse the repository at this point in the history
  • Loading branch information
adetyaz committed Sep 6, 2024
1 parent 3a9d999 commit 4d27bdd
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/components/voice-assistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,30 @@ export const VoiceAssistant = ({
},
])

// useEffect(() => {
// const synth = window.speechSynthesis

// // Create a speech synthesis utterance
// const utterance = new SpeechSynthesisUtterance(
// "Welcome to our world! Feel free to explore and discover hidden treasures together with your AI companion. Let's embark on this adventure!"
// )

// // Speak the message after a delay of 5 seconds
// const timeoutId = setTimeout(() => {
// if (!synth.speaking) {
// synth.speak(utterance)
// }
// }, 5000)

// // Cleanup function to cancel speech synthesis and timeout if necessary
// return () => {
// clearTimeout(timeoutId)
// if (synth.speaking) {
// synth.cancel()
// console.log('Speech synthesis canceled')
// }
// }
// }, [])
useEffect(() => {
const synth = window.speechSynthesis

// Create a speech synthesis utterance
const utterance = new SpeechSynthesisUtterance(
`Welcome, Feel free to explore ${brandName} and discover hidden treasures together with your AI companion.`
)

// Speak the message after a delay of 5 seconds
const timeoutId = setTimeout(() => {
if (!synth.speaking) {
synth.speak(utterance)
}
}, 5000)

// Cleanup function to cancel speech synthesis and timeout if necessary
return () => {
clearTimeout(timeoutId)
if (synth.speaking) {
synth.cancel()
console.log('Speech synthesis canceled')
}
}
}, [])

useEffect(() => {
// Feature detection for webkitSpeechRecognition
Expand Down

0 comments on commit 4d27bdd

Please sign in to comment.