Mehdi commited on
Commit
77fcf1b
·
verified ·
1 Parent(s): aad61ab

Upload components/VoiceControl.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/VoiceControl.jsx +39 -0
components/VoiceControl.jsx ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState } from 'react'
2
+ import { FaMicrophone, FaStop } from 'react-icons/fa'
3
+
4
+ const VoiceControl = ({ language, onCommand }) => {
5
+ const [isListening, setIsListening] = useState(false)
6
+
7
+ const toggleListening = () => {
8
+ setIsListening(!isListening)
9
+ // Here you would integrate with Web Speech API
10
+ if (!isListening && onCommand) {
11
+ onCommand(language === 'fa'
12
+ ? 'دستور صوتی دریافت شد: ساخت یک پروژه React جدید'
13
+ : 'Voice command received: Create a new React project')
14
+ }
15
+ }
16
+
17
+ return (
18
+ <div className="flex items-center justify-center p-4">
19
+ <button
20
+ onClick={toggleListening}
21
+ className={`flex items-center justify-center w-16 h-16 rounded-full text-white text-2xl ${isListening ? 'bg-red-500 animate-pulse' : 'bg-blue-600'}`}
22
+ >
23
+ {isListening ? <FaStop /> : <FaMicrophone />}
24
+ </button>
25
+ <div className="mr-4">
26
+ <p className="font-bold">
27
+ {language === 'fa' ? 'کنترل صوتی' : 'Voice Control'}
28
+ </p>
29
+ <p className="text-sm text-gray-600">
30
+ {isListening
31
+ ? (language === 'fa' ? 'در حال گوش دادن...' : 'Listening...')
32
+ : (language === 'fa' ? 'برای صحبت کلیک کنید' : 'Click to speak')}
33
+ </p>
34
+ </div>
35
+ </div>
36
+ )
37
+ }
38
+
39
+ export default VoiceControl