0% found this document useful (0 votes)
15 views25 pages

Minor

Uploaded by

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

Minor

Uploaded by

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

[acknowledgement]

i would like to express my special thanks


of gratitude to our department teacher
“Vivekananda gayen” for their able
guidance and support in completing our
project.

MINOR PROJECT ON:


VOICE ASSISTANT (Using Python)
Under guidance of Vivekananda Gayen

Submitted by:

NIRUPAM GARAI : D222302440


ANIT GOLDAR : D222302442
MD IMTIAZ ALI : D222302439
SUJAYA MUKHERJEE : D222302441
JOY MAITY : D222302452
PRASENJIT DAS : D222302455

DIPLOMA IN COMPUTER SCIENCE & TECHNOLOGY.


4THSEMESTER 2ND YEAR
(CST)

SIR RAJENDRA NATH MUKHERJEE GOVT.


POLYTECHNIC
(BAS)
SERIAL NO. FULL NAME RESPONSIBILITY

1 NIRUPAM GARAI BACK-END CODING

2 ANIT GOLDAR BACK-END CODING

3 MD IMTIAZ ALI BACK-END CODING

4 SUJAYA MUKHERJEE ANALYSING & TESTING

5 JOY MAITY ANALYSING & TESTING

6 PRASENJIT DAS ANALYSING & TESTING


INDEX

SL.NO. CONTENTS PAGE NO.

1. INTRODUCTION

2. FUNCTIONALITY OF VOICE ASSISTANT

3. PROPOSED SYSTEM

4. SOURCE CODE

5. OUTPUT

6. APPLICATION

7. FUTURE SCOPE

8. TESTING

9. COCLUSION

10. LIMITATION
INTRODUCTION

VOICE ASSISTANT:
A voice assistant is a digital assistant that uses voice
recognition, language processing algorithms, and voice
synthesis to listen to specific voice commands and return
relevant information or perform specific functions as
requested by the user.

Based on specific commands, sometimes called intents,


spoken by the user, voice assistants can
return relevant information by listening for specific keywords
and filtering out the ambient noise.
While voice assistants can be completely software based and
able to integrate into most devices, some assistants are
designed specifically for single device applications, such as
the Amazon Alexa Wall Clock.

Today, voice assistants are integrated into many of the


devices we use on a daily basis, such as cell phones,
computers, and smart speakers. Because of their wide array
of integrations, There are several voice assistants who offer a
very specific feature set, while some choose to be open
ended to help with almost any situation at hand.
FUNCTIONALITY OF VOICE ASSITENT:

speck Function:
#text to speach
def speck(audio,rate = 180):
engine.setProperty('rate',rate) # rate maintain the speed
of voice
engine.say(audio)
print(audio)
engine.runAndWait()# start executing next line after
completion of speak

Purpose: Converts text to speech and speaks it aloud. It also prints


the text to the console.

Parameters:
• audio: The text to be spoken.
• rate: The speed at which the text will be spoken (default is
180).
capture_voice_input Function:
#Create a function to capture voice input from the user using
a microphone:
#capture_voice_input()
def capture_voice_input():
with sr.Microphone() as source:

#recognizer.adjust_for_ambient_noise(source,duration=1)
#recognizer.energy_threshold()

print("Listening...")
recognizer.pause_threshold = 1 # Minimum length of
silence that will register as the end of a phrase

audio = recognizer.listen(source,0,5)# listening


duration 5 seconds
return audio

Purpose: Captures voice input from the user using the microphone.
Returns:
• An audio object containing the captured voice input.

convert_voice_to_text Function:
#Create a function to convert the captured voice input to
text:

def convert_voice_to_text(audio):
try:
text = recognizer.recognize_google(audio) # use google
recognizer for voice to text
print("You said: " + text)
except:
speck("Sorry, I didn't understand that. try again") #
handle any error in recognizer
return "none"

return text
Purpose: Converts the captured voice input to text using Google's
speech recognition service.

Parameters:
• audio: The audio input captured from the microphone.

Returns:
• The recognized text, or "none" if recognition fails.

intro Function:
# for introduction of assitent
def intro():
speck("hello , i am anna . how can i help you") # speak
the introduction
return

Purpose: Introduces the voice assistant.

auto_search_with_topic Function:
def auto_search_with_topic(text):

# for searching in wikipedia


if "wikipedia" in text.lower():

speck("searching on wikipedia.....",)
text1 = search_wiki(text)

if 'try again' != text1:


speck("according to wikipedia "+text1)
else:
speck("i can't understand the query")
else:
speck("searching.....")
topic ='https://www.google.com/search?q='+ text
topic1 ='https://www.youtube.com/search?q='+ text
# then call the default open method described above
#webbrowser.open(url1)

webbrowser.open(topic1)
return

Purpose: Determines whether to search Wikipedia or perform a web search based on the
text.

