Professional Documents
Culture Documents
(minor project) AMBEDKAR INSTITUTE OF TECHNOLOGY
(minor project) AMBEDKAR INSTITUTE OF TECHNOLOGY
Session : 2020-2021
Minor Project
Department – ITES&M
Semester – 5th Semester (3rd Year)
*ACKNOWLEDGEMENT
*DECLARATION
*TOPIC
*ADVANTAGES
*Source code
*References
ACKNOWLEDGEMENT
o Planning: This field deals with optimal planning that gives us maximum
returns with minimal costs. These software programs start with facts
about the particular situation and a statement of a goal. These programs
are also aware of the facts of the world, so that they know what the
rules are. From this information, they generate the most optimal plan to
achieve the goal.
Computer Vision: These are the systems that deal with visual data such as
images and videos. These systems understand the content and extract
insights based on the use case. For example, Google uses reverse image
search to search for visually similar images across the Web.
Natural Language Processing: This field deals with understanding text. We
can interact with a machine by typing natural language sentences. Search
engines use this extensively to deliver the right search results.
In our endeavour to identify what is the best programming language for AI and neural
network, Python has taken a big lead.
In our endeavour to identify what is the best programming language for AI and neural
network, Python has taken a big lead. Let us look at why Artificial Intelligence with
Python is one of the best ideas under the sun.
Python also features dynamic type system and automatic memory management
supporting a wide variety of programming paradigms including object-oriented,
imperative, functional and procedural to name a few.
Python is available for all Operating Systems and also has an open-source offering
titled CPython which is garnering widespread popularity as well.
Let us now look as to how using Python for Artificial Inelegance gives us an edge over
other popular programming languages
Python offers the least code among others and is in fact 1/5 the number compared to
other OOP languages. No wonder it is one of the most popular in the market today.
• Python has Prebuilt Libraries like Numpy for scientific computation, Scipy for
advanced computing and Pybrain for machine learning (Python Machine
Learning) making it one of the best languages For AI.
• Python developers around the world provide comprehensive support and
assistance via forums and tutorials making the job of the coder easier than any
other popular languages.
• Python is platform Independent and is hence one of the most flexible and
popular choiceS for use across different platforms and technologies with the
least tweaks in basic coding.
• Python is the most flexible of all others with options to choose between OOPs
approach and scripting. You can also use IDE itself to check for most codes and
is a boon for developers struggling with different algorithms.
Another useful library is pandas, an open source library that provides users with
easy-to-use data structures and analytic tools for Python.
Matplotlib is another service which is a 2D plotting library creating publication quality
figures. You can use matplotlib to up to 6 graphical users interface toolkits, web
application servers, and Python scripts.
Your next step will be to explore k-means clustering and also gather knowledge
about decision trees, continuous numeric prediction, logistic regression, etc.
Some of the most commonly used Python AI libraries are AIMA, pyDatalog, SimpleAI,
EasyAi, etc. There are also Python libraries for machine learning like PyBrain, MDP,
scikit, PyML.
Let us look a little more in detail about the various Python libraries in AI and why this
programming language is used for AI
• Python is a more popular language over C++ for AI and leads with a 57% vote
among developers. That is because Python is easy to learn and implement.
With its many libraries, they can also be used for data analysis.
• Performance wise C++ outperforms Python. This is because C++ has the
advantage of being a statically typed language and hence there are no typing
errors during runtime. C++ also creates more compact and faster runtime
code.
• Python is a dynamic (as opposed to static) language and reduces complexity
when it comes to collaborating meaning you can implement functionality with
less code. Unlike C++, where all significant compilers tend to do specific
optimisation and can be platform specific, Python code can be run on pretty
much any platform without wasting time on specific configurations.
• With the rise of GPU-accelerated computing offering capabilities for
parallelism which has led to the creation of libraries such as CUDA Python and
cuDNN, Python has the edge over C++. This means is that more and more of
the actual computing for machine learning workloads is being offloaded to
GPUs – and the result is that any performance advantage that C++ may have is
becoming increasingly irrelevant.
• Python wins over C++ regarding simplicity of code, especially amongst new
developers. C++ being a lower-level language requires more experience and
skill to master.
• Python’s simple syntax also allows for a more natural and intuitive ETL
(Extract, Transform, Load) process, and means that it is faster for development
when compared to C++, allowing developers to test machine learning
algorithms without having to implement them quickly.
Between C++ and Python, the latter has more edge and is more suitable for AI. With
its simple syntax and readability promoting the rapid testing of complex machine
learning algorithms and a thriving community bolstered by collaborative tools like
Jupyter Notebooks and Google Colab, Python wins the crown.
Main function and modules
• Pyttsx3:
pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative
libraries, it works offline and is compatible with both Python 2 and 3. An
application invokes the pyttsx3. init() factory function to get a reference to
a pyttsx3. Engine instance.
• Speech recognition
In speech recognition module of python, we use pyaudio which is required if
and only if we want to use microphone input (microphone). PyAudio version
0.2.11+ is required, as earlier versions have known memory management bugs
when recording from microphones in certain situations. If not installed,
everything in the library will still work, except attempting to instantiate a
microphone object will raise an Attribute ERROR. After it we initialize the
recognizer function of module.
# taking command function from user
try:
def takecommand():
r = sr.Recognizer()
try:
print("recognizing")
try:
query = r.recognize_google(audio)
except Exception:
speak("could you say it again")
print(query)
return query
except Exception as e:
print(e)
• Wikipedia
Wikipedia is a Python library that makes it easy to access and parse data
from Wikipedia. Search Wikipedia, get article summaries, get data like links
and images from a page.
query = query.replace("WIKIPEDIA","")
result = wk.summary(query, sentences=3)
print(result)
speak(result)
• OS module
The OS module in python provides functions for interacting with the operating
system. OS, comes under Python's standard utility modules.
This module provides a portable way of using operating system dependent
functionality. The *os* and *os. path* modules include many functions to
interact with the file system.
elif 'logout' in query:
os.system("shutdown -1")
• Pyjokes
One-line jokes for programmers (jokes as a service).
# function for jokes
def jokes():
speak(pj.get_jokes(language="en",category="neutral"))
• Psutil
psutil (python system and process utilities) is a cross-platform library for
retrieving information on running processes and system utilization (CPU,
memory, disks, network, sensors) in Python. It is useful mainly for system
monitoring, profiling, limiting process resources and the management of
running processes
# function for cpu status
def cpu():
usage = str(pu.cpu_percent())
speak("cpu is at" + usage)
battery =pu.sensors_battery()
speak("battery is at")
speak(battery)
• Play music function
Using os module I use it to play music, first define the path of music path.
Then call the listdir function and startfile function to run it.
elif 'play music' in query:
try:
songs_dir ='G:\\Music\\phone'
songs = os.listdir(songs_dir)
os.startfile(os.path.join(songs_dir,songs[0]))
except Exception:
speak(Exception)
print(Exception)
• Pyautogui
PyAutoGUI lets your Python scripts control the mouse and keyboard to
automate interactions with other applications. The API is designed to be as
simple. PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2
and 3.
• Wishing function
Using this function, it wishes good morning, noon, after noon, evening and night
with the use of date time module of python.
• Login function
Here we login into the program. using authorised email id and password we
can login into it. After getting the email id and password it calls administration
modules admin function.
# login area ==============#
tprint("welcome")
speak("welcome")
speak("who are you?? old user or new user.")
print("1. new user ")
print("2. old user")
k1=takecommand().lower()
if "old" in k1:
speak('please enter your email')
email = input("enter your email")
str(email)
speak('enter your password')
password= input("enter your password")
str(password)
z=adminstration.admin(email,password)
str(z)
• administration module
we use administration module to login in program with sql connectivity.
Using this it will verify from getting the data through login area then check it in
sql database. Here I make a database name Jarvis and table password. using
select command the administration will check the login criteria is right or not
if inputs are correct then it will return the name of the user other wise it will
close the program.
def admin(email,password):
except Exception as e:
print(e)
return k
• pymysql
it is module of python to connect program to database.
First import the module, then connect it using connect function of pymysql
module using database host name, password. Call the cursor to initialize the
operation, then using execute function of module connect.
server = pymysql.connect( host="localhost", user="root",password="Asrmath1053#")
a = server.cursor()
sql="USE jarvis;"
a.execute(sql)
• News
By using this we get news updates.
def pasrefeed():
f=feedparser.parse("https://feeds.bbci.co.uk/news/rss.xml")
for newsitem in f['items']:
notification.notify(title=newsitem['title'],message=str(newsitem['summary
']),timeout=10)
time.sleep(10)
• Art
Art package is used to print decorative arts on the terminal as well as to save in
file and a word can be represented by” | “and can be saved in a file
• Smtp
The smtplib module defines an SMTP client session object that can be used to
send mail to any Internet machine with an SMTP or ESMTP listener daemon. ...
An SMTP instance encapsulates an SMTP connection. It has methods that
support a full repertoire of SMTP and ESMTP operations.
def sendmail(to,content):
try:
server=sb.SMTP_SSL('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.login('maith.artifi@gmail.com','asrmath1053')
server.sendmail('maith.artifi@gmail.com',to,content)
server.close()
except:
print("something wents wrong....")
• Selenium
Python language bindings for Selenium WebDriver. The selenium package is
used to automate web browser interaction from Python. Several
browsers/drivers are supported (Firefox, Chrome, Internet Explorer), as well
as the Remote protocol.
elif 'open chrome' in query:
driver = webdriver.Chrome("C:\\Program Files (x86)\\Google\\C
hrome\\Application\\chrome.exe")
import pyttsx3
import speech_recognition as sr
abc= pyttsx3.init()
def speak(audio):
abc.say(audio)
abc.runAndWait()
try:
def takecommand():
r = sr.Recognizer()
try:
print("recognizing")
try:
query = r.recognize_google(audio)
except Exception:
speak("could you say it again")
print(query)
return query
except Exception as e:
print(e)
except Exception as k:
speak(k)
#======================================#
#-----------imports--------------------#
#======================================#
import pyttsx3
import datetime
import speech_recognition as sr
import wikipedia as wk
import smtplib as sb,ssl
import webbrowser as wb
import os
from selenium import webdriver
import pyautogui as pg
import psutil as pu
import pyjokes as pj
import pymysql
import adminstration
import sqlai
import feedparser
from plyer import notification
import time
from art import *
# initialization of pyttsx3 module
abc = pyttsx3.init()
def pasrefeed():
f=feedparser.parse("https://feeds.bbci.co.uk/news/rss.xml")
for newsitem in f['items']:
notification.notify(title=newsitem['title'],message=str(newsitem['summary']),timeo
ut=30)
time.sleep(30)
def reset():
if "yes" in sri:
speak("are you old user or new user")
w2=takecommand().lower()
else:
speak("please try after some time")
else:
speak("thank you for visiting!!")
else:
speak("i can't recognize you")
exit()
def newregistration():
server = pymysql.connect( host="localhost", user="root",password="Asrmath1053#")
a = server.cursor()
sql="USE jarvis;"
a.execute(sql)
try:
print("recognizing")
try:
query= r.recognize_google(audio)
except Exception:
speak("please check you internet connection and could you say it again
")
print(query)
return query
except Exception as e:
print(e)
except Exception as k:
speak(k)
if z:
speak('welcome')
speak(z)
if __name__ == "__main__":
wish()
while 1==1:
query = takecommand().lower()
if 'time' in query:
time1()
f=open('about.txt','r')
speak(f.read())
except Exception:
speak(Exception)
except Exception :
speak('you did not say any thing')
elif 'date' in query:
date()
else:
reset()
elif 'new user' in query:
newregistration()
else:
exit()
import pymysql
import sqlite3
import basic
import numpy
def admin(email,password):
sql="USE jarvis;"
a.execute(sql)
try:
except Exception as e:
print(e)
return k
def forget(npassword,phone_no):
server=pymysql.connect(host="localhost",user="root",password="Asrmath1053#")
a=server.cursor()
sql="use jarvis;"
a.execute(sql)
try:
a.execute('update password set password= %s where phone_no=%s',(npassword,p
hone_no,))
k=a.fechall()
str(k)
except Exception as e:
print(e)
return k
def signup(name,password,email,phno):
server = pymysql.connect( host="localhost", user="root",password="Asrmath1053#")
a = server.cursor()
sql="USE jarvis;"
a.execute(sql)
try:
except Exception as e:
print(e)
import pymysql
import sqlite3
import basic
import numpy
def create(host,password,username):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("what is the name of database you want to create ")
print("what is the name of database create")
db=basic.takecommand()
k=a.execute("create %s",(db))
if k==True:
basic.speak("do you also want to create a table sir ")
m=basic.takecommand()
if "yes" in m:
basic.speak("what is the name of tables do you want to create ")
table=basic.takecommand()
basic.speak("how many entity for coloum sir")
column=basic.takecommand()
int(column)
a=numpy.array([25])
for n in column:
a[n]=basic.takecommand()
b=numpy.array([25])
for k in column:
b[k]=basic.takecommand()
for f in column:
exit()
def query(host,password,username):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("do you want add more specification for query yes or no")
extra=basic.takecommand().lower
if "yes" in extra:
basic.speak("with which coperatorr you want to add specification or /
and")
n=basic.takecommand().lower()
if "and" in n:
basic.speak("which entity do you want on which you want to do que
ry")
base1=basic.takecommand()
basic.speak("value of that entity")
value1=basic.takecommand()
return a.execute("select %s from %s where %s=%s and %s=%s",(colum
n,table,base,value,base1,value1))
server.commit()
if "or" in n:
basic.speak("which entity do you want on which you want to do que
ry")
base1=basic.takecommand()
basic.speak("value of that entity")
value1=basic.takecommand()
return a.execute("select %s from %s where %s=%s or %s=%s",(column
,table,base,value,base1,value1))
server.commit()
else:
return a.execute("select %s from %s where %s=%s",(column,table,base,v
alue))
def update(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter table name")
table=input("enter table name")
basic.speak("enter target entity")
entity=input("enter target entity")
basic.speak("enter value of entity")
value=input("enter value of entity")
basic.speak("enter new value")
nvalue=input("enter new value")
try:
a.execute('update %s set value=%s where %s=5s',(table,nvalue,entity,value
,))
server.commit()
except Exception:
print(Exception)
def delete(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter table name you want to delete")
table=input("enter table name you want to delete")
basic.speak("enter target entity")
entity=input("enter target entity")
basic.speak("enter value of entity")
value=input("enter value of entity")
a.execute('delete from %s where %s=%s',(table,entity,value,))
server.commit()
def orderby(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter target entity")
entity=input("enter target entity")
basic.speak("enter table name")
table=input("enter table name")
basic.speak("order by ascending or descending order")
order=input('ASC for ascending or DESC for decending order')
if order=='ASC' or order=="asc":
a.execute('select %s from %s ORDERBY %s ASC',(entity,table,entity,))
server.commit()
if order=='DESC' or order=="desc":
a.execute('select %s from %s ORDERBY %s DESC',(entity,table,entity,))
server.commit()
def droptable(host,username,password):
server=pymysql.connect(host=host,user=username,password=password)
a=server.cursor()
basic.speak("enter table name")
table=input("enter table name")
a.execute('DROP %s',(table))
server.commit()
glimpses
references
• Artificial intelligence with python Prateek joshi.
• www.Pypi.org
• GitHub
• Geeks for geeks
• Stack flow
• www.python.org
• Udemy
• MySQL for python
• Iron man movie.
Our thoughts:
Our thinking is that it is not the ending of this project it’s just
beginning. we will extend its functionality, if AI is future it is our first
step. Learning is not limited to my degree, my degree is not limited to
only what is my course, we will enhance our knowledge and take it
at great level where it will help in our future works.
To be continued………