Python Project Voice Converter To Text

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

--------------------------------------------------------------------------------------------------------------------------------------

MAHARASHTRA STATE BOARD OF TECHNICAL


EDUCATION

Mini-Project Report On

“Virtual Voice Assistant using Python”


Submitted in particular fulfilment in the requirement for
6th semester

Diploma in Computer Engineering


Academic year-2022-23

BY
Ajay Shriram Pawara (2000610098)

Under Guidance Of
Mr M Y Varule

Smt. Sharachchandrika Suresh Patil Institute of


Technology (Polytechnic) Chopda-2022-23

1
--------------------------------------------------------------------------------------------------------------------------------------
-

MAHARASHTRA STATE BOARD OF TECHNICAL


EDUCATION

Smt.Sharachchandrika Suresh Patil Institute of


Technology (Polytechnic) Chopda-2022-23

CERTIFICATE
Certified that this is a Bonafide record of the project work titled

“Virtual Voice Assistant using Python”


On

Programming with python


Done by

AJAY PAWARA (2000610098)

of 6th semester Computer Science & Engineering in the year


2022-23 in partial fulfilment of the requirements for the award of
Degree of Diploma in Computer Science & Engineering.

Miss M Y Varule Mr. D.M Fegade


Project Guide Head of the Division
------------------------------------ ----------------------------------

2
--------------------------------------------------------------------------------------------------------------------------------------
-

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


Certificate

This is to certify that Students of CO6I(A) Roll N:339 of 6th Semester of

Diploma Computer Engineering of Institute, Smt. Sirchchandrika Suresh


Patil Institute of Technology (Polytechnic)Chopda- (Code:0061)/has
completed the Micro Project satisfactorily in the Subject –-Programming
with Python(22616) for the Academic Year 2022-23 as prescribed in the
curriculum.

Place-Chopda.
Date: / /2021

Mr M Y Varule Mr D.M Fegade Mr.V.N Borse


Subject Teacher H. O. D Principle
-------------------------- --------------------------------------- -------------------------------------

3
--------------------------------------------------------------------------------------------------------------------------------------
-
CONTENT

Topics Name:- Page


No:-

1.) ACKNOWLEDGEMENT

2.) ABSTRACT

3.) INTRODUCTION

4.) LITERATURE SURVEY

5.) PROPOSED SYSTEM

6.) EXPERIMENT ANALYSIS

7.) FUTURE SCOPE

8.) APPLICATION

9.) RESULT

10.) CONCLUSION

11.) REFERENCES

ACKNOWLEDGEMENT

4
--------------------------------------------------------------------------------------------------------------------------------------
-
------------------------------------------------------------------------------------------------
Acknowledgement

I would like to express my gratitude to my guide and


teacher R.C.
Lokhande who provided me the amazing opportunity
to do this
wonderful Micro-Project of the Course title
‘Management’ (Course
code: 22509) on the topic ‘Study of management
principles applied to
large scale industries’.
Secondly, I want to extend my sincere thanks to our
Principal
well as the Head of the Department of civil
department who have been
an invisible spirit and inspiration to me throughout the
process.
Also, I would like to thank every one of my group
members who
helped me lot to conclude this micro-project within
the limited time
frame.

ABSTRACT
----------------------------------------------------------------------------------------------------------------

5
--------------------------------------------------------------------------------------------------------------------------------------
-
In today’s develop generation, How cool is it to build your own
personal assistants like Alexa or Siri ? It’s not very complex and may be
effortlessly performed in Python. Personal virtual assistants are capturing
numerous attentions lately. Chat bots are not unusual in maximum business web
sites. The predominant agenda of our voice help makes human beings clever
and supply immediate and computed effects. The fundamental mission of a
voice assistant is to reduce using enter gadgets like keyboard, mouse, touch
pens, and so forth. This will lessen both the hardware fee and space taken by it.
Keywords: Voice Assistant, Python, Machine Learning, Text-Speech-Text,
Voice Detection and Artificial Intelligence

INTRODUCTION
--------------------------------------------------------------------------------------------------------------------------

6
--------------------------------------------------------------------------------------------------------------------------------------
-
The developments of artificial intelligence (AI) systems which can make virtual
human are gaining popularity. Human does not learns to talk with a device, but
it’s the machine that learns to speak with a humans.

