Spaces:
Configuration error
Configuration error
Download src/components/VoiceButton.jsx from CPISTO/TARSTHENEXT: direct link, hf CLI and curl.
- Browser
- Download file 703 Bytes
-
https://huggingface.co/spaces/CPISTO/TARSTHENEXT/resolve/main/src/components/VoiceButton.jsx
- Command line
-
hf download hf://spaces/CPISTO/TARSTHENEXT/src/components/VoiceButton.jsx
-
curl -L -o VoiceButton.jsx https://huggingface.co/spaces/CPISTO/TARSTHENEXT/resolve/main/src/components/VoiceButton.jsx
703 Bytes
| import { useState } from 'react' | |
| export default function VoiceButton({ onResult }) { | |
| const [listening, setListening] = useState(false) | |
| const startListening = () => { | |
| const recognition = new window.webkitSpeechRecognition() | |
| recognition.lang = 'pt-BR' | |
| recognition.onresult = e => { | |
| const transcript = e.results[0][0].transcript | |
| onResult(transcript) | |
| } | |
| recognition.onend = () => setListening(false) | |
| recognition.start() | |
| setListening(true) | |
| } | |
| return ( | |
| <button | |
| className={`px-3 py-2 rounded ${listening ? 'bg-red-500' : 'bg-green-600'} text-white`} | |
| onClick={startListening} | |
| > | |
| 🎙️ Voz | |
| </button> | |
| ) | |
| } | |