-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsruthi.py
134 lines (112 loc) · 3.8 KB
/
sruthi.py
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import sqlite3
import os
import random
import speech_recognition as sr
from gtts import gTTS
from playsound import playsound
import datetime
import wikipedia
import pywhatkit
import tkinter
from tkinter import PhotoImage
from tkinter.ttk import *
from PIL import ImageTk
conn = sqlite3.connect('userlog.db')
c = conn.cursor()
def beginListening():
earings=sr.Recognizer()
try:
with sr.Microphone() as source:
playsound("initiate.mp3")
print("ശ്രുതിയോടു സംസാരിക്കൂ")
earings.adjust_for_ambient_noise(source)
voice=earings.listen(source)
text=earings.recognize_google(voice,language="ml-IN")
print(text)
except:
pass
def logEntry(query, keyword):
c.execute("INSERT INTO Userlog (Query, Keyword) VALUES (?, ?)", [query, keyword])
conn.commit()
def myName():
txt='എന്റെ പേര് ശ്രുതി'
mal=gTTS(txt,lang='ml')
mal.save("voice.mp3")
playsound("voice.mp3")
os.remove("voice.mp3")
def howAreYou():
txt="എനിക്ക് സുഖമാണ്"
mal=gTTS(txt,lang='ml')
mal.save('voice.mp3')
playsound('voice.mp3')
os.remove("voice.mp3")
def currentTime():
txt=datetime.datetime.now().strftime("%I:%M %p")
print(txt)
mal=gTTS(txt,lang='ml')
mal.save("voice.mp3")
playsound("voice.mp3")
os.remove("voice.mp3")
def currentDate():
txt=datetime.datetime.now().strftime("%d/%B/%Y")
print(txt)
mal=gTTS(txt,lang='ml')
mal.save("voice.mp3")
playsound("voice.mp3")
os.remove("voice.mp3")
def whoIs():
person=text.replace('ആരാണ്','')
wikipedia.set_lang('ml')
txt=wikipedia.summary(person,3)
print(txt)
mal=gTTS(txt,lang='ml')
mal.save("voice.mp3")
playsound("voice.mp3")
os.remove("voice.mp3")
def jokes():
lno=random.randint(0,4)
f=open('jokes.txt', encoding="utf8")
line=f.readlines()
txt=line[lno]
print(txt)
mal=gTTS(txt,lang='ml')
mal.save("voice.mp3")
playsound("voice.mp3")
os.remove("voice.mp3")
f.close()
if 'പേര്' in text:
myName()
logEntry(text, 'പേര്')
elif 'എന്തൊക്കെയുണ്ട് വിശേഷം' in text:
howAreYou()
logEntry(text, 'എന്തൊക്കെയുണ്ട് വിശേഷം')
elif 'സമയം' in text:
currentTime()
logEntry(text, 'സമയം')
elif 'തീയതി' in text:
currentDate()
logEntry(text, 'തീയതി')
elif 'ആരാണ്' in text:
whoIs()
logEntry(text, 'ആരാണ്')
elif 'കേൾക്കണം' in text:
song=text.replace('കേൾക്കണം','')
pywhatkit.playonyt(song)
logEntry(text, 'കേൾക്കണം')
elif 'കാണണം' in text:
film=text.replace('കാണണം','')
pywhatkit.playonyt(film)
logEntry(text, 'കാണണം')
elif 'തമാശ' in text:
jokes()
logEntry(text, 'തമാശ')
root = tkinter.Tk()
root.title('ശ്രുതി')
canvas = tkinter.Canvas(root, width=700, height=550)
canvas.pack()
tk_img = ImageTk.PhotoImage(file = "splash.png")
canvas.create_image(350, 300, image=tk_img)
photo = PhotoImage(file = r"button.png")
quit_button = tkinter.Button(root, image = photo, command = beginListening, anchor = 'w')
quit_button.pack()
root.mainloop()