Final Document

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 51

SYNOPSIS

Covid-19 Hospital Management python Django System provides the benefits


of streamlined operations, enhanced administration & control, superior
patient care, strict cost control and improved profitability. HMS is powerful,
flexible, and easy to use and is designed and developed to deliver real
conceivable benefits to hospitals. More importantly it is backed by reliable and
dependable support.
The project ' Covid-19 Hospital Management python Django System' is based
on the database, object oriented and networking techniques. As there are many
areas where we keep the records in database for which we are using MY SQL
software which is one of the best and the easiest software to keep our
information. This project uses JAVA as the front-end software which is an Object
Oriented Programming and has connectivity with MY SQL.
Covid-19 Hospital Management python Django System is custom built to meet
the specific requirement of the mid and large size hospitals across the globe. All
the required modules and features have been particularly built to just fit in to
your requirement. This package has been widely accepted by the clients in India
and overseas. Not stopping only to this but they are highly satisfied and
appreciating. Entire application is web based and built on 3 tier architecture using
the latest technologies. The sound database of the application makes it more
users friendly and expandable. The package is highly customizable and can be
modified as per the needs and requirements of our clients. Prolonged study of the
functionalities of the hospital and its specific requirement has given it a wonderful
shape both technically and usability wise.

1
CONTENTS

SI.NO TITLE DESCRIPTION PAGE NO.

INTRODUCTION 4
1.1 ORGANIZATION PROFILE 4

I 1.2 SYSTEM SPECIFICATION 5

1.2.1 HARDWARE CONFIGURATION 5


1.2.2 SOFTWARE SPECIFICATION 5
1.3 SOFTWARE DESCRIPTION 6

SYSTEM STUDY 11
2.1 EXISTING SYSTEM 11

II 2.1.1 DRAWBACKS OF EXISTING SYSTEM 10

2.2 PROPOSED SYSTEM 11


2.2.1 FEATURES OF PROPOSED SYSTEM 11
SYSTEM DESIGN AND DEVELOPMENT 12
3.1 FILE DESIGN 12
3.2 INPUT DESIGN 12
3.3 OUTPUT DESIGN 13
III
3.4 DATABASE DESIGN 14
3.5 SYSTEM DEVELOPMENT 15
3.5.1 DESCRIPTION OF MODULES 16
IV SYSTEM TESTING AND IMPLEMENTATION 20

CONCLUSION 23

BIBLIOGRAPHY 24
APPENDICES 25
A. DATA FLOW DIAGRAM 25
B. DATABASE TABLE 27
C. SAMPLE CODE 29

D. SAMPLE INPUT 38
V
E. SAMPLE OUTPUT 45

2
1.INTRODUCTION

Human Body is a very complex and sophisticated structure and comprises


of millions of functions. All these complicated functions have been understood by

3
man him, part-by-part their research and experiments. As science and technology
progressed, medicine became an integral part of the research. Gradually, medical
science became an entirely new branch of science. As of today, the Health Sector
comprises of Medical institutions ie. Hospitals, HOSPITALS etc. research and
development institutions and medical colleges. Thus the Health sector aims at
providing the best medical facilities to the common man.

1.2 SYSTEM SPECIFICATION

4
1.2.1 HARDWARE ARE CONFIGURATION

MONITOR : 15.6” FULL HD WVA DISPLAY

PROCESSOR : INTEL

HARD DISK : 250 GB

MOUSE : OPTICAL MOUSE

KEYBOARD : 1.4 MULTIMEDIA

RAM : 8GB

1.2.2 SOFTWARE SPECIFICATION

OPERATING SYSTEM : WINDOWS XP

FRONT END : PHP

BACK END : MY SQL,PYTHON

1.3 AN OVERVIEW OF SOFTWARE

5
PYTHON

Python is a computer programming language often used to build websites and software,
automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it
can be used to create a variety of different programs and isn’t specialized for any specific
problems. This versatility, along with its beginner-friendliness, has made it one of the most-
used programming languages today. A survey conducted by industry analyst firm Red Monk
found that it was the second-most popular programming language among developers in 2021.

Python is commonly used for developing websites and software, task automation, data
analysis, and data visualization. Since it’s relatively easy to learn, Python has been adopted by
many non-programmers such as accountants and scientists, for a variety of everyday tasks, like
organizing finances.

Python has become a staple in data science, allowing data analyst and other


