import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import urllib
import requests
from bs4 import BeautifulSoup
import sys
from youtube_search import YoutubeSearch
import smtplib
print("Initialising Siri....")
MASTER = "Yashoditya"
AI = "Siri"
engine = [Link]('sapi5')
voices = [Link]('voices')
[Link]('voice', voices[1].id)
def speak(text):
[Link](text)
[Link]()
#Main Program starts here
#This function will wish me
def wishMe():
hour = int([Link]().hour)
if hour>=0 and hour <12:
speak("Good Morning" + MASTER)
elif hour>=12 and hour<16:
speak("Good Afternoon" +MASTER)
else:
speak("Good Evening" + MASTER)
print(hour)
speak("How may i help you?")
#This function will take command from me(via microphone)
def takeCommand():
r = [Link]()
with [Link]() as source:
print("Listening...")
audio = [Link](source)
try :
print("Recognising...")
query = r.recognize_google(audio, language = 'en-in')
print(f"user said: {query}\n")
except Exception as e:
print(MASTER + " ,Say that again please!")
speak(MASTER + " ,Say that again please!")
query = None
return query
#Main Program starts here
speak("Initialising " + AI + (" ..."))
wishMe()
query = takeCommand()
# Logic for executing tasks as per the query
def respond(query, readmenews="[Link]
IN&gl=IN&ceid=IN:en"):
if 'wikipedia' in query:
speak('Searching Wikipedia...')
query = [Link]("wikipedia", "")
results = [Link](query, sentences=3)
print(results)
speak(results)
elif "find location of" in [Link]():
location = query
query = [Link]("find location of", "")
url = "[Link] + query + '/&'
[Link]().open(url)
speak("Here is the location of " + query)
elif "can you talk" in [Link]():
speak("Yes I can talk like a human")
elif 'who made you' in [Link]():
speak("Yashoditya made me")
elif 'how old are you' in [Link]():
speak("I am as old as you")
elif "What is your name?" in [Link]():
speak("My name is" + AI + "Its nice to meet you!")
elif 'who are you?' in [Link]():
speak("My name is" + AI + "Its nice to meet you!")
elif "search" in query:
query = [Link]("search", "")
url = "[Link] + query
[Link]().open(url)
speak("Here is what I found for" + query)
elif 'open youtube' in [Link]():
url = "[Link]"
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/[Link] %s'
[Link](chrome_path).open(url)
speak("Youtube is now opening...")
elif 'open google' in [Link]():
url = "[Link]"
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/[Link] %s'
[Link](chrome_path).open(url)
speak("Google is now opening...")
elif 'YouTube search' in [Link]():
query = [Link]("YouTube search","")
speak("Searching youtube")
url = '[Link] + query
[Link]().open(url)
speak("Here is what I searched on youtube for" + query)
elif 'open google and search' in [Link]():
query = [Link]("open google and search", "")
speak("opening google")
url = "[Link] + query
[Link]().open(url)
speak("Here is what I found for" + query)
elif 'open hotstar' in [Link]():
# [Link]("[Link]")
url = "[Link]"
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/[Link] %s'
[Link](chrome_path).open(url)
speak("Hotstar is now opening...")
elif 'open primevideo' in [Link]():
# [Link]("[Link]")
url = "[Link]"
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/[Link] %s'
[Link](chrome_path).open(url)
speak("Prime Video is now opening...")
elif 'play music' in [Link]():
songs_dir = "C:\\Users\\Administrator\\Desktop"
songs = [Link](songs_dir)
print(songs)
[Link]([Link](songs_dir, songs[0]))
elif 'time' in [Link]():
strTime = [Link]().strftime("%H:%M:%S")
speak(f"{MASTER} the time is {strTime}")
elif 'end' in [Link]():
speak(" Goodbye!Feeling sad that you are leaving")
[Link]()
elif 'News' or 'updates' in [Link]():
speak("Anything else you want me to do?")
while (1):
query = takeCommand()
respond(query)