You are on page 1of 20

Report On

Text to morse code converter

Submitted in partial fulfillment of the requirements of the Course project in


Semester IV of Second Year Computer Engineering

by
Amruta Poojary (Roll No. 41)
Sakshi Ghonge (Roll No. 15)
Divyen Gharat (Roll No. 13)

Mentor
Prof. Snehal Mhatre

University of Mumbai

Vidyavardhini's College of Engineering & Technology

Department of Computer Engineering

(A.Y. 2021-22)
Vidyavardhini's College of Engineering & Technology

Department of Computer Engineering

CERTIFICATE

This is to certify that the Mini Project entitled “ Text to Morse Code

Converter ” is a bonafide work of Amruta Poojary (41) , Sakshi

Ghonge (15) , Divyen Gharat (13) submitted to the University of

Mumbai in partial fulfillment of the requirement for the award of the

degree of “Bachelor of Engineering” in Semester IV of Second Year

“Computer Engineering” .

______________________
Prof. Snehal Mhatre
Mentor

________________ _______________
Dr Megha Trivedi Dr. H.V. Vankudre
Head of Department Principal
Vidyavardhini's College of Engineering & Technology

Department of Computer Engineering

Course Project Approval

This Mini Project entitled “ Text to Morse Code Converter” by Amruta

Poojary (41) , Sakshi Ghonge (15) , Divyen Gharat (13) is approved

for the degree of Bachelor of Engineering in in Semester IV of Second

Year Computer Engineering .

Examiners

1………………………………………
(Internal Examiner Name & Sign)

2…………………………………………
(External Examiner name & Sign)

Date:

Place:
Contents

Abstract ii

Acknowledgments iii

1 Introduction 1
1.1 Introduction
1.2 Problem Statement & Objectives
1.3 Scope
1.4 Course Project Contribution

2 Proposed System

2.1 Introduction
2.2 Architecture/ Framework/Block diagram
2.3 Algorithm and Process Design
2.4 Details of Hardware & Software
2.5 Experiment and Results for Validation and Verification
2.6 Conclusion and Future work.
2.7 References
Abstract

Morse code is a process of transmitting text information as a series of on-off tones and lights
or clicks. if they use a tapping device recipient can understand the message without additional
decoding equipment. Morse code is represented by the form of dots and dashes. Morse code
used to transmit only numerals at first. After that, Alfred Vail included letters and characters.
Morse code can be transmitted by using electric telegraph wire, light, and sound, through a
different medium in different ways. It is the base for the morse code to transmit or receive.
Morse code is a character encoding and decoding scheme.
Acknowledgement
It gives immense pleasure in bringing out this synopsis of the project entitled “Text to morse
code converter project”. In performing our project, we had to take the help and guideline of
some respected persons, who deserve our greatest gratitude. The completion of this project
gives us much Pleasure. We would like to show our gratitude to our mentor Mrs. Neha Raut
involved in this project and for giving us a good guideline for numerous consultations. We
would also like to expand our deepest gratitude to all those who have directly and indirectly
guided us throughout this journey. Many people, especially our classmates and team members
themselves, have made valuable comment suggestions on this proposal which gave us the
inspiration to improve our project. We thank all the people for their help directly and indirectly
to complete our project
Introduction

Problem Statement & Objectives


SO, in this project we will be creating a simple but highly effective application which helps
to encode and decode secret morse code messages without the need for any tapping device.
This will be a very to use GUI application made in python which can be used to encode
morse code or decode text messages and the user can also listen to the morse by clicking
play sound button

Scope
The scope of this project is to provide an easy-to-use interface for encoding and decoding
secret messages or information. Our application can be used by detectives, long
communication purpose, military, external affairs etc.
Proposed system

Architecture/ Framework/Block diagram


Algorithm and Process Design

Python provides a data structure called dictionary which stores information


in the form of key-value pairs which is very convenient for implementing
a cipher such as a Morse code.
We can save the morse code chart in a dictionary where
(key -value pairs) => (English character – morse code).