professionals to use the language to conduct complex statistical calculations, create data
visualizations, build machine learning algorithms, manipulate and analyse data, and complete
other data-related tasks.

Python can build a wide range of different data visualizations, like line and bar graphs,
pie charts, histograms, and 3D plots. Python also has a number of libraries that enable coders to
write programs for data analysis and machine learning more quickly and efficiently, like
TensorFlow and Kera’s.

Python is often used to develop the back end of a website or application—the parts that
a user doesn’t see. Python’s role in web development can include sending data to and from
servers, processing data and communicating with databases, URL routing, and ensuring
security. Python offers several frameworks for web development. Commonly used ones include
Django and Flask.

6
FEATURES OF PYTHON

1. Easy to Code

Python is a very high-level programming language, yet it is effortless to learn.


Anyone can learn to code in Python in just a few hours or a few days. Mastering Python and
all its advanced concepts, packages and modules might take some more time. However,
learning the basic Python syntax is very easy, as compared to other popular languages like C,
C++, and Java. 

2. Easy to Read

Python code looks like simple English words. There is no use of semicolons or
brackets, and the indentations define the code block. You can tell what the code is supposed
to do simply by looking at it. 

3. Free and Open-Source

Python is developed under an OSI-approved open-source license. Hence, it is


completely free to use, even for commercial purposes. It doesn't cost anything to download
Python or to include it in your application. It can also be freely modified and re-distributed.
Python can be downloaded from the official Python website.

4. Robust Standard Library

Python has an extensive standard library available for anyone to use. This means that
programmers don’t have to write their code for every single thing unlike other programming
languages. There are libraries for image manipulation, databases, unit-testing, expressions
and a lot of other functionalities. In addition to the standard library, there is also a growing
collection of thousands of components, which are all available in the python package index.

5. Interpreted

7
When a programming language is interpreted, it means that the source code is
executed line by line, and not all at once. Programming languages such as C++ or Java are
not interpreted, and hence need to be compiled first to run them. There is no need to compile
Python because it is processed at runtime by the interpreter. 

6. Portable

Python is portable in the sense that the same code can be used on different machines.
Suppose you write a Python code on a Mac. If you want to run it on Windows or Linux later,
you don’t have to make any changes to it. As such, there is no need to write a program
multiple times for several platforms.

7. Object-Oriented and Procedure-Oriented

A programming language is object-oriented if it focuses design around data and


objects, rather than functions and logic. On the contrary, a programming language is
procedure-oriented if it focuses more on functions (code that can be reused). One of the
critical Python features is that it supports both object-oriented and procedure-oriented
programming. 

8. Extensible

A programming language is said to be extensible if it can be extended to other


languages. Python code can also be written in other languages like C++, making it a highly
extensible language.

9. Expressive

Python needs to use only a few lines of code to perform complex tasks. For example,
to display Hello World, you simply need to type one line - print (“Hello World”). Other
languages like Java or C would take up multiple lines to execute this.

10. Support for GUI

8
One of the key aspects of any programming language is support for GUI or Graphical
User Interface. A user can easily interact with the software using a GUI. Python offers
various toolkits, such as Tkinter, wxPython and JPython, which allows for GUI's easy and
fast development.

11. Dynamically Typed

Many programming languages need to declare the type of the variable before runtime.
With Python, the type of the variable can be decided during runtime. This makes Python a
dynamically typed language.

For example, if you have to assign an integer value 20 to a variable “x”, you don’t need to
write int x = 20. You just have to write x = 15.

12. High-level Language

Python is a high-level programming language because programmers don’t need to


remember the system architecture, nor do they have to manage the memory. This makes it
super programmer-friendly and is one of the key features of Python.

13. Simplify Complex Software Development

Python can be used to develop both desktop and web apps and complex scientific and
numerical applications. Python's data analysis features help you create custom big data
solutions without so much time and effort. You can also use the Python data visualization
libraries and APIs to present data in a more appealing way. Several advanced software
developers use Python to accomplish high-end AI and natural language processing tasks. 

14. Other Advanced Programming Features

9
Python contains several advanced programming features such as generators (used to
create iterators with a different approach that most other languages) and list

comprehensions (used to create new lists from other iterables). Python also has automatic
memory management eliminating the need to manually allocate and free memory in the code.

10
2. SYSTEM STUDY

2.1 EXISTING SYSTEM

