Summer Training Report

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

Summer training report

On
Voice-Command Calculator

Submitted in partial fulfilment of the requirement of


Bachelors of Computer Applications (BCA)

Guru Gobind Singh Indraprastha University, Delhi

Session 2019-20

Under the guidance of Submitted By


Dr Ruchi agarwal Faraz khan
(HOD of BCA dept.) 01025502019
Mrs Kalpana jha BCA (5th SEM.)
DECLARATION

I hereby declare that this Summer Training Report titled Voice command calculator_
submitted by me to JEMTEC, Greater Noida is a bonafide work undertaken during the period
from _15th july_to_1st September__by me and has not been submitted to any other University or
Institution for the award of any degree diploma / certificate or published any time before.

(Signature of the Student) Date: 08/11 / 2021

Name: Faraz Khan

Enroll. No.: 01025502019


BONAFIDE CERTIFICATE

This is to certify that as per best of my belief the project entitled “(Voice command calculator)”
is the bonafide research work carried out by FARAZ KHAN Student of BCA, JEMTEC, Greater
Noida, in partial fulfillment of the requirements for the Summer Training Report for the Degree
of Bachelor of Business Administration.

He has worked under my guidance.


I wish him a success in all his future career endeavors

Faculty Guide
Name: Ms.Apoorva Jain
Designation: Assistant Professor ___________________

Faculty Guide
Name: Dr.Ruchi Agarwal
Designation: HOD BCA Department ___________________
ACKNOWLEDGEMENT

I offer my sincere thanks and humble regards to JEMTEC, Greater Noida for imparting us very
valuable professional training in BCA.

I pay my gratitude and sincere regards to Dr.Ruchi agarwal my project Guide for giving me the
cream of her knowledge. I am thankful to him/her as he/she has been a constant source of advice,
motivation and inspiration. I am also thankful to him/her for giving his suggestions and
encouragement throughout the project work.

I take the opportunity to express my gratitude and thanks to our computer Lab staff and library
staff for providing me opportunity to utilize their resources for the completion of the project.

I am also thankful to my family and friends for constantly motivating me to complete the project
and providing me an environment, which enhanced my knowledge.

Date: 08 /11 / 2021


Name: FARAZ KHAN
Enroll. No.: 01025502019

Course: BCA (V-Sem)

(Signature of the Student)


TOPIC Serial number

.Abstract 1

Company Profile 2

Project description 3

Objective 4

Software Requirements Specification 5

H/w and S/w requirements 6

Software design specification 7

Source code 8

Output snapshot 9

Conclusion 10

References 11
Abstract

This report reviews the use of graphical user interface via tkinter and speech recognition
application via pyaudio and pygame in python. As we know that in today’s technology , keeping
up with basic knowledge is necessary and most students don’t know about the GUI(Graphical
User Interface) and the applications of speech recognition in python and its usages in
implementing many softwares such as games ,browsers , mobile apps and many visually
appealing applications with a visual interface. A graphical user interface is an application that
has buttons, windows, and lots of other widgets that the user can use to interact with your
application.

A programmer can easily take in hand his operation by the help of speech recognition application
of pyaudio and pygame in which he will control the any other application by just giving orders
via speaking; all the operations will be carried out by itself

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the
GUI methods, tkinter is the most commonly used method. It is a standard Python interface to
the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to
create the GUI applications. Creating a GUI using tkinter is an easy task.

Having a good GUI and speech recognition applied to the software increases your reputation
and makes software more visually appealing and user friendly.

The project involves the use of Tkinter which is a graphical user interface of python by
implementing it in the form of a GUI calculator. As you will see later that there is a huge
difference between a simple calculator program and the calculator implemented by using
graphical user interface.

PyAudio helps in applying the speech recognition in the program by providing certain inbuilt
keywords and functions. PyAudio provides Python bindings for PortAudio, the cross-platform
audio I/O library. With PyAudio, you can easily use Python to play and record audio

Using pyaudio you can

 Play MP3 and WAV files, as well as a range of other audio formats
 Play NumPy and Python arrays containing sound
 Record sound using Python
 Save your recordings or audio files in a range of different file formats
