0% found this document useful (0 votes)
17 views

PRO COMP

Uploaded by

anonymous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

PRO COMP

Uploaded by

anonymous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 83

1|P a ge

2|P a ge
THIS IS TO HEREBY CERTIFY THAT “HARSH SAINI”
OF CLASS XII(SCI) OF SHRI RAM SHIKSHA MANDIR
HAS COMPLETED HIS PROJECT ON THE TOPIC
VOICE ASSISTANT BY PYTHON UNDER THE
GUIDANCE OF MR. ANKUR GARG. HE HAS TAKEN
PROPER CARE AND SHOWN UTMOST SINCERITY IN
COMPLETING THIS PROJECT. I CERTIFY THAT THIS
PROJECT IS UPTO MY EXPECTATIONS AND AS PER
THE GUIDELINES OF CBSE.

SIGNATURE OF SUBJECT TEACHER SIGNATURE OF PRINCIPLE

3|P a ge
I would like to express my special gratitude to
the principal MS. NEETU MUNJAL, for her
encouragement and for all the support that she
provided for this work. I am grateful to my
teacher MR. ANKUR GARG
for supporting me throughout completion of
this project.

I also extend my sincere gratitude to my


family without whom this project would
not have been possible.

4|P a ge
5|P a ge
6|P a ge
7|P a ge
WORKING ENVIRONMENT

Python is a high-level, general-purpose programming


language known for its simplicity, readability, and
versatility. It was created by Guido van Rossum and first
released in 1991. Python emphasizes code readability,
allowing developers to express concepts in fewer lines of
code compared to other languages like C++ or Java.

Beginner-Friendly: Python’s simplicity makes it easy for


beginners to pick up.
Versatile: It can be used in various domains such as
web development, data science, machine learning,
automation, etc.
High Demand: Python is one of the most in-demand
programming languages in the tech industry

8|P a ge
Simple and Readable Syntax: Python's syntax is clear and easy
to learn, making it an ideal language for beginners. Its code is
often compared to plain English, allowing for easier understanding
and maintenance.

Interpreted Language: Python is an interpreted language,


meaning the code is executed line by line, which helps with
debugging and rapid development.

Dynamically Typed: Python does not require you to declare the


data type of variables. The type is determined at runtime, making
coding more flexible.

Cross-Platform: Python is cross-platform, meaning it runs on


various operating systems like Windows, macOS, and Linux without
the need to modify the code.

Extensive Standard Library: Python comes with a comprehensive


standard library that provides tools for handling many tasks such
as file I/O, system calls, and even web services. This reduces the
need for external libraries in many cases.

Large Ecosystem and Community: Python has a vast ecosystem


of libraries and frameworks for various domains, including web
development, data science, artificial intelligence, and machine
learning. Examples include:

 Django and Flask for web development


 Pandas and NumPy for data analysis
 TensorFlow and PyTorch for machine learning

9|P a ge
Web Development: Frameworks like Django and
Flask make Python a great choice for building web
applications.

Data Science and Machine Learning: Python's


extensive libraries, such as NumPy, Pandas, and
Scikit-learn, make it a popular choice for data
analysis, machine learning, and artificial intelligence.

Automation/Scripting: Python is often used for


automating mundane tasks such as file renaming,
downloading, and data scraping.

Game Development: While not as common as


other languages, Python libraries like Pygame allow
for simple game development.

Scientific Computing: Libraries such as SciPy and


Matplotlib make Python a go-to tool for scientists
and researchers.

System Administration: Python scripts can help


in system monitoring, managing servers, and other
administrative tasks.

10 | P a g e
To begin with, you need to install Python on your computer. You can download the latest version of Python
from the official Python website

1. Visit python.org
2. Navigate to the “download”
section
3. Select the appropriate version
of your operating system (win,
macOS or Linux)
4. Download the installer file

Once the installer is downloaded, follow these steps to install Python:

WINDOWS:
a) Run the installer file you
downloaded.
b) Make sure to click the box that
says “Add python to path”.