english_to_morse = {'a': '.-', 'b': '-...', 'c': '-.-.', 'd': '-..',


'e': '.', 'f': '..-.', 'g': '--.', 'h': '....',
'i': '..', 'j': '.---', 'k': '-.-', 'l': '.-..',
'm': '--', 'n': '-.', 'o': '---', 'p': '.--.',
'q': '--.-', 'r': '.-.', 's': '...', 't': '-',
'u': '..--', 'v': '...-', 'w': '.--', 'x': '-..-',
'y': '-.--', 'z': '--..', '1': '.----',
'2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.',
'0': '-----', ' ':' ', '|':'|', "":"" }

The plaintext (English characters) takes the place of keys and the ciphertext
(Morse code) form the values of the corresponding keys.

The values of keys can be accessed from the dictionary in the same way
we access the values of an array through their index and vice versa.
Encryption (Convert text to morse code)
In the case of encryption, we extract each character from a word one at a time and match it
with its corresponding morse code stored in the dictionary
We then Store the morse code in a variable that will contain our encoded string and then we
add a space to our string that will contain the result.
While encoding in morse code we need to add 1 space between every character and 2
consecutive spaces between every word.
If the character is a space, then add another space to the variable containing the result. We
repeat this process till we traverse the whole string

Decryption
In the case of decryption, we start by adding a space at the end of the string to be decoded
Now we keep extracting characters from the string till we are not getting any space.
As soon as we get a space, we look up the corresponding English language character to the
extracted sequence of characters and add it to a variable that will store the result.
Remember keeping track of the space is the most important part of this decryption process.
As soon as we get 2 consecutive spaces, we will add another space to our variable containing
the decoded string.
The last space at the end of the string will help us identify the last sequence of morse code
characters (since space acts as a check for extracting characters and start decoding them).
Details of Hardware & Software

The minimum requirement to run the proposed system are listed below:

Hardware:
● 2.0 GHz Intel Processor
● 2 GIGS RAM
● HDD / SSD (preferable)

Software:
● Windows 8.1 or above
● python 3.5 or above
● python tkinter library
● python Pillow library
● python playsound library
● Visual Studio for software development and new patches
Experiment and Results for Validation and Verification