The term virtual assistant, or virtual personal assistant, is also commonly used to
describe contract workers who work from home doing administrative tasks typically
performed by executive assistants or secretaries. Virtual assistants are typically cloud-based
programs that require internet-connected devices and/or applications to work. Three such
applications are Siri on Apple devices, Cortana on Microsoft Devices and Google Assistant
on Android devices. There are also devices dedicated to providing virtual assistance. The
most popular ones are available from Amazon, Google and Microsoft. To use the Amazon
Echo virtual assistant, called Alexa, users call out the wake word, "Alexa." A light on the
device signals to the user it is ready to receive a command, which typically involves simple
language requests, such as "what is the weather today," or "play pop music." Those requests
are processed and stored in Amazon's cloud. The technologies that power virtual assistants
require massive amounts of data, which feeds artificial intelligence (AI) platforms, including
machine learning, natural language processing and speech recognition platforms. As the end
user interacts with a virtual assistant, the AI programming uses sophisticated algorithms to
learn from data input and become better at predicting the end user's needs.

2.1.1 DRAWBACKS

Virtual assistants have a variety of privacy concerns associated with them. Features
such as activation by voice pose a threat; as such features require the device to always be
listening. However, such features are important to make devices accessible for people who
may otherwise have trouble. Modes of privacy such as the virtual security button have been
proposed to create a multilayer authentication for virtual assistants.

Cortana, for example, works best by using data from a user's device, including emails
and other communications, a user's contacts, location data, search history, and data from
other Microsoft services and skills -- third-party applications -- that users choose to connect

11
with. Users can choose not to sign in and share this data with Cortana, and adjust permissions
to prevent certain data from being collected, though these actions limit the virtual assistant's
usefulness. These virtual assistants require large amounts of personal data and are always
"listening" in order to respond to voice commands. Virtual assistants then retain voice
interactions and personal information to improve the user experience. Virtual assistant
providers also maintain privacy policies, which define how each company uses and shares
personal information. In most cases, companies do not share customer-identifiable
information without a customer's consent.

2.2 PROPOSED SYSTEM

To design a device that acts as a digital organizer to provide variety of services to its
master. It will look at examples of intelligent programs with natural language processing that
are currently available, with different categories of support, and examine the potential
usefulness of one specific piece of software as a VPA. It continues to expand its digital
abilities in organizing events, ordering food, playing music, guiding services for travelling,
game prediction etc. It is suggested that new technologies may soon make the idea of virtual
personal assistants a reality. Experiments conducted on this system, combined with user
testing, have provided evidence that a basic program with machine learning algorithms in the
form of a digital personal assistant. Using machine learning algorithms to iteratively learn
user’s preference for each theme based on quality feedback given by the user. The concept of
a virtual assistant which is a digital service looking after a range of our needs is fast
becoming a reality. As artificial intelligence and machine learning progress at pace, digital
assistants are set to become our gateway to the internet and know more about us than we do
ourselves. Siri and Google now are just the beginning. The device accepts voice input
processes it through various machine learning algorithms to provide desired output to user.

2.2.1 FEATURES

Virtual assistants typically perform simple jobs for end users, including the following:

12
 adding tasks to a calendar;

 providing information that would normally be searched in a web browser;

 controlling and checking the status of smart home devices, including lights,


cameras and thermostats;

 making and receiving phone calls;

 creating text messages;

 getting directions;

 hearing news and weather reports;

 finding hotels or restaurants;

 checking flight reservations;

 listening to music; and

 playing games.

3.SYSTEM DESIGN AND DEVELOPMENT

13
The design of the system is essentially a blue print or plan for solution of the system
to be developed. A part of the system or subsystem of a whole system can itself be considered
a system with its own complements

3.1 FILE DESIGN

The file design is the last phase that indicates the final system and process of the final
system in the design phase of A.I ASSISTANT, input screen design and output design etc are
designed

All the input screens in this system are user-friendly and understandable format.

Also, the sizes of all the screens are standardized

Icons designed in this system are brief, compact and self-explanatory the icons are
sharp and the user can invoke the system. Reports generated here give the minute
information, which helps the manager to take vital decisions.

The importance of software design can be stated with a single word "QUALITY":
Design is a place where quality is fostered in software development. Design is the only way
where their requirements are accurately translated into finished software product or system.

3.2 INPUT DESIGN

