-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendmessage.py
36 lines (32 loc) · 1.06 KB
/
sendmessage.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
import pywhatkit
import speech_recognition as sr
import pyttsx3
import datetime
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def swm():
engine.say('please say number')
engine.runAndWait()
try:
with sr.Microphone() as source:
print('Listening....')
number = listener.listen(source)
commandN = listener.recognize_google(number)
print(commandN)
engine.say('what is the message')
engine.runAndWait()
print('Listening....')
message = listener.listen(source)
commandM = listener.recognize_google(message)
commandM = commandM.lower()
print(commandM)
# ch = datetime.datetime.now().strftime('%H')
# cm = datetime.datetime.now().strftime('%M')
now = datetime.datetime.now()
m = now.minute + 1
pywhatkit.sendwhatmsg(
'+91'+commandN, commandM, now.hour, m)
except:
pass