-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWhatsapp.py
59 lines (50 loc) · 1.71 KB
/
Whatsapp.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
import pywhatkit
import pyttsx3
import datetime
import speech_recognition
import webbrowser
from bs4 import BeautifulSoup
from time import sleep
import os
from datetime import timedelta
from datetime import datetime
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")
for voice in voices:
if "zira" in voice.name.lower():
engine.setProperty("voice", voice.id)
break
engine.setProperty("rate", 170)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def takeCommand():
r = speech_recognition.Recognizer()
with speech_recognition.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
r.energy_threshold = 300
audio = r.listen(source, 0, 4)
try:
print("Understanding..")
query = r.recognize_google(audio, language="en-in")
print(f"You said : {query}\n")
except Exception as e:
print("Say that again")
return "None"
return query
strTime = int(datetime.now().strftime("%H"))
update = int((datetime.now() + timedelta(minutes=2)).strftime("%M"))
def sendMessage():
speak("Who do you want to send the message to?")
a = int(input("Aditya - 1 , Babita - 2 \n Enter the number:"))
if a == 1:
speak("What message do you want to send?")
message = str(input("Enter the message: "))
pywhatkit.sendwhatmsg("+9199XX3XXXX", message, time_hour=strTime,time_min=update)
speak("Message sent successfully")
elif a == 2:
speak("What message do you want to send?")
message = str(input("Enter the message: "))
pywhatkit.sendwhatmsg("+9198XX35XXX", message, time_hour=strTime,time_min=update)
speak("Message sent successfully")