Input design is the process of converting user-originated inputs to a computer-based


format

The system takes input from the users, processes it and produces an output. Input
design is link that ties the information system into the world of its users. The system should
be users friendly to gain appropriate information to the user

3.3 OUTPUT DESIGN

14
Output design generally refers to the results and information that are
integrated by the system for many end users. Output is the main reason for developing the
system and the basis on which they evaluate the usefulness of the application.

The objective of a system finds its shape in terms of output, Output of a


system can face various forms. The most command are the reports, screen displays, printed
forms, graphical, drawings etc. The basic requirements of output are that, it should be
accurate, timely and of content, medium and layout for its in tented purpose.

External outputs are those whose destination will be outside the organization
Interactive outputs are those, in which user uses in communicating directly with computer

3.4 DATABASE DESIGN

The Database Management System (DBMS) consists of a collection of Interrelated


data and a set of programs to access that data. The collection of data usually referred to as
database. The primary key goal of DBMS is to provide an environment that is both
convenient and efficient to use in retrieving and storing data information.

The term database design can be used to describe many different parts of the design of
an overall database system. Principally and most correctly, it can be thought of as the logical
design of the base data structures used to store the data. In the relational model these are the
tables and views. In an object database the entities and relationships map directly to object
classes and named relationships. However, the term database design could also be used to
apply to the overall process of designing, not just the base data structures, but also the forms
and queries used as part of the overall database application within the database management
system (DBMS)

The process of doing database design generally consists of a number of steps which
will be carried out by the database designer.

15
3.5 SYSTEM DEVELOPMENT

A system development project encompasses all the activities undertaken from the
time at which a potential requirement is identified until the resulting system is fully
implemented and accepted by the end user. The process can involve many stages over a long
period. The following section highlights some fundamental issues to be considered. outlines
the main stages in development and procuring new systems, and indicates when and how the
auditor should be involved.

An information system acquired today must not only satisfy present business needs, it
must also be flexible and capable of being enhanced to meet changing circumstances well
into the future. Thus, a pre-requisite to the introduction of a new system is for management to
identify and understand their organization's mission and its related information needs.
Writing this down helps to ensure common understanding and direction, and provides a
yardstick against which achievement can be measured.

3.5.1 Methodology of A.I

Assistant Using Python

Speech Recognition module

The system uses Google’s online speech recognition system for converting speech
input to text. The speech input Users can obtain texts from the special corpora organized on
the computer network server at the information centre from the microphone is temporarily
stored in the system which is then sent to Google cloud for speech recognition. The
equivalent text is then received and fed to the central processor.

API calls

API stands for Application Programming Interface. An API is a software intermediary


that allows two applications to talk to each other. In other words, an API is a messenger that
delivers your request to the provider that you’re requesting it from and then delivers the
response back to you.

16
Content Extraction

Context extraction (CE) is the task of automatically extracting structured information


from unstructured and/or semi-structured machine-readable documents. In most cases, this
activity concerns processing human language texts using natural language processing (NLP).
Recent activities in multimedia document processing like automatic annotation and content
extraction out of images/audio/video could be seen as context extraction TEST RESULTS.

Text-to-speech module

Text-to-Speech (TTS) refers to the ability of computers to read text aloud. A TTS
Engine converts written text to a phonemic representation, then converts the phonemic
representation to waveforms that can be output as sound. TTS engines with different
languages, dialects and specialized vocabularies are available through third-party publishers.

4.TESTING AND IMPLEMENTATION

SYSTEM TESTING

Artificial intelligence (AI) has blessed several industries with its efficiency and
accuracy. Businesses are leveraging AI to deliver flawless customer experience at a fraction
of the costs that they used to spend before. Virtual assistants (VA) are helping businesses to
automate customer support and engagement round the clock without any human intervention.
AI-powered solutions have become increasingly popular among both startups and global
enterprises to interact with customers at scale.

17
Key metrics to test virtual assistants 

It is essential to keep in mind the below mentioned key metrics when testing virtual
assistants: 

1. Response time: 

Normally, AI-enabled virtual assistants are expected to reply instantly after an input is
received from the user. Any lag in response can affect the user experience. Hence, it is
business-critical to test the exact response time of the VA to ensure a customer delight
experience. 

2. Answering/Response accuracy: 

Test the responses or answers by VAs to inputs or queries to ensure they are meeting
the business objective efficiently. 