Virtual assistants are software program that help you to easily do your
day to day works like displaying climate reviews, on off devices and so on.
They take input as command through text or through voice. Voice based
assistants need a wake phrase to start, followed by the command. There are
many voice assistance like Apple’s Siri, Amazon’s Alexa and Microsoft’s
Cortana. Such as stream movie on YouTube, Search on Wikipedia and
Google, Open websites on web browser, Open applications, Perform windows
OS task like Sending and checking mails the voice assistant we've got advanced
is a computer-primarily based built using python modules and libraries.

This assistant is just a simple model that might carry out all the simple
responsibilities which have been mentioned above however cutting-edge
generation is even though right in its miles nevertheless to be merged with
Machine Learning and Internet Of Things (IoT) for better improvements. And
we also upload GUI to this mission for makes it extra exciting and additionally
for person friendly.

Personal assistants software program improves person productiveness by


means of dealing with routine obligations of the consumer and by using
providing records from an internet supply to the consumer. So with a virtual
assistant, we are able to be capable of manage many stuff in our desktop/laptop
around us with simplest one platform

LITERATURE SURVEY
--------------------------------------------------------------------------------------------------------------------------

7
--------------------------------------------------------------------------------------------------------------------------------------
-
This area of digital assistants having speech reputation has visible some primary
advancements or inventions. This is especially due to its call for in gadgets like
smart watches or health bands, speakers, Bluetooth earphones, cellular
telephones, computer or desktop, TV, and so forth. Almost all the digital
gadgets which are coming nowadays with voice assistants, which assist to
control the device with speech recognition. A new set of strategies is being
evolved constantly to improve the performance of voice computerized seek.

With using voice assistants, we are able to automate the project


without difficulty, simply give the center to the machine within the speech
shape and all the duties might be accomplished by means of it from changing
your speech into textual content shape to putting off keywords from that text
and execute the question to provide outcomes to the person. This has been one
of the most beneficial improvements in era.Before AI we have been the ones
who have been upgrading technology to do a assignment however now the
gadget is itself able to counter new responsibilities and clear up it without need
to involve the people to conform it.

API
Voice input Speech Recognition Call
Module

Content
Extraction

Text to speech PYTHON system


Module BACKEND call
Python Import Libraries are:-

8
--------------------------------------------------------------------------------------------------------------------------------------
-
import speech_recognition as sr
import os
import sys
import re
import webbrowser
import smtplib
import request

fig.Module imported…..

Installation of Packages/framework using pip command in


cmd.

9
--------------------------------------------------------------------------------------------------------------------------------------
-

The voice module used this system is Google’s API i.e. “import
speech_recognition as sr”. This module is used to recognize the sound waves
given by the user as input. This is a loose API this is supplied and supported by
Google. This is a totally mild API that facilitates in decreasing the scale of our
application.

TTS & STT:

The input voice is first converted to text by using speech recognition module.
The text is then processed to result of the voice by the user. The most time
ingesting a number of the STT because the gadget first has to concentrate to the
user and unique users have distinctive, a few are smooth to apprehend whilst a
few are not without difficulty audible. Once the speech is converted to text
executing commands and giving the consequences lower back to the user isn't
always a time-eating.

PYTTSX3:

10
--------------------------------------------------------------------------------------------------------------------------------------
-
To convert text into speech in python the pyttsx3 module is used. This is an
offline module. The module provides run and wait functionality. It is used to
allow how much time the system will wait for another input of user. This is a
module available in the python community for free that can be installed using
the pip command.

DATETIME:

The Date-Time module is imported to support the date and time. For example,
the consumer wants to recognize the modern- day date and time or the person
desires to time table a venture at a sure time. In brief this module helps
instructions to manipulate date and time and carry out operations according to it
handiest. This is a critical module, mainly in tasks in which we need to keep a
track of time. This module could be very small in length and allows controlling
the dimensions of our program. If the modules are too large or heavy then the
system will lag and provide gradual responses.

WEBBROWSER:

Web-browser module is imported to display information from web to users. If


the user wants to open browser and gives input as “Open Google”. Then input is
processed using this module and the Google browser is opened. The browser
which is set in code will open.