Company profile

Udemy.inc is an American massive open online course (MOOC) provider aimed at professional
adults and students who want to learn something while sitting at their home by online method.

Udemy was founded in May 2010 by eren Ball, Gagan biyani and oktay caglar. As of June of
2021, the platform has more than 44 million students 83000 courses and 65000 instructors
teaching courses in 75 languages. Udemy is a platform that allows instructors to build online
courses on their preferred topics. Using Udemy's course development tools, they can upload
videos, PowerPoint presentations, PDFs, audio, ZIP files and live classes to create courses.
Instructors can also engage and interact with users via online discussion boards.Courses are
offered across a breadth of categories, including business and entrepreneurship academics, the
arts, health and fitness, language, music, and technology.

Most classes are in practical subjects such as Excel software or using an iPhone camera. Udemy
also offers Udemy for Business, enabling businesses access to a targeted suite of over 7,000
training courses on topics from digital marketing tactics to office
productivity, design, management, programming, and more. With Udemy for Business,
organizations can also create custom learning portals for corporate training. Courses on Udemy
can be paid or free, depending on the instructor.

Project description

This project is about Tkinter’s and PyAudio implementation as a GUI (Graphical User Interface)
and speech recognition application which can easily record your audio and use google to
translate your audio into string.In this smart calculator you can either type your desired numbers
via the buttons provided by GUI or just provide the command to the calculator by clicking on the
microphone button which we have implemented via pygame in which a sound is played of the
clicking of microphone just like it plays in google after we click the microphone icon and the
operation will be carried out by itself.

Process

Step-1- First of all you have to click on the microphone button , a sound will be played ,then you
have to speak your desired numbers which you want to calculate with the specific operation
which you want to be carried by the calculator

Step-2- For e.g. – if you say “perform addition of 3 and 4” then that audio will be recorded by
the help of some functions and keywords provided by PyAudio and will be translated by google
into string
Step-3- String will be then filtered out as per the condition provided in the program in which we
have provided a list which will filter out the words such as addition or multiplication and the
numbers such as 3 and 4 will be filtered out and fed to the calculator,

Step-4-When the words and numbers are being filtered out, then they are in string at that time so
for operation to be carried out by the calculator they must be converted to integer, that’s why a
separate keyword is provided to convert that string into integer

Step-5-After being converted into integer the operation is ready to perform and just like that the
operation is carried out and result is displayed on the screen by a sound which tells us that the
operation is carried out successfully.

NOTE: Beware to speak carefully or the audio will not be recorded clearly which will result in
an error or a wrong output.

This whole project is made using the applications of speech recognition and graphical user
interface via PyAudio and Tkinter .

PyAudio helps in applying the speech recognition in the program by providing certain inbuilt
keywords and functions. PyAudio provides Python bindings for PortAudio, the cross-platform
audio I/O library. With PyAudio, you can easily use Python to play and record audio

Using pyaudio you can

 Play MP3 and WAV files, as well as a range of other audio formats
 Play NumPy and Python arrays containing sound
 Record sound using Python
 Save your recordings or audio files in a range of different file formats

For using PyAudio:

 Install PyAudio using pip command pip install pyaudio


 Import PyAudio.

Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a
fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented
interface to the Tk GUI toolkit.

Creating a GUI application using Tkinter is an easy task. All you need to do is perform the
following steps −
 Import the Tkinter module.
 Create the GUI application main window.
 Add one or more of the above-mentioned widgets to the GUI application.
 Enter the main event loop to take action against each event triggered by the user.

Objective

The objective of this project is to provide the implementation of speech recognition and
Graphical user interface. By this project you will get to know how easy it is control your
application by just sitting on your chair and providing your desired commands and the result will
be displayed automatically by itself. And using GUI will make your software look even more
attractive and there are buttons provided by the GUI which make your work easy.

Software Requirement Specification

The software design specification can produce at the culmination of the analysis task. The
function and performance allocated to software as part of system engineering are refined by
established complete information description , a detailed functional description, a representation
of system behavior and indication of performance and design constrain, appropriate validate
criteria and other information pertinent to requirements.