3. Error management: 

AI-enabled VA is equipped to handle errors and address them. For instance, if a


virtual assistant is unable to process user inputs, it should be able to think alternately and ask
different questions from the user to eliminate dead air in the conversation. In worst case
scenario, it should transfer the call to a live agent. 

4. Personality: 

Virtual assistants should have a unique tone that is pleasant for users. To ensure a
great customer experience, its tone should be tested and rectified if needed. 

5. Navigation: 
Customers often feel lost while communicating with a virtual assistant. Make sure the
navigation of the VA is user-friendly for an seamless experience. 

18
5.CONCLUSION

In this paper “Virtual Assistant Using Python” we discussed the design and implementation
of Digital Assistance. The project is built using open-source software modules with PyCharm
community backing which can accommodate any updates shortly. The modular nature of this
project makes it more flexible and easier to add additional features without disturbing current
system functionalities.

It not only works on human commands but also give responses to the user based on the query
being asked or the words spoken by the user such as opening tasks and operations. It is
greeting the user the way the user feels more comfortable and feels free to interact with the
voice assistant. The application should also eliminate any kind of unnecessary manual work
required in the user life of performing every task. The entire system works on the verbal input
rather than the next one.

19
BIBLIOGRAPHY

Books References
1. Adriana Stan Beata Lorincz,” GENERATING THE VOICE OF THE INTERACTIVE
VIRTUAL ASSISTANT”, Feb 10th 2021
2. Ali soofastaei,” VIRTUAL ASSISTANT”, Artificial Intelligence Center, Australia,2021

WEBSITES
1. http://www.github.com/
2. http://www.projectworld.com/
3. http://www.greeks for greeks.com/

20
APPENDICES

A) DATA FLOW DIAGRAM

LEVEL 0

LEVEL 1

21
B) SAMPLE CODING

import subprocess

import wolframalpha

import pyttsx3

import json

import speech_recognition as sr

import datetime

import wikipedia

import webbrowser

import os

import winshell

import pyjokes

import smtplib

import ctypes

import time

import requests

import shutil

22
from twilio.rest import Client

from clint.textui import progress

from ecapture import ecapture as ec

from urllib.request import urlopen

engine = pyttsx3.init('sapi5')

voices = engine.getProperty('voices')

engine.setProperty('voice', voices[1].id)

def speak(audio):

engine.say(audio)

engine.runAndWait()

def wishMe():

hour = int(datetime.datetime.now().hour)
23
if hour >= 0 and hour < 12:

speak("Good Morning Sir !")

elif hour >= 12 and hour < 18:

speak("Good Afternoon Sir !")

else:

speak("Good Evening Sir !")

assname = ("pixie")

speak("thats my name bro")

speak(assname)

def username():

speak("What your name")

uname = takeCommand()

speak("Welcome ")
24
speak(uname)

columns = shutil.get_terminal_size().columns

print("#####################".center(columns))

print("Mr.", uname.center(columns))

print("#####################".center(columns))

speak("How can i Help you, Sir")

def takeCommand():

r = sr.Recognizer()

with sr.Microphone() as source:

print("Listening...")

r.pause_threshold = 1

audio = r.listen(source)
25
try:

print("Recognizing...")

query = r.recognize_google(audio, language='en-in')

print(f"User said: {query}\n")

except Exception as e:

print(e)

print("Unable to Recognize your voice.")

return "None"

return query

def sendEmail(to, content):

server = smtplib.SMTP('smtp.gmail.com', 587)

server.ehlo()

server.starttls()
26
# Enable low security in gmail

server.login('your email id', 'your email password')

server.sendmail('your email id', to, content)

server.close()

if __name__ == '__main__':

clear = lambda: os.system('cls')

# This Function will clean any

# command before execution of this python file

clear()

wishMe()

username()

while True:

27
query = takeCommand().lower()

# All the commands said by user will be

# stored here in 'query' and will be

# converted to lower case for easily

# recognition of command

if 'wikipedia' in query:

speak('Searching Wikipedia...')

query = query.replace("wikipedia", "")

results = wikipedia.summary(query, sentences=3)

speak("According to Wikipedia")

print(results)

speak(results)

elif 'open youtube' in query:

speak("Here you go to Youtube\n")

webbrowser.open("youtube.com")

28
elif 'open google' in query:

speak("Here you go to Google\n")

