-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode
106 lines (88 loc) · 5.2 KB
/
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import speech_recognition as sr
import pyttsx3
from googletrans import Translator
import webbrowser
import os, sys
def speakhindi(text):
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.setProperty('rate', 160)
engine.say(text)
engine.runAndWait()
t = Translator()
r = sr.Recognizer()
def speakEnglish(text):
enginE = pyttsx3.init()
voicess = enginE.getProperty('voices')
enginE.setProperty('voice',voicess[3].id)
enginE.setProperty('rate',160)
enginE.say(text)
enginE.runAndWait()
if __name__ == "__main__":
speakhindi("हैलो मेरा नाम किकी है। बताइये में आपकी क्या मदद कर सक्ती हूं")
speakhindi("हिंदी में बात करने के लिए कहो , मैं हिंदी में बात करना चाहता हूं")
speakEnglish("Hello , I am kiki . How can i help you?")
speakEnglish("To speak in english say i want to talk in english")
with sr.Microphone() as source:
speakhindi("आपकी आवाज सुनी जा रही है")
speakEnglish("Listening to your voice")
print("Listening your voice....")
audio = r.listen(source)
try:
command = r.recognize_google(audio, language='hi-IN')
cOmmand = r.recognize_google(audio)
cOmmand = cOmmand.lower()
if "मैं हिंदी में बात करना चाहता हूं" in command:
while True:
with sr.Microphone() as sourceee:
speakhindi("बताइये में आपकी क्या मदद कर सक्ती हूं")
speakhindi("आपकी आवाज सुनी जा रही है")
print("Listening your voice....")
aaaudio = r.listen(sourceee)
textt = r.recognize_google(aaaudio,language='hi-IN')
textt = textt.lower()
speakhindi("आपने कहा: " + textt)
translated = t.translate(textt,dest = 'en').text
if "youtube" in translated.lower():
speakhindi("youtube.com खोला जा रहा है")
print("Opening Youtube.com....")
webbrowser.open("https://www.youtube.com/")
elif "wikipedia" in translated.lower():
speakhindi("विकिपीडिया खोला जा रहा है")
print("Opening Wikipedia....")
webbrowser.open("https://wikipedia.org/")
elif "discord" in translated.lower():
speakhindi("discord खोला जा रहा है")
print("Opening Discord....")
os.startfile("C:/Users/Kunal/AppData/Local/Discord/Update.exe")
elif "close" in translated.lower():
speakhindi("प्रोग्राम बंद किया जा रहा है")
print("Stopping Program....")
sys.exit()
elif "linkdn" in translated.lower():
speakhindi("")
elif "i want to talk in english" in cOmmand:
while True:
with sr.Microphone() as sourcee:
speakEnglish("Hello , I am kiki . How can i help you?")
speakEnglish("Listening to your voice")
print("Listening your voice....")
aaudio = r.listen(sourcee)
text = r.recognize_google(aaudio)
text = text.lower()
if "youtube" in text:
speakEnglish("Opening Youtube.com....")
webbrowser.open("https://www.youtube.com/")
elif "wikipedia" in text:
speakEnglish("Opening Wikipedia....")
webbrowser.open("https://wikipedia.org/")
elif "discord" in text:
speakEnglish("Opening Discord....")
os.startfile("C:/Users/Kunal/AppData/Local/Discord/Update.exe")
elif "close" in text:
speakEnglish("Stopping Program....")
sys.exit()
except sr.UnknownValueError:
speakhindi("में आपकी आवाज समझ नहीं पा रहा हूं। कृपा फिर से बोलिए")
print("Unrecognized Voice. Say that again please.")