Ai
How make Ai .
To make first you create python file name main.py and for make Ai start up import pyttsx3 in terminal type pip install pyttsx3.
All codes
If you want write code to copy this and if want to write step by step to watch this video :- Please watch
import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print(voices[0].id)
engine.setProperty('voice', voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak ("Good Morning!")
elif hour>=12 and hour <18:
speak("Good Afternoon!")
else:
speak("Good Evening!")
speak("I am Zeepi Sir. Please tell me how may I help you")
def takeCommand():
#It takes microphone input from the user returns string output
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
speak("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"User said: {query}\n")
except Exception as e:
# print(e)
speak("Say that again please...")
return "none"
return query
if __name__=="__main__":
wishMe()
while True:
query = takeCommand().lower()
# Logic for executing tasks based on query
if 'wikipedia' in query:
speak('searching Wikipedia...')
print('searching Wikipedia...')
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=10)
speak("According to Wikipedia")
print("According to Wikipedia")
print(results)
speak(results)
elif 'open youtube' in query:
webbrowser.open("youtube.com")
elif 'search bad boy ' in query:
webbrowser.open("youtube.com/results?search_query=bad+boy")
elif 'play bad boy ' in query:
webbrowser.open("youtube.com/watch?v=OxjKx0Vojy4")
elif 'search how to make ai' in query:
webbrowser.open("youtube.com/results?search_query=how+to+make+ai")
elif 'search how to solve cube' in query:
webbrowser.open("youtube.com/results?search_query=how+to+solve+cube+cfop")
elif 'search origami tree' in query:
webbrowser.open("youtube.com/results?search_query=origami+tree")
elif 'search code with harry' in query:
webbrowser.open("youtube.com/results?search_query=code+with+harry")
elif 'search how to make minecraft ' in query:
webbrowser.open("youtube.com/results?search_query=how+to+make+minecraft+with+coding+")
elif 'open google' in query:
webbrowser.open("google.com")
elif 'open 7 a.m.' in query:
webbrowser.open("7amlive.blogspot.com")
elif 'open cube timer' in query:
webbrowser.open("cstimer.net")
elif 'open gmail' in query:
webbrowser.open("mail.google.com/mail/u/0/#inbox")
elif 'the time' in query:
strTime = datetime.datetime.now().strftime("%H:%M:%S")
speak(f"Sir, the time is {strTime}")
print(f"Sir, the time is {strTime}")
elif 'open vs code' in query:
codePath = "C:\\Users\\AMIT\\Desktop\\FOLDER OF EARTH\\VS CODE\\Microsoft VS Code\\Code.exe"
os.startfile(codePath)
elif 'open my browser' in query:
codeMy = "C:\\Users\\AMIT\\Desktop\\FOLDER OF EARTH\\Python\\Browser\\Zeetoc.py"
os.startfile(codeMy)
elif 'open zeetoc' in query:
codeZeetoc = "C:\\Users\\AMIT\\Desktop\\FOLDER OF EARTH\\Python\\Browser\\Zeetoc.py"
os.startfile(codeZeetoc)
elif 'open chrome' in query:
codeChrome = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
os.startfile(codeChrome)
elif 'open minecraft' in query:
codeGame = "C:\\Users\\AMIT\Desktop\\FOLDER OF EARTH\\Gaming Website\\MINECRAFT.py"
os.startfile(codeGame)
elif 'open my folder' in query:
codeFolder = "C:\\Users\\AMIT\Desktop\\FOLDER OF EARTH"
os.startfile(codeFolder)
elif 'play music' in query:
music_dir = 'D:\\All\\soft song'
songs = os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir, songs[0-100]))
elif 'who are you' in query:
speak("I am ai and my name is Zeepi")
From: Zeetoc
Author : Pratham
Thanks for reading
0 Comments