0% found this document useful (0 votes)
8 views17 pages

CS Proj

The document details a computer science project titled 'Multi-Language Translator' submitted by Anas Arfeen from Matrix Academy Senior Secondary School. The project, developed using Python, facilitates text translation between multiple languages and includes a text-to-speech feature. It outlines the project's introduction, hardware and software requirements, code implementation, and bibliography for further reference.
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)
8 views17 pages

CS Proj

The document details a computer science project titled 'Multi-Language Translator' submitted by Anas Arfeen from Matrix Academy Senior Secondary School. The project, developed using Python, facilitates text translation between multiple languages and includes a text-to-speech feature. It outlines the project's introduction, hardware and software requirements, code implementation, and bibliography for further reference.
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/ 17

MATRIX ACADEMY SENIOR

SECONDARY SCHOOL, CBSE

BOLINJ, VIRAR(W)

COMPUTER SCIENCE PROJECT


ON
“MULTI-LANGUAGE TRANSLATOR”
SUBMITTED BY ANAS ARFEEN
XII AMPERE
ROLL NO: 10
COMPUTER SCIENCE PROJECT
PROJECT TOPIC:

“MULTI-LANGUAGE TRANSLATOR”

SUBMITTED BY:
ANAS ARFEEN
XII AMPERE
ROLL NO: 10

UNDER THE GUIDANCE OF:


Mrs. Bristel Rodrigues
MATRIX ACADEMY SCHOOL , CBSE
NEAR GULMOHAR HERITAGE
KHARODI NAKA, VIRAR (W)

CERTIFICATE
This is to certify that Anas Arfeen, student of Class XII-
Ampere has completed his major project titled:
“MULTI-LANGUAGE TRANSLATOR”
And has submitted the project report for the fulfilment
of the curriculum followed at Matrix academy school,
CBSE, Virar.
ACKNOWLEDGEMENT
I would like to express my gratitude to Mrs. Bristel
Rodrigues Ma’am, for her stimulating guidance
continuous encouragement and supervision
throughout the project work.

I wish to extend my thanks to our headmistress Mrs.


Jayanthi Ravichandran Ma'am for her constant
support, motivation and kind words.

I would also like to be grateful to our principal Mrs.


Seema Behaal Ma'am for providing us with a well
acupressure library to complete our project.

I would like to thanks my friends for their


constructive suggestions that helped in the
improvement of the project.
INDEX
1. Introduction

2. Hardware and software

3. Code

4. Output

5. Bibliography
INTRODUCTION
This project on Multi-Language Translator is a
software developed using Python to facilitate the
translation of text between multiple languages. Users can
input text in one language and receive accurate
translations in their desired target language. In addition
to text translation, the software also includes a text-to-
speech feature, enabling users to hear the translated
text.

For developing this project, we have utilized the


following Python modules:
PyQt5, Deep translator, Google Text-to-Speech,
Playsound

By combining these modules, the project creates a


seamless translation tool that meets the needs of users
requiring both text and audio translations. With the rise
of multilingual communication, this project aims to
break language barriers, making communication easier
and more efficient across diverse languages and cultures.
HARDWARE AND SOFTWARE

1. Hardware Requirements:
a. Computer/Laptop with at least
i. Processor: Intel i3 or equivalent
ii. RAM: 4 GB or higher
iii. Storage: 100 MB of free disk space
b. Speakers or Headphones (for audio output)
c. Internet Connection (for accessing translation services)
d. Pen drive (For transferring files)

