Skip to content

Commit

Permalink
feat: build steamlit ui
Browse files Browse the repository at this point in the history
  • Loading branch information
gunarakulangunaretnam committed Jan 19, 2024
1 parent d5bbbfa commit 8873a4d
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 62 deletions.
70 changes: 8 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Language Translation Bot

## Introduction
## 01 Introduction

A voice recognition based tool for translating languages in real time. This tool could be used to translate languages with voice data. For an example, it can listen and, translate that voice data into the target language then, it speaks out as a voice output, similar to a human translator, who listens and then translate in a targeted language.

This is not efficient like human translator, it is using the google translate platform as backbone to perform the translation process.

![Banner Image](docs/media/0-banner-image.png)

![diagram](github-readme-contents/system-architeture.png)

## Technologies & Frameworks
![diagram](docs/media/system-architeture.png)

## 02 Technology Stack

- Python 3.8
- GTTS Module
Expand All @@ -18,69 +20,13 @@
- Googletrans Module


### Why GTTS Module?

gTTS (Google Text-to-Speech)is a Python library and CLI tool to interface with Google Translate text-to-speech API. We will import the gTTS library from the gtts module which can be used for speech translation.

**Note:** This module helps to convert text as voice output.


### Why SpeechRecognition Module?

This module gives the ability to perform speech recognition, basically, it could be used to convert speech to text operations.

### Why Playsound Module?

playsound is a “pure Python, cross platform, single function module with no dependencies for playing sounds.” With this module, you can play a sound file with a single line of code:

``` python
from playsound import playsound
playsound('myfile.wav')
```

### Why Googletrans Module?

Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate.

This is core library of this project, which does the translations among languages.

## Configuration & Setup

- Install playsound

```
pip install playsound
```

- Install gTTS

```
pip install gTTS
```

- Install SpeechRecognition

```
pip install SpeechRecognition
```


- Install googletrans

```
pip install googletrans==3.1.0a0
```


## Execution & Running

**Note:** To run this program, navigate to the preferred folder, and execute the run.py script to start the program.
## 03 Setup

![diagram](github-readme-contents/folder.jpg)

## 04 Usage

```
python run.py
python main.py
```

Expand Down
Binary file added docs/media/0-banner-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
playsound
SpeechRecognition
googletrans
Binary file removed github-readme-contents/folder.jpg
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added soruce/cache_file.mp3
Binary file not shown.
29 changes: 29 additions & 0 deletions soruce/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import streamlit as st
from googletrans import LANGUAGES, Translator

def translate_text(text, source_language, target_language):
translator = Translator()
translated_text = translator.translate(text, src=source_language, dest=target_language).text
return translated_text

# UI layout
st.title("Language Translator")

# Dropdowns for selecting languages
from_language = st.selectbox("From", list(LANGUAGES.values()))
to_language = st.selectbox("To", list(LANGUAGES.values()))

# Button to trigger translation
if st.button("Start"):
st.text("Translation in progress...")

# Your translation logic here
text_to_translate = "Hello, world!" # Replace this with the actual text you want to translate
translated_result = translate_text(text_to_translate, from_language, to_language)

# Display the translated text
st.text(f"Translated text from {from_language} to {to_language}:")
st.text(translated_result)

# Display status
st.text("Status: Ready")

0 comments on commit 8873a4d

Please sign in to comment.