Hardware and software requirements

 Python
(Any version, although python3+ versions would be better)

 Tkinter library of python


(Install it using pip command “pip install tk”)

 Speech recognition library of python


(Install it using pip command “pip install speechrecognition”)

 Pygame library of python


(Install it using pip command pip install pygame)

 PyAudio library of python


(Install it using pip command “pip install pyaudio”)
  Operating system:
Linux- Ubuntu 16.04 to 17.10 or Windows 7 to 10

 RAM
2 GB (4 GB preferable)

Software Design Specification

This software is made by the help of Tkinter which is a library of python with graphical
properties. For implementation of this project you have to import tkinter library of python first
after installing tkinter through pip command “pip install tk” , then write the code as per needed
by providing different buttons for your input and colors of your choice.

There are certain processes which are carried out by the software before printing the result :

process-1) Audio will be recorded by the help of inbuilt functions and keywords provided by
PyAudio and will be translated by google into string

process-2) String will be then filtered out as per the condition provided in the program in which
we have provided a list which will filter out the words such as addition or multiplication and the
numbers such as 3 and 4 will be filtered out and fed to the calculator,

process-3) When the words and numbers are being filtered out, then they are in string at that time
so for operation to be carried out by the calculator they must be converted to integer, that’s why
a separate keyword is provided to convert that string into integer

process-4) After being converted into integer the operation is ready to perform and just like that
the operation is carried out and result is displayed on the screen by a sound which tells us that the
operation is carried out successfully.

Source Code
from tkinter import *
import math
from pygame import mixer
import speech_recognition

mixer.init()

def click(value):
ex = entryField.get()
answer = ''
try:

if value == 'C':
ex = ex[0:len(ex) - 1] # 78
entryField.delete(0, END)
entryField.insert(0, ex)
return

elif value == 'CE':


entryField.delete(0, END)

elif value == '√':


answer = math.sqrt(eval(ex))

elif value == 'π':


answer = math.pi

elif value == 'cosθ':


answer = math.cos(math.radians(eval(ex)))

elif value == 'tanθ':


answer = math.tan(math.radians(eval(ex)))

elif value == 'sinθ':


answer = math.sin(math.radians(eval(ex)))

elif value == '2π':


answer = 2 * math.pi

elif value == 'cosh':


answer = math.cosh(eval(ex))

elif value == 'tanh':


answer = math.tanh(eval(ex))

elif value == 'sinh':


answer = math.sinh(eval(ex))

elif value == chr(8731):


answer = eval(ex) ** (1 / 3)

elif value == 'x\u02b8': # 7**2


entryField.insert(END, '**')
return

elif value == 'x\u00B3':


answer = eval(ex) ** 3

elif value == 'x\u00B2':


answer = eval(ex) ** 2

elif value == 'ln':


answer = math.log2(eval(ex))

elif value == 'deg':


answer = math.degrees(eval(ex))
elif value == "rad":
answer = math.radians(eval(ex))

elif value == 'e':


answer = math.e

elif value == 'log₁₀':


answer = math.log10(eval(ex))

elif value == 'x!':


answer = math.factorial(ex)

elif value == chr(247): # 7/2=3.5


entryField.insert(END, "/")
return

elif value == '=':


answer = eval(ex)

else:
entryField.insert(END, value)
return

entryField.delete(0, END)
entryField.insert(0, answer)

except SyntaxError:
pass

def add(a, b):


return a + b

def sub(a, b):


return a - b

def mul(a, b):


return a * b

def div(a, b):


return a / b

def mod(a, b):


return a % b

def lcm(a, b):


l = math.lcm(a, b)
return l

def hcf(a, b):


h = math.gcd(a, b)
return h