2. Software Requirements:
a. Operating System: Windows 10/11 / macOS / Linux
b. Python: (Programming language used for the project)
c. Modules and Libraries:
i. PyQt5: pip install PyQt5
[Used for creating an intuitive and visually appealing graphical
user interface (GUI).]
ii. Deep Translator: pip install deep_translator
[Provides access to various translation services, enabling
accurate and real-time translations.]
iii. gTTS (Google Text-to-Speech): pip install gTTS
[Used to convert translated text into speech, allowing users to
hear the translation.]
iv. playsound: pip install playsound==1.2.2
[Plays the audio output generated by gTTS.]
d. Python IDE/Editor: VS Code (any Python-supported IDE)
CODE
'''
REQUIRED MODULES AND LIBRARIES:
PyQt5 ------------> pip install PyQt5
deep_translator ------------> pip install deep_translator
gTTS ------------> pip install gTTS
playsound ------------> pip install playsound==1.2.2

MUST RUN THIS BEFORE EXECUTION:


pip install PyQt5
pip install deep-translator
pip install gTTS
pip install playsound==1.2.2
'''

import sys
from PyQt5.QtWidgets import (
QApplication,
QMainWindow,
QTextEdit,
QLabel,
QPushButton,
QVBoxLayout,
QHBoxLayout,
QWidget,
QComboBox)
from PyQt5 import QtGui
from PyQt5.QtGui import QTextOption, QFontDatabase, QFont
from PyQt5.QtCore import Qt
from deep_translator import GoogleTranslator
from gtts import gTTS
from playsound import playsound
import os

# FORMATTING OF THE APP


Background = '#D9EEF5'
colour1 = '#3fbbe5'
colour2 = '#009fe0'
fontcolour1 = 'Black'
Dropdowncolour1 = '#a0d5e7'
Titlefont = "Manolo Mono"
Dropdownfont = 'Roboto Medium'
Textboxfont = 'Roboto Medium'
Buttonfont = 'Roboto Medium'
Buttonstyle = f"""
QPushButton {{
background:{colour1};
color: white;
padding: 10px;
border-radius: 10px;
}}

QPushButton:hover {{
background:{colour2} ;
}}
"""
Dropdownstyle = f"""
QComboBox {{
background-color: {Dropdowncolour1};
border-radius: 10px;
padding: 5px;
color: #333;
}}

QComboBox::drop-down {{
border: none;
background-color: transparent;
width: 30px; /* Adjust width to fit your icon */
}}

QComboBox::down-arrow {{
background-image: url('Datas/dropdown_icon.png');
background-position: center;
background-repeat: no-repeat;
width: 20px; /* Adjust width to fit your icon */
height: 20px; /* Adjust height to fit your icon */
}}

QScrollBar:vertical {{
background: #F0F0F0;
width: 10px;
border: none;
}}

QScrollBar::handle:vertical {{
background: #3fbbe5;
min-height: 20px;
border:none;
}}

QScrollBar::add-line:vertical {{
background: transparent;
height: 0px;
border: none;
}}

QScrollBar::sub-line:vertical {{
background: transparent;
height: 0px;
border:none;
}}
"""

Textstyle = f"border: 0px; padding: 5px; background-color: white; color:


#333;border-radius:5px"

# ADDING SOME FONTS FOR EXCITEMENT


def load_fonts():
font_files = [
r'Datas\manolo-mono.ttf',
r'Datas\Mauline.otf',
r'Datas\Figtree-Black.ttf',
r'Datas\Roboto-Medium.ttf']

for font_file in font_files:


id = QFontDatabase.addApplicationFont(font_file)

# CREATING A FUNCTION TO CONVERT TRANSLATED TEXT TO SPEECH


def text_to_speech(text, target_lang):
tts = gTTS(text=text, lang=target_lang)
file_path = 'translation.mp3' # TEMPORARILY STORES THE
TRANSLATED MP3 FILE
if os.path.exists(file_path):
try:
os.remove(file_path)
except Exception as e:
print(f"An error occurred while deleting '{file_path}': {e}")
tts.save(file_path)
playsound(file_path)

# CLASS FOR CREATING AN APP