WIKIPEDIA:

Wikipedia is an online library in python which it possible for the virtual


assistant to process the queries on Wikipedia and display it to the users. This
library needs an internet connection. The number of lines that the user wants to
get as a result can be set manually.

11
--------------------------------------------------------------------------------------------------------------------------------------
-
OS MODULE:

OS Module provides operating system dependent functionalities. If we want to


perform operations of OS like data reading, data writing, or data manipulate
paths then this types of functions are available in an OS module. When the these
operations raise an error like “OSError” in case of any error like invalid names,
paths, or arguments which may be incorrect or correct but just not accepted by
the operating system.

SMTPLIB:

SMTPLIB is python’s standard library which deals with emails. The SMTPLIB
library sends mail using “SMTP”. This is done using steps that are - initialize,
sendmail(), quit. When the optional parameters host and port are provided then
connect method is called with these arguments during initialization.

DESIGN:

The design consists of the following: Taking voice as a input from user.
Conversion of the speech into text by the system The converted text is then
processed to get the desired output.

12
--------------------------------------------------------------------------------------------------------------------------------------
-
PROPOSED SYSTEM
--------------------------------------------------------------------------------------------------------------------------

This may be whatever like getting movies, opening internal files, and so
on. Tests are made via code with the help of books and on line sources, with the
aim to find best results and a more expertise of Voice Assistant. The system has
the functionality like:- The device will hold listening for commands and the
time for listening is variable which may be modified consistent with consumer
necessities. If the system isn't capable of gather facts from the consumer input it
will keep asking again to copy until the desired no. of times. Features supported
in the current version include playing song, emails, texts, Wikipedia, OS tasks,
or establishing system mounted packages, starting something on the net
browser, etc.

The machine will hold listening for commands and the time for listening
is variable which can be modified in step with person necessities.

EXPERIMENT ANALYSIS
13
--------------------------------------------------------------------------------------------------------------------------------------
-
--------------------------------------------------------------------------------------------------------------------------

System configuration
This project can run on commodity hardware. We ran the entire project
on an Intel 8th generation I5 processor with 8 GB Ram, 2GB Graphics Card.
First part is the training phase which takes 20-25 mins of time and the second
part is the testing part which only takes a few seconds to make predictions

Hardware Requirements

• RAM: 4 GB
• Storage: 500 GB
• CPU: 2 GHz or faster
• Architecture: 32-bit or 64-bit

Software requirements
• Python 3.5 in Google Colab is used for data pre-processing, model training
and prediction.
• Operating System: Windows 7 and above or Linux based OS or MAC OS.

FUTURE SCOPE

14
--------------------------------------------------------------------------------------------------------------------------------------
-
--------------------------------------------------------------------------------------------------------------------------

The virtual assistants who might be presently available are speedy and
responsive however we nevertheless must go an extended manner. The
assistants available these days are still no longer reliable in critical eventualities.
The destiny of these assistants may have the virtual assistants integrated with
Artificial Intelligence which incorporates Machine Learning, Neural
Networks and IoT. With this technology, we are able to gain new heights.
What the digital assistants can attain is lots past what we have done till now.
Most of us have seen Jarvis, that is a digital assistant evolved through iron guy
which is even though fictional but this has set new requirements of what we will
achieve using voice-activated digital assistants.

Application
15
--------------------------------------------------------------------------------------------------------------------------------------
-
--------------------------------------------------------------------------------------------------------------------------

Program:-
import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import smtplib
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
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!")

16
--------------------------------------------------------------------------------------------------------------------------------------
-
speak("I am Jarvis Sir. Please tell me how may I help you")

def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("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)
print("Say that again please...")
return "None"
return query
def sendEmail(to, content):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login('[email protected]', 'your-password')
server.sendmail('[email protected]', to, content)
server.close()
if __name__ == "__main__":

17
--------------------------------------------------------------------------------------------------------------------------------------
-
wishMe()
while True:
query = takeCommand().lower()
if 'wikipedia' in query:
speak('Searching Wikipedia...')
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("According to Wikipedia")
print(results)
speak(results)

elif 'open youtube' in query:


webbrowser.open("youtube.com")

elif 'open google' in query:


webbrowser.open("google.com")

elif 'open stackoverflow' in query:


webbrowser.open("stackoverflow.com")
elif 'play music' in query:
music_dir = 'D:\\Non Critical\\songs\\Favorite Songs2'
songs = os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir, songs[0]))