operations = {'ADD': add, 'ADDITION': add, 'SUM': add, 'PLUS': add,


'SUBTRACTION': sub, 'DIFFERENCE': sub, 'MINUS': sub, 'SUBTRACT':
sub,
'PRODUCT': mul, 'MULTIPLICATION': mul, 'MULTIPLY': mul,
'DIVISION': div, 'DIV': div, 'DIVIDE': div,
'LCM': lcm, 'HCF': hcf,
'MOD': mod, 'REMAINDER': mod, 'MODULUS': mod}

def findNumbers(t):
l = []
for num in t:
try:
l.append(int(num))
except ValueError:
pass
return l

def audio():
mixer.music.load('music1.mp3')
mixer.music.play()
sr = speech_recognition.Recognizer()
with speech_recognition.Microphone() as m:
try:
sr.adjust_for_ambient_noise(m, duration=0.2)
voice = sr.listen(m)
text = sr.recognize_google(voice)
mixer.music.load('music2.mp3')
mixer.music.play()
text_list = text.split(' ')
for word in text_list:
if word.upper() in operations.keys():
l = findNumbers(text_list)
print(l)
result = operations[word.upper()](l[0], l[1]) #
mul(5.0,6.0)
entryField.delete(0, END)
entryField.insert(END, result)

else:
pass

except:
pass

root = Tk()
root.title('Smart Calculator')
root.config(bg='dodgerblue3')
root.geometry('680x486+100+100')
logoImage = PhotoImage(file='logo.png')
logoLabel = Label(root, image=logoImage, bg='dodgerblue3')
logoLabel.grid(row=0, column=0)

entryField = Entry(root, font=('arial', 20, 'bold'), bg='dodgerblue3',


fg='white', bd=10, relief=SUNKEN, width=30)
entryField.grid(row=0, column=0, columnspan=8)

micImage = PhotoImage(file='microphone.png')
micButton = Button(root, image=micImage, bd=0, bg='dodgerblue3',
activebackground='dodgerblue3'
, command=audio)
micButton.grid(row=0, column=7)

button_text_list = ["C", "CE", "√", "+", "π", "cosθ", "tanθ", "sinθ",


"1", "2", "3", "-", "2π", "cosh", "tanh", "sinh",
"4", "5", "6", "*", chr(8731), "x\u02b8", "x\u00B3",
"x\u00B2",
"7", "8", "9", chr(247), "ln", "deg", "rad", "e",
"0", ".", "%", "=", "log₁₀", "(", ")", "x!"]
rowvalue = 1
columnvalue = 0
for i in button_text_list:

button = Button(root, width=5, height=2, bd=2, relief=SUNKEN, text=i,


bg='dodgerblue3', fg='white',
font=('arial', 18, 'bold'),
activebackground='dodgerblue3', command=lambda button=i: click(button))
button.grid(row=rowvalue, column=columnvalue, pady=1)
columnvalue += 1
if columnvalue > 7:
rowvalue += 1
columnvalue = 0

root.mainloop()
Output Snapshots

Fig 9.1- performing subtraction fig 9.1.1- Result

fig 9.2- performing division


fig 9.2.1- Result
Fig 9.3- Performing Multiplication fig 9.3.1- Result

Fig 9.4- Performing addition fig 9.4.1- Result


Conclusion

As you can see this calculator is obviously a better alternative compared to the calculator without
GUI based on the looks and voice command based on the simplicity alone.

At the end this project is showing how a GUI and voice command being is implemented and why
these are a better approach in the field of development. GUI doesn’t only improve the looks and
charm of your code but also makes your code more user friendly by providing user interfaces for
them; users can easily press this virtual button via mouse instead of typing the numbers again via
keyboard .A programmer can easily take in hand his operations by giving out commands and
doing everything without touching the keyboard in this calculator.

References

 Python 3.10.0 documentation (2021), https://docs.python.org/3/ (accessed on 11th


October 2021)

 GUI calculator(2021),https://www.geeksforgeeks.org/python-simple-gui-calculator-
using-tkinter/ (accessed on 20th October 2021)

 Tkinter documentation (2021), https://docs.python.org/3/library/tk.html (accessed on 11th


October 2021

 GUI programming,https://www.tutorialspoint.com/python/python_gui_programming.htm
(accessed on 24th October 2021)

You might also like