class TranslatorApp(QMainWindow):
def __init__(self):
super().__init__()
self.translated_text = "" # INITIALIZING TO AN EMPTY
STRING
self.languages1 = { # ALL REQUIRED LANGUAGES
'Afrikaans': 'af',
'Albanian': 'sq',
'Amharic': 'am',
'Arabic': 'ar',
'Armenian': 'hy',
'Assamese': 'as',
'Azerbaijani': 'az',
'Bambara': 'bm',
'Basque': 'eu',
'Belarusian': 'be',
'Bengali': 'bn',
'Bosnian': 'bs',
'Bulgarian': 'bg',
'Catalan': 'ca',
'Chinese (Simplified)': 'zh-CN',
'Chinese (Traditional)': 'zh-TW',
'Croatian': 'hr',
'Czech': 'cs',
'Danish': 'da',
'Dutch': 'nl',
'English': 'en',
'Esperanto': 'eo',
'Estonian': 'et',
'Filipino': 'tl',
'Finnish': 'fi',
'French': 'fr',
'German': 'de',
'Greek': 'el',
'Gujarati': 'gu',
'Haitian Creole': 'ht',
'Hebrew': 'he',
'Hindi': 'hi',
'Hungarian': 'hu',
'Icelandic': 'is',
'Indonesian': 'id',
'Italian': 'it',
'Japanese': 'ja',
'Korean': 'ko',
'Kurdish (Sorani)': 'ckb',
'Latin': 'la',
'Latvian': 'lv',
'Lithuanian': 'lt',
'Malay': 'ms',
'Malayalam': 'ml',
'Nepali': 'ne',
'Norwegian': 'no',
'Persian': 'fa',
'Polish': 'pl',
'Portuguese': 'pt',
'Punjabi': 'pa',
'Romanian': 'ro',
'Russian': 'ru',
'Serbian': 'sr',
'Slovak': 'sk',
'Slovenian': 'sl',
'Somali': 'so',
'Spanish': 'es',
'Swahili': 'sw',
'Swedish': 'sv',
'Turkish': 'tr',
'Urdu': 'ur',
'Vietnamese': 'vi',
'Welsh': 'cy',
'Yoruba': 'yo',
'Zulu': 'zu'
}

self.languages = list(self.languages1.keys())
self.languages.sort()

self.setWindowTitle("Translator with TTS")


self.setWindowIcon(QtGui.QIcon(r"Datas\icon.ico"))
self.setFixedSize(650, 500) # FIXED WINDOW SIZE
self.setStyleSheet("background-color: #F0F0F0;") # LIGHT GRAY
BACKGROUND
self.setup_gui()

def setup_gui(self):
load_fonts()
self.widget = QWidget()
self.widget.setStyleSheet(f"background-color:{Background}")
self.main_layout = QVBoxLayout()
self.welcome_label = QLabel("Welcome to the Translator!") # WELCOME
LABEL
self.welcome_label.setAlignment(Qt.AlignCenter)
self.welcome_label.setFont(QFont(Titlefont, 20))
self.welcome_label.setStyleSheet(f"color:{fontcolour1}")
self.main_layout.addWidget(self.welcome_label)

self.h_layout = QHBoxLayout() # Horizontal layout for dropdowns


self.main_layout.addLayout(self.h_layout)

self.input_language_dropdown = QComboBox() # Dropdown for input


language
self.input_language_dropdown.addItems(self.languages)

self.input_language_dropdown.setCurrentIndex(self.languages.index("English"))
self.input_language_dropdown.setFont(QFont(Dropdownfont, 15))
self.input_language_dropdown.setStyleSheet(Dropdownstyle)
self.h_layout.addWidget(self.input_language_dropdown)

self.output_language_dropdown = QComboBox() # Dropdown for output


language
self.output_language_dropdown.addItems(self.languages)

self.output_language_dropdown.setCurrentIndex(self.languages.index("Hindi"))
self.output_language_dropdown.setFont(QFont(Dropdownfont, 15))
self.output_language_dropdown.setStyleSheet(Dropdownstyle)
self.h_layout.addWidget(self.output_language_dropdown)

self.original_text = QTextEdit() # Text area for original input