Code:-
import tkinter
from tkinter import IntVar , END, DISABLED, NORMAL
from playsound import playsound
from PIL import ImageTk, Image
root = tkinter.Tk()
root.title( 'Morse Code Translator' )
#root.iconbitmap('morse.ico')
root.geometry('600x450')
root.resizable(0,0)
button_font = ('SimSun',10)
root_color = "#778899"
frame_color = "#dcdcdc"
button_color = "#c0c0c0"
text_color = "#f8f8f8"
root.config(bg=root_color)
def convert():
if language.get() == 1:
get_morse()
elif language.get() == 2:
get_english()
def get_morse():
morse_code = ""
text = input_text.get("1.0", END)
text = text.lower()
for letter in text:
if letter not in english_to_morse.keys():
text = text.replace(letter, '')
word_list = text.split(" ")
for word in word_list:
letters = list(word)
morse_code
for letter in letters:
morse_char = english_to_morse[letter]
morse_code += morse_char
morse_code += " "
morse_code += "|"
output_text.insert("1.0", morse_code)
def get_english():
english = ""
text = input_text.get("1.0", END)
for letter in text:
if letter not in morse_to_english.keys():
text = text.replace(letter, '')
word_list = text.split("|")
for word in word_list:
letters = word.split(" ")
for letter in letters:
english_char = morse_to_english[letter]
english += english_char
english += " "
output_text.insert("1.0", english)
def clear():
input_text.delete("1.0", END)
output_text.delete("1.0", END)
def play():
if language.get() == 1:
text = output_text.get("1.0", END)
elif language.get() == 2:
text = input_text.get("1.0", END)
for value in text:
if value == ".":
playsound(r"C:\Users\Amruta\OneDrive\Documents\SEM 4\SBL\text to
morsecode sbl project\dot.mp3")
root.after(100)
elif value == "-":
playsound(r"C:\Users\Amruta\OneDrive\Documents\SEM 4\SBL\text to
morsecode sbl project\dash.mp3")
root.after(200)
elif value == " ":
root.after(300)
elif value == "|":
root.after(700)
def show_guide():
global morse
global guide
guide = tkinter.Toplevel()
guide.title("Morse Guide")
# guide.iconbitmap('morse.ico')
guide.geometry('350x350+'+ str(root.winfo_x()+500) + "+" + str(root.winfo_y()))
guide.config(bg=root_color)
morse = ImageTk.PhotoImage(Image.open("morse_chart.jpg"))
label = tkinter.Label(guide, image=morse)
label.pack(padx=10, pady=10, ipadx=5, ipady=5)
close_button = tkinter.Button(guide, text="Close", font=button_font, bg=button_color,
command=hide_guide)
close_button.pack(padx=10, ipadx=50)
guide_button.config(state=DISABLED)
def hide_guide():
guide_button.config(state=NORMAL)
guide.destroy()
english_to_morse = {'a': '.-', 'b': '-...', 'c': '-.-.', 'd': '-..',
'e': '.', 'f': '..-.', 'g': '--.', 'h': '....',
'i': '..', 'j': '.---', 'k': '-.-', 'l': '.-..',
'm': '--', 'n': '-.', 'o': '---', 'p': '.--.',
'q': '--.-', 'r': '.-.', 's': '...', 't': '-',
'u': '..--', 'v': '...-', 'w': '.--', 'x': '-..-',
'y': '-.--', 'z': '--..', '1': '.----',
'2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.',
'0': '-----', ' ':' ', '|':'|', "":"" }
morse_to_english = dict([(value, key) for key, value in english_to_morse.items()])
input_frame = tkinter.LabelFrame(root, bg=frame_color)
output_frame = tkinter.LabelFrame(root, bg=frame_color)
input_frame.pack(padx=16, pady=(16,8))
output_frame.pack(padx=16, pady=(16,8))
input_text = tkinter.Text(input_frame, height=8, width=30, bg=text_color)
input_text.grid(row=0, column=1, rowspan=3, padx=5, pady=5)
language = IntVar()
language.set(1)
morse_button = tkinter.Radiobutton(input_frame, text="English --> Morse
Code",variable=language, value=1, font=button_font, bg=frame_color)
english_button = tkinter.Radiobutton(input_frame, text="Morse Code -->
English",variable=language, value=2, font=button_font, bg=frame_color)
guide_button = tkinter.Button(input_frame, text="Guide", font=button_font,
bg=button_color)
morse_button.grid(row=0, column=0, pady=(15,0))
english_button.grid(row=1, column=0)
guide_button.grid(row=2, column=0, sticky="WE",padx=10)
output_text = tkinter.Text(output_frame, height=8, width=30, bg=text_color)
output_text.grid(row=0,column=1,rowspan=4,padx=5,pady=5)
convert_button = tkinter.Button(output_frame, text="Convert",font=button_font,
bg=button_color, command=convert)
play_button = tkinter.Button(output_frame, text="Play Morse",font=button_font,
bg=button_color, command=play)
clear_button = tkinter.Button(output_frame, text="Clear",font=button_font,
bg=button_color, command=clear)
quit_button = tkinter.Button(output_frame, text="Quit",font=button_font,
bg=button_color, command=root.destroy)
guide_button = tkinter.Button(output_frame, text="guide",font=button_font,
bg=button_color, command=show_guide)
convert_button.grid(row=0, column=0, padx=50) #convert ipadx defines column width
play_button.grid(row=1, column=0, padx=10, sticky="WE")
clear_button.grid(row=2, column=0, padx=10, sticky="WE")
quit_button.grid(row=3, column=0, padx=10, sticky="WE")
root.mainloop()

Output :-

Result after running the code


Converting text to morse code

Converting morse code to text


Conclusion and Future work.
The successful completion of the project has given intermediate knowledge in python,
python GUI and working with python packages. Our project can be used in various areas
like military, long communication etc., without the need of any tapping device.
References
1. https://docs.python.org/3/tutorial/index.html
2. https://tkdocs.com/tutorial/index.html
3. https://docs.python.org/3/library/sqlite3.html
4. https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g
5. https://stackoverflow.com/
Plagiarism check

You might also like