webbrowser.open("google.com")

elif 'open stackoverflow' in query:

speak("Here you go to Stack Over flow.Happy coding")

webbrowser.open("stackoverflow.com")

elif 'play music' in query or "play song" in query:

speak("Here you go with music")

# music_dir = "G:\\Song"

music_dir = "C:\\Users\\GAURAV\\Music"

songs = os.listdir(music_dir)

print(songs)

random = os.startfile(os.path.join(music_dir, songs[1]))

elif 'the time' in query:

strTime = datetime.datetime.now().strftime("% H:% M:% S")


29
speak(f"Sir, the time is {strTime}")

elif 'open opera' in query:

codePath = r"C:\\Users\\GAURAV\\AppData\\Local\\Programs\\Opera\\launcher.exe"

os.startfile(codePath)

elif 'email to gaurav' in query:

try:

speak("What should I say?")

content = takeCommand()

to = "Receiver email address"

sendEmail(to, content)

speak("Email has been sent !")

except Exception as e:

print(e)

speak("I am not able to send this email")

elif 'send a mail' in query:


30
try:

speak("What should I say?")

content = takeCommand()

speak("whome should i send")

to = input()

sendEmail(to, content)

speak("Email has been sent !")

except Exception as e:

print(e)

speak("I am not able to send this email")

elif 'how are you' in query:

speak("I am fine, Thank you")

speak("How are you, Sir")

elif 'fine' in query or "good" in query:

speak("It's good to know that your fine")

31
elif "change my name to" in query:

query = query.replace("change my name to", "")

assname = query

elif "change name" in query:

speak("What would you like to call me, Sir ")

assname = takeCommand()

speak("Thanks for naming me")

elif "what's your name" in query or "What is your name" in query:

speak("people call me")

speak(assname)

print("people call me", assname)

elif 'exit' in query:

speak("Thanks for giving me your time")

exit()

32
elif "who made you" in query or "who created you" in query:

speak("I have been created by bittu.")

elif 'say me a joke' in query:

speak(pyjokes.get_joke())

elif 'say me another joke' in query:

speak(pyjokes.get_joke())

elif "calculate" in query:

app_id = "Wolframalpha api id"

client = wolframalpha.Client(app_id)

indx = query.lower().split().index('calculate')

query = query.split()[indx + 1:]

res = client.query(' '.join(query))

answer = next(res.results).text

print("The answer is " + answer)


33
speak("The answer is " + answer)

elif 'search' in query or 'play' in query:

query = query.replace("search", "")

query = query.replace("play", "")

webbrowser.open(query)

elif "who i am" in query:

speak("If i am not blind , i think you are a human , are you?.")

elif "yes i am human" in query:

speak("Then why did even ask that question , are you dumb or what?.")

elif "how did you came to world" in query:

speak("Thanks to bittu. further It's a secret")

elif 'power point presentation' in query:


34
speak("opening Power Point presentation")

power = r"C:\\Users\\GAURAV\\Desktop\\Minor Project\\Presentation\\Voice


Assistant.pptx"

os.startfile(power)

elif 'is love' in query:

speak("It is 7th sense that destroy all other senses and i hope master dont get fool by
love")

elif "who are you" in query:

speak("I am your virtual assistant created by bittu")

elif 'reason for you' in query:

speak("I was created as a Minor project by Mister bittu ")

elif 'change background' in query:

ctypes.windll.user32.SystemParametersInfoW(20,

0,

35
"Location of wallpaper",

0)

speak("Background changed successfully")

elif 'open bluestack' in query:

appli = r"C:\\ProgramData\\BlueStacks\\Client\\Bluestacks.exe"

os.startfile(appli)

elif 'news' in query:

try:

jsonObj = urlopen(

'''https://newsapi.org / v1 / articles?source = the-times-of-india&sortBy =


top&apiKey =\\times of India Api key\\''')

data = json.load(jsonObj)

i=1

speak('here are some top news from the times of india')

36
print('''=============== TIMES OF INDIA ============''' + '\n')

for item in data['articles']:

print(str(i) + '. ' + item['title'] + '\n')

print(item['description'] + '\n')

speak(str(i) + '. ' + item['title'] + '\n')

i += 1

except Exception as e:

print(str(e))

elif 'lock window' in query:

speak("locking the device")

ctypes.windll.user32.LockWorkStation()

elif 'shutdown system' in query:

speak("Hold On a Sec ! Your system is on its way to shut down")


37
subprocess.call('shutdown / p /f')

elif 'empty recycle bin' in query:

winshell.recycle_bin().empty(confirm=False, show_progress=False, sound=True)

speak("Recycle Bin Recycled")

elif "don't listen" in query or "stop listening" in query:

speak("for how much time you want to stop jarvis from listening commands")

a = int(takeCommand())

time.sleep(a)

print(a)

elif "where is" in query:

query = query.replace("where is", "")

location = query

speak("User asked to Locate")

speak(location)

webbrowser.open("https://www.google.com / maps / place/" + location + "")


38
elif "camera" in query or "take a photo" in query:

ec.capture(0, "Jarvis Camera ", "img.jpg")

elif "restart" in query:

subprocess.call(["shutdown", "/r"])

elif "hibernate" in query or "sleep" in query:

speak("Hibernating")

subprocess.call("shutdown / h")

elif "log off" in query or "sign out" in query:

speak("Make sure all the application are closed before sign-out")

time.sleep(5)

subprocess.call(["shutdown", "/l"])

elif "write a note" in query:

speak("What should i write, sir")


39
note = takeCommand()

file = open('pixie.txt', 'w')

speak("Sir, Should i include date and time")

snfm = takeCommand()

if 'yes' in snfm or 'sure' in snfm:

strTime = datetime.datetime.now().strftime("% H:% M:% S")

file.write(strTime)

file.write(" :- ")

file.write(note)

else:

file.write(note)

elif "show note" in query:

speak("Showing Notes")

file = open("pixie.txt", "r")

print(file.read())

speak(file.read(6))

40
elif "update assistant" in query:

speak("After downloading file please replace this file with the downloaded one")

url = '# url after uploading file'

r = requests.get(url, stream=True)

with open("Voice.py", "wb") as Pypdf:

total_length = int(r.headers.get('content-length'))

for ch in progress.bar(r.iter_content(chunk_size=2391975),

expected_size=(total_length / 1024) + 1):

if ch:

Pypdf.write(ch)

# NPPR9-FWDCX-D2C8J-H872K-2YT43

elif "pixie" in query:

wishMe()
41
speak("pixie 1 point o in your service Mister")

speak(assname)

elif "weather" in query:

# Google Open weather website

# to get API of Open weather

api_key = "Api key"

base_url = "http://api.openweathermap.org / data / 2.5 / weather?"

speak(" City name ")

print("City name : ")

city_name = takeCommand()

complete_url = base_url + "appid =" + api_key + "&q =" + city_name

response = requests.get(complete_url)

x = response.json()

if x["code"] != "404":

y = x["main"]
42
current_temperature = y["temp"]

current_pressure = y["pressure"]

current_humidiy = y["humidity"]

z = x["weather"]

weather_description = z[0]["description"]

print(" Temperature (in kelvin unit) = " + str(

current_temperature) + "\n atmospheric pressure (in hPa unit) =" + str(

current_pressure) + "\n humidity (in percentage) = " + str(

current_humidiy) + "\n description = " + str(weather_description))

else:

speak(" City Not Found ")

elif "send message " in query:

# You need to create an account on Twilio to use this service

account_sid = 'Account Sid key'

auth_token = 'Auth token'

client = Client(account_sid, auth_token)


43
message = client.messages \

.create(

body=takeCommand(),

from_='Sender No',

to='Receiver No'

print(message.sid)

elif "wikipedia" in query:

webbrowser.open("wikipedia.com")

elif "Good Morning" in query:

speak("A warm" + query)

speak("How are you Mister")

speak(assname)

44
# most asked question from google Assistant

elif "will you be my gf" in query or "will you be my bf" in query:

speak("no i m fine, just ask a real girl dude and stop simping at an a i")

elif "how are you" in query:

speak("I'm fine, glad you me that")

elif "i love you" in query:

speak("please go out and find a real girl")

elif "what is" in query or "who is" in query:

# Use the same API key

# that we have generated earlier

client = wolframalpha.Client("API_ID")

res = client.query(query)

try:
45
print(next(res.results).text)

speak(next(res.results).text)

except StopIteration:

print("No results")

# elif "" in query:

# Command go here

# For adding more commands

C) SAMPLE INPUT

46
47
48
49
D) SAMPLE OUTPUT

50
51

You might also like