self.original_text.setFont(QFont(Textboxfont, 14))
self.original_text.setStyleSheet(Textstyle)
self.original_text.setPlaceholderText("Write and translate!")
self.main_layout.addWidget(self.original_text)

self.button_layout = QHBoxLayout() # Horizontal layout for buttons


self.main_layout.addLayout(self.button_layout)

self.translate_button = QPushButton("Translate") # Button for


translation
self.translate_button.clicked.connect(self.translate_text)
self.translate_button.setFont(QFont(Buttonfont, 14))
self.translate_button.setStyleSheet(Buttonstyle)
self.button_layout.addWidget(self.translate_button)

self.text_to_speech_button = QPushButton("Text to Speech")


self.text_to_speech_button.clicked.connect(self.text_to_speech)
self.text_to_speech_button.setFont(QFont(Buttonfont, 14))
self.text_to_speech_button.setStyleSheet(Buttonstyle)
self.button_layout.addWidget(self.text_to_speech_button)

self.result_label = QTextEdit() # Label for displaying the


translated text
self.result_label.setFont(QFont(Textboxfont, 14))
self.result_label.setReadOnly(True)
self.result_label.setStyleSheet(Textstyle)
self.main_layout.addWidget(self.result_label)

self.status_label = QLabel("") # Label for displaying status updates


self.status_label.setFont(QFont(Textboxfont, 12))
self.status_label.setAlignment(Qt.AlignCenter)
self.status_label.setStyleSheet("color: black")
self.main_layout.addWidget(self.status_label)

self.widget.setLayout(self.main_layout)
self.setCentralWidget(self.widget)

def translate_text(self):
try:
original_text = self.original_text.toPlainText()
input_lang =
self.languages1[self.input_language_dropdown.currentText()]
output_lang =
self.languages1[self.output_language_dropdown.currentText()]
translated_text = GoogleTranslator(source=input_lang,
target=output_lang).translate(original_text)
self.translated_text = translated_text
self.result_label.setPlainText(translated_text)
except Exception as e:
self.status_label.setText(f"Translation failed: {e}")

def text_to_speech(self):
try:
if not self.translated_text:
self.status_label.setText("Nothing to read!")
return
output_lang =
self.languages1[self.output_language_dropdown.currentText()]
text_to_speech(self.translated_text, output_lang)
self.status_label.setText("Text-to-speech completed!")
except Exception as e:
self.status_label.setText(f"Text-to-speech failed: {e}")

if __name__ == "__main__":
app = QApplication(sys.argv)
translator_app = TranslatorApp()
translator_app.show()
sys.exit(app.exec_())
OUTPUT
BIBLIOGRAPHY
 https://docs.python.org/3/
Comprehensive resource for Python's standard library and language
features, offering official guides, tutorials, and reference materials.
 Fluent Python by Luciano Ramalho
An in-depth book on writing idiomatic Python code, covering advanced
topics and best practices for Python programming.
 https://www.geeksforgeeks.org/real-time-
translation-app-using-python/
A tutorial that explains how to create a real-time language translation app
using Python, providing practical examples and code snippets.
 https://medium.com/dataflair/python-language-
translator-project-79dcd6cf2f69
A project-based tutorial on building a Python language translator, focusing
on implementing translation features using various Python libraries.
 https://www.riverbankcomputing.com/static/
Docs/PyQt5/
The official documentation for PyQt5, detailing how to use the PyQt5 library
to create cross-platform desktop applications with Python.
 https://cloud.google.com/text-to-speech/docs
Documentation for Google Cloud's Text-to-Speech API, which provides
guidelines and examples for converting text into natural-sounding speech
using Google's AI models.
 https://github.com/
A platform for hosting and collaborating on open-source software projects,
offering access to a vast collection of code repositories and development
tools.
 https://stackoverflow.com/
A community-driven Q&A platform where developers can ask and answer
questions on a wide range of programming topics, including Python and
PyQt5.

You might also like