Parameters:

 text: The text input to be searched.

Behavior:

 If the text includes "wikipedia", it performs a Wikipedia search and reads the result.
 Otherwise, it opens a Google or YouTube search in the web browser.

search_wiki Function:

# for Searcing wikipedia


def search_wiki(str_search):
try:
# Replacing the Activation word from the query
query = str_search.lower()
if 'search on wikipedia' in query:
query = query.replace('search on wikipedia', '').strip()
elif 'on wikipedia' in query:
query = query.replace('on wikipedia', '').strip()
elif 'according to wikipedia' in query:
query = query.replace('according to wikipedia', '').strip()
elif 'in wikipedia' in query:
query = query.replace('in wikipedia', '').strip()
elif 'wikipedia' in query:
query = query.replace('wikipedia', '').strip()

result = wikipedia.summary(query) # taking only the summary


from wikipedia

temp = result.split('.') # splits the string into sentence


temp = '.'.join(temp[:3])# taking only 3 sentence and join then
together
return temp+'.' # returning the String

except Exception:# Exception handing for any error to Searching

return "try again"

Purpose: Searches Wikipedia for a summary of the query.

Parameters:

 str_search: The search query.

Returns:

 A summary of the Wikipedia article, or "try again" if an error occurs.

Main Logic:

intro()
audio = capture_voice_input()

text = convert_voice_to_text(audio)
if text.lower() != 'none':
auto_search_with_topic(text)

Purpose: Executes the main flow of the voice assistant:

1. Introduces the assistant.


2. Captures voice input.
3. Converts the voice input to text.
4. Performs a search based on the text.
PROPOSED SYSTEM
The following documentation is a project the "Name of the
term paper allotted". It is a detailed summary of allthe
drawbacks of the old system and how the new proposed
system overcomes these shortcomings. The new system
takes into account the various factors while designing a new
system.It keeps into the account the Economical bandwidth
available for the new system. The foremost thing that is
taken care of is the Need and Requirements of the User.

DESCRIPTION
Before developing software, we keep following things in
mind that we can develop powerful and quality software

PROBLEM STATEMENT
Problem statement was to design a module:
O Which is user friendly
O Which will restrict the user from accessing other user's
data.
O Which will help user in viewing his data and privileges.
O Which will help the administrator to handle all the
changes.
FUNCTIONS TO BE PROVIDED:

The system will be user friendly and completely menu driven


so that the users shall have no problem in using all options.

O The system will be efficient and fast in response.


O The system will be customized according to needs.

SYSTEM REQUIRMENTS:

Operating system: Windows 10

Language: Python

Processor: Intel Core i3-4160

RAM: 512 MB

Hard Disk: 50 GB and up


Then we began with the design phase of the system. System
design is a solution, a "HOW TO" approach to the creation of
a new system. It translates system requirements into ways by
which they can be made operational. It is a translational from
a user-oriented document to a document oriented
programmers. For that, it provides the understanding and
procedural details necessary for the implementation. Here
we use flowchart to supplement the working of the new
system. The system thus made should be reliable durable and
above all should have least possible maintenance costs. It
should overcome all the drawbacks of the old existing system
and most important of all meet the user requirements.
FLOW CHART
SOURCE CODE

# https://reintech.io/blog/how-to-create-a-
voice-recognition-system-with-python
#topic ='https://www.google.com/search?q='+ x
#topic1 ='https://www.google.com/search?q=(x)'

# pip install SpeechRecognition


# pip install pyttsx3 # to canvert text to sp
# install following

# sudo apt install python3-pyaudio


importpyttsx3
importspeech_recognitionassr
importwikipedia
importwebbrowser

engine=pyttsx3.init("sapi5") # creating a
pyttsx3 object

voices=engine.getProperty('voices') # geting
the list of voices

engine.setProperty('voice',voices[1].id)#
seting a certain voice for speak

#text to speach
defspeck(audio,rate=180):
engine.setProperty('rate',rate) # rate
maintain the speed of voice
engine.say(audio)
print(audio)
engine.runAndWait()# start executing next
line after completion of speak

#Create an instance of the Recognizer class:

recognizer=sr.Recognizer()

#Create a function to capture voice input from


the user using a microphone:

defcapture_voice_input():
withsr.Microphone() assource:

#recognizer.adjust_for_ambient_noise(source,du
ration=1)
#recognizer.energy_threshold()

print("Listening...")
recognizer.pause_threshold=1
# listening duration 5 seconds
audio=recognizer.listen(source,0,5)
returnaudio

#capture_voice_input()

#Create a function to convert the captured


voice input to text:

defconvert_voice_to_text(audio):
try:

text=recognizer.recognize_google(audio)
print("You said: "+text)
except:
speck("Sorry, I didn't understand
that. try again")
return"none"

returntext

'''
#list_microphone_names() method will return a
array/list of \
#the connected microphones to the system.
lst1 = sr.Microphone.list_microphone_names()
print(len(lst1))
'''
# for introduction of assitent
defintro():
speck("hello , i am anna . how can i help
you")
return

defauto_search_with_topic(text):

# for searching in wikipedia


if"wikipedia"intext.lower():

speck("searching on
wikipedia.....",)
text1=search_wiki(text)

if'try again'!=text1:
speck("according to
wikipedia "+text1)
else:
speck("i can't
understand the query")
else:
speck("searching.....")

topic='https://www.google.com/search?q='+text

topic1='https://www.youtube.com/search?
q='+text
# then call the default
open method described above
#webbrowser.open(url1)

webbrowser.open(topic1)
return

# for Searcingwikipedia
defsearch_wiki(str_search):
try:
# Replacing the Activation word from
the query
query=str_search.lower()
if'search on wikipedia'inquery:
query=query.replace('search on
wikipedia', '').strip()
elif'on wikipedia'inquery:
query=query.replace('on
wikipedia', '').strip()
elif'according to wikipedia'inquery:
query=query.replace('according to
wikipedia', '').strip()
elif'in wikipedia'inquery:
query=query.replace('in
wikipedia', '').strip()
elif'wikipedia'inquery:
query=query.replace('wikipedia',
'').strip()

result=wikipedia.summary(query) #
taking only the summary from wikipedia

temp=result.split('.') # splits the


string into sentence
temp='.'.join(temp[:3])# taking only 3
sentence and join then together

returntemp+'.'# returning the String

exceptException:# Exception handing for


any error to Searching

return"try again"

intro()
audio=capture_voice_input()

text=convert_voice_to_text(audio)
iftext.lower() !='none':
auto_search_with_topic(text)
OUTPUT
APPLICATION

Voice assistants have numerous applications that enhance


convenience, accessibility, and efficiency:

Smart Home Control: Manage lighting, thermostats, and


security systems through voice commands.
Personal Assistance: Set reminders, alarms, and manage to-
do lists and calendars.
Entertainment: Play music, control smart TVs, and stream
content.
Communication: Make calls, send texts, and manage emails.
Information Retrieval: Answer questions, provide weather
updates, and offer cooking recipes.
Navigation: Offer turn-by-turn directions and traffic updates.
E-Commerce: Place orders, track packages, and find deals.
Healthcare: Remind users to take medications and track
health metrics.
Customer Service: Provide automated support and book
appointments.
Accessibility: Assist individuals with disabilities and offer
language translation.
Voice assistants continue to evolve, integrating with more
devices and services, broadening their utility.

FUTURE SCOPE

The future scope of voice assistant projects includes several


promising advancements:

Enhanced Natural Language Understanding: Improving


context awareness and emotion detection to create more
natural and empathetic interactions.
Multilingual Capabilities: Offering seamless real-time
translation and better handling of regional accents and
dialects.
Personalization: Customizing responses and predicting user
needs based on habits and preferences.
IoT Integration: Expanding compatibility with a wider range
of smart home and IoT devices.
Security and Privacy: Strengthening voice authentication and
ensuring robust data privacy measures.
Accessibility: Enhancing assistive technologies for individuals
with disabilities and supporting elderly care.
Enterprise Solutions: Developing advanced automated
customer support and productivity tools for workplaces.
Healthcare: Integrating health monitoring and telemedicine
capabilities.

Education: Facilitating interactive learning and personalized


tutoring.
Environmental Control: Assisting in energy management and
promoting sustainable choices.
These advancements will make voice assistants more
intuitive, secure, and integrated into everyday life, enhancing
user experience across various domains.

CONCLUSION
Voice assistants are advanced software agents that can
perform tasks or services based on verbal commands. They
use natural language processing (NLP) to understand and
respond to human speech. Examples include Amazon's Alexa,
Apple's Siri, Google Assistant, and Microsoft's Cortana. These
assistants can perform a variety of functions, such as setting
reminders, playing music, providing weather updates,
controlling smart home devices, and answering questions by
accessing information from the internet. Voice assistants are
integrated into smartphones, smart speakers, and other
connected devices, enhancing user interaction through
hands-free operation and improving accessibility for various
user needs.

LIMITATION

Voice assistants have revolutionized the way we interact with


technology, but they're not without limitations. One major
constraint is privacy concerns. Since voice assistants
constantly listen for their wake words, there's a risk of
unintentionally recording private conversations. Moreover,
they may struggle with accents, dialects, and speech
impediments, limiting accessibility for some users.
Additionally, voice assistants often lack context and
understanding, leading to misinterpretations and frustrating
experiences. Lastly, they rely heavily on internet connectivity,
rendering them useless in areas with poor or no network
coverage. Despite these limitations, continuous
advancements in technology aim to address these issues and
enhance the overall user experience.

You might also like