elif 'the time' in query:

18
--------------------------------------------------------------------------------------------------------------------------------------
-
strTime = datetime.datetime.now().strftime("%H:%M:%S")
speak(f"Sir, the time is {strTime}")
elif 'open code' in query:
codePath = "C:\\Users\\Haris\\AppData\\Local\\Programs\\
Microsoft VS Code\\Code.exe"
os.startfile(codePath)
elif 'email to harry' in query:
try:
speak("What should I say?")
content = takeCommand()
to = "[email protected]"
sendEmail(to, content)
speak("Email has been sent!")
except Exception as e:
print(e)
speak("Sorry my friend harry bhai. I am not able to send this email")

RESULT
Output:-

19
--------------------------------------------------------------------------------------------------------------------------------------
-

20
--------------------------------------------------------------------------------------------------------------------------------------
-

21
--------------------------------------------------------------------------------------------------------------------------------------
-
CONCLUSION
--------------------------------------------------------------------------------------------------------------------------

In this “Personal Desktop Virtual Voice Assistant using Python” we discussed


about the design and implementation of Virtual Voice Assistance. This modules
uses open source software IDLE. The nature of this assignment makes it
flexible and easy to add additional features without present day machine
functionalities. It is not hand work on human commands however additionally it
give responses to the user based on the question being requested or the words
spoken by way of the user consisting of establishing duties and operations. It is
greeting the way the person feels greater comfortable and to interact with the
voice assistant. The utility need to also dispose of any kind of useless manual
paintings required inside the consumer existence of acting each challenge. The
complete machine works at the verbal enter as opposed to the subsequent one.

22
--------------------------------------------------------------------------------------------------------------------------------------
-
REFERENCES
--------------------------------------------------------------------------------------------------------------------------

[1]. R. Belvin, R. Burns, and C. Hein, “Development of the HRL route


navigation dialogue system,” in Proceedings of ACL-HLT, 2001

[2]. T.J.Hazen,and L.Hetherington, “JUPITER: A Telephone Based


Conversational Interface for Weather Information,” IEEE Transactions on
Speech and Audio Processing, vol. 8, no. 1, pp. 85–96, 2000.

[3]. M. Kolss, D. Bernreuther, M. Paulik,

[4]. Open Domain Speech Recognition & Translation: Lectures and Speeches,”
in Proceedings of ICASSP, 2006.

[5]. D. R. S. Caon, T. Simonnet, P. Sendorek, J. Boudy, and G. Chollet,


“vAssist: The Virtual Interactive Assistant for Daily Homer-Care,” in
Proceedings of pHealth, 2011.

[6]. Crevier, D. (1993). AI: The Tumultuous Search for Artificial Intelligence.
New York, NY: Basic Books, ISBN 0- 465-02997-3.

[7]. Sadun, E., &Sande, S. (2014). Talking to Siri: Mastering the Language of
Apple’s Intelligent Assistant.

[8]. Webopedia, web page Available:


https://www.webopedia.com/TERM/I/intelligent-personal-assistant.html

[9]. Statista, web page Available:


https://www.statista.com/statistics/973815/worldwide-digital-voice assistant-in-
use/

23
--------------------------------------------------------------------------------------------------------------------------------------
-
[10]. Smart sheet web page[Online]. https://www.smartsheet.com/voice-
assistants-artificial-intelligence

[11]. Aditya Sinha, Gargi Garg, GouravRajwani, Shimona Tayal, “Intelligent


Personal Assistant”. International Journal of Informative & Futuristic Research,
Volune. 4, Issue 8, April 2017.

[12]. Emad S. Othman .”Voice Controlled Personal Assistant Using Raspberry


Pi”. International Journal of Scientific and Engineering Research Volume 8,
Issue 11, November-2017. Bibek Behera, “Chappie - A Semi-automatic
Intelligent

[13]. http://en.wikipedia.org/wiki/WebServiceDescriptionLanguage.

[14]. http://yudian.voicecloud.cn [15]. http://en.wikipedia.org/wiki/Sir

24

You might also like