11 | P a g e
MacOS:
a) 0pen the downloaded .pkg file.
b) Follow the installation instructions.
c) Python should be added in your path.

LINUX:
a) Open the terminal.
b) Use the package manager specific to your
distribution.

To verify that Python is installed correctly:

 Open a terminal (Command Prompt on


Windows, Terminal on macOS and
Linux).
 Type the following command and press
Enter: [ python –version] This should
display the version of Python installed on
your system.
12 | P a g e
Using an Integrated Development Environment
(IDE)
Using a Text Editor
• Visual Studio Code (VS Code):

a. Download vs code from its


official website.
b. Install VS Code by following the installation instructions
specific to your operating system.
c. Launch VS Code and install the Python extension: ▪ Go
to the Extensions view by clicking on the Extensions icon
in the Activity Bar on the side of the window. ▪ Search
for "Python" and install the extension provided by
Microsoft.
d. Configure the Python interpreter in VS Code by opening the
Command Palette (Ctrl+Shift+P), typing "Python: Select
Interpreter", and choosing the correct Python interpreter.

13 | P a g e
With Python installed and your
development environment set up, you
can start writing and running Python
code.

• In PyCharm:
 Create a new Python file (.py) in your project.
 Write your Python code in the file.
 Run the code by right-clicking the file and
selecting "Run" or by using the run button.

• In VS Code:
 Create a new Python file (.py).
 Write your Python code in the file.
 Run the code by pressing F5 or by opening
the terminal in VS Code and typing: [
python filename.py ]
By following these steps, you will have Python installed and a
development environment set up, ready for you to start coding and
developing your Hotel Management System.

14 | P a g e
Python scripts are simple text files with a .py extension.
These scripts can be written in any text editor or integrated
development environment (IDE). Once written, you can
execute these scripts using the command line or within the
IDE itself.

STEP 1: WRITING PYTHON SCRIPT


To write a Python script, you can use a text editor or an IDE of your choice.
Here’s a simple example of a Python script:

 You can use a basic text editor like Notepad (Windows), TextEdit
(macOS), or Nano/Vim (Linux).
 Alternatively, you can use an IDE like PyCharm or a text editor with

 Python support like Visual Studio Code (VS Code).


 In your text editor or IDE, create a new file and save it with a .py extension, for
example, hello_world.py.

Here’s an example of a simple Python script that prints "Hello, World!" to the console: #
hello_world.py print("Hello, World!")

STEP 2: EXECUTING PYTHON SCRIPT


There are two primary ways to execute Python scripts: using
the command line or an IDE.
Executing Python Scripts Using the
Command Line

15 | P a g e
Open the command line:
 On Windows, open Command Prompt.
 On macOS, open Terminal.
 On Linux, open Terminal.

Navigate to the directory containing your Python script:


Use the cd command to change the directory. For example, if your script is in the Documents
folder:
[ cd Documents]
Run the Python script:
 Use the python or python3 command followed by the script’s filename. For example: [
python hello_world.py]
 You should see the output "Hello, World!" printed in the command line.

Executing Python Scripts Using an IDE


Open your IDE:
 Launch your IDE (e.g., PyCharm or VS Code).
Open your Python script:
 Open the .py file you created.
Run the script:
 In PyCharm, you can run the script by right-clicking the file and selecting "Run 'filename'" or by
using the run button.
 In VS Code, you can run the script by pressing F5 or by opening the terminal in VS Code and
typing: [ python hello_world.py]
 The output "Hello, World!" will be displayed in the IDE’s output window or terminal.

STEP 3: EDITING AND RE_RUNNING


THE PYTHON SCRIPT 16 | P a g e
After writing and executing your script, you may want to
make changes and run it again:
Edit your script:
 Open your .py file in your text editor or IDE.
 Make the necessary changes to your code.
 Save the file.

Re-run the script:


 Follow the same steps to execute the script using the command line or your IDE.

By following these steps, you can write and execute


Python scripts effectively, allowing you to develop and
test your code efficiently.

Variables in Python
Variables are used to store information that can be
referenced and manipulated throughout a program.
In Python, variables do not require explicit
declaration to reserve memory space. Instead, the
declaration happens automatically when a value is
assigned to the variable.
17 | P a g e
Key Points about Variables in
Python:
Dynamic Typing:
Python is dynamically typed, meaning you do not
need to specify the type of variable. The type is
inferred from the value assigned to it.
Assignment:
You can assign a value to a variable using the =
operator.
Reassignment:
Variables can be reassigned to different values, and
even different data types, at any point in the
program.

18 | P a g e
Naming Conventions:

Variable names should start with a letter or


underscore (_), followed by letters, digits, or
underscores. Variable names are case-sensitive.

EXAMPLE:

19 | P a g e
Explanation of the Example:
Initial Assignment:
Variables x, y, name, and is_student are assigned
values of different data types (integer, float,
string, and Boolean, respectively).
Printing Variables:
The print function is used to display the values of
the variables.
Reassignment:
The values of x and name are changed to 20 and
"Bob", respectively.
Dynamic Typing:
The variable z is first assigned a string value "Hello"
and later reassigned to an integer value 42. Python
handles the change in data type automatically.

By understanding how variables work in Python,


you can efficiently store and manipulate data
within your programs.

20 | P a g e
21 | P a g e
22 | P a g e
23 | P a g e
24 | P a g e
25 | P a g e
26 | P a g e
27 | P a g e
28 | P a g e
29 | P a g e
30 | P a g e
31 | P a g e
32 | P a g e
33 | P a g e
34 | P a g e
35 | P a g e
36 | P a g e
Functions are reusable blocks of code that perform specific tasks. They allow you to structure
your code into modular units, making it easier to manage and reuse. Python supports both built-in
functions (like print (), Len (), type (), etc.) and user-defined functions.

Defining Functions
To define a function in Python, you use the def keyword followed by the function name and
parentheses containing optional parameters. The function body is indented and contains the code to
be executed.
Example: Defining and Calling a Function

37 | P a g e
Built-in Functions
Python comes with a set of built-in functions that are ready to use without the need for defining
them. Some commonly used built-in functions include:

 print (): Outputs a message to the console.


 Len (): Returns the length of an object (e.g.,
string, list, tuple).
 type (): Returns the type of an object.
 input (): Reads input from the user.
Example: Using Built-in Functions

38 | P a g e
User-defined Functions
You can also create custom functions tailored to your specific needs. These are called user-
defined functions.
Example: Creating a User-defined Function (new
customer)

39 | P a g e
Modules in Python are files containing Python code. This code can define functions, classes, and
variables that can be used in other Python programs. Modules help organize code into reusable
units and facilitate modular programming.
Introduction to Using Modules
To use a module in Python, you typically import it using the import statement. There are
different ways to import modules:

Importing Entire Module:

Importing Specific Items from a Module:

Renaming a Module or Item:

40 | P a g e
Common Modules in Python
Python's standard library includes a wide range of modules that provide ready-to-use functions
and classes for various tasks. Some common modules include:

math: Provides mathematical functions like sqrt(), sin(),


cos(), etc.

random: Provides functions for generating random numbers


and making random selections.

datetime: Provides classes for manipulating dates and


times.

41 | P a g e
Modules USED
SPEECH_RECPRGNITION
In Python, speech recognition allows the conversion of spoken language into text, which can be
used in various applications like virtual assistants, transcription tools, or voice-controlled
systems.

PYTTSX3
pyttsx3 is a Python library that converts text to speech (TTS). It is platform-independent and
works offline, meaning it doesn't require an internet connection. Unlike some other TTS
libraries (like Google Text-to-Speech), pyttsx3 uses the text-to-speech engine installed on
your system and can work with voices provided by the operating system.

DATETIME
In Python, the datetime module is used to work with dates and times. It provides a variety of
classes and functions to manipulate dates and times, perform date arithmetic, and format or parse
dates.

42 | P a g e
Python, the Wikipedia library is a great option. It allows you to easily access and retrieve
information from Wikipedia pages programmatically. This can be useful for various applications,
including bots, data scraping, or simply retrieving information for personal projects.

WEBBROWSER
This module can facilitate browsing the internet, interacting with web pages, scraping data, or
automating web tasks. Below are some key aspects and libraries associated with creating web
browsers or web interactions in Python.

In Python, the os module is a standard library that provides a way of using operating system-
dependent functionality like reading or writing to the file system, interacting with the
environment variables, and performing various system-level operations. It is essential for tasks
that require interaction with the operating system.

SMTPLIMB
The smtplib module in Python is a built-in library used for sending emails using the Simple Mail Transfer Protocol
(SMTP). This module provides functions to create an SMTP client session object, which can be used to send mail to any
internet machine with an SMTP/ESMTP listener daemon.

MIMETEXT
The MIMEText class, which is part of the email.mime.text module in the Python standard
library, is specifically used to create MIME-formatted email messages with plain or HTML
text content.

43 | P a g e
MIMEMultipart is a class in the email.mime.multipart module of Python's standard library that
is used to create multipart email messages. It allows you to send emails that contain multiple
parts, such as plain text, HTML content, and attachments.

REQUESTS
The requests module in Python is a popular and user-friendly library designed for making HTTP requests.
It simplifies the process of sending requests to web servers and receiving responses. The library abstracts
the complexities of handling URL connections, HTTP methods, session management, and more, making it a
preferred choice for web developers and data scientists when interacting with APIs or web scraping.

JSON
The json module in Python is a built-in library that provides functions for working with JSON (JavaScript
Object Notation) data. JSON is a lightweight data interchange format that is easy for humans to read and
write and easy for machines to parse and generate

44 | P a g e
FUNCTIONS USED
Speak(audio):
The speak (audio) function in Python is typically used in applications where there is a need to
convert text to speech (TTS). This function is particularly useful in creating voice assistants,
accessibility tools, educational applications, and any other software that benefits from audio
output.

Greet_user():
The greet_user() function in Python (or any programming language) is typically a custom
function designed to provide a personalized greeting to users.

Take _command():
The take_command function in Python is typically used in the context of voice recognition
applications, particularly those that involve creating voice assistants or chatbots. This function is
designed to capture and process spoken input from the user, converting it into text for further
analysis or action.

45 | P a g e
Sendmail():
The sendmail function in Python is commonly used to send emails programmatically. It is typically
part of the smtplib module, which provides a simple way to connect to an SMTP (Simple Mail
Transfer Protocol) server and send emails from a Python application.

Open_website():
The open website function in Python is typically used to programmatically launch a web browser
and navigate to a specified URL. This functionality can be useful in various scenarios, such as
automating web tasks, testing web applications, or providing users with direct links to resources.

The run_assistant function in Python is typically associated with voice assistants or chatbot
applications. This function is responsible for initiating and managing the main loop of the assistant,
allowing it to listen for user input, process commands, and respond appropriately.

46 | P a g e
HARDWARE AND SOFTWARE
SPECIFICATIONS USED

47 | P a g e
48 | P a g e
49 | P a g e
50 | P a g e
51 | P a g e
52 | P a g e
53 | P a g e
54 | P a g e
55 | P a g e
56 | P a g e
57 | P a g e
OUTPUT

58 | P a g e
59 | P a g e
60 | P a g e
61 | P a g e
62 | P a g e
63 | P a g e
64 | P a g e
65 | P a g e
66 | P a g e
67 | P a g e
68 | P a g e
69 | P a g e
70 | P a g e
71 | P a g e
72 | P a g e
73 | P a g e
74 | P a g e
75 | P a g e
76 | P a g e
77 | P a g e
78 | P a g e
79 | P a g e
80 | P a g e
81 | P a g e
82 | P a g e
83 | P a g e

You might also like