An open API service indexing awesome lists of open source software.

https://github.com/kritagya-web/nlp-speech_recognition_and_translation

A modern web application for translating and converting speech to text in various languages. Built with Next.js and Chakra UI for a responsive frontend, and FastAPI for the backend, which handles translation and text-to-speech services. Integrated using Docker for seamless deployment.
https://github.com/kritagya-web/nlp-speech_recognition_and_translation

Last synced: 7 months ago
JSON representation

A modern web application for translating and converting speech to text in various languages. Built with Next.js and Chakra UI for a responsive frontend, and FastAPI for the backend, which handles translation and text-to-speech services. Integrated using Docker for seamless deployment.

Awesome Lists containing this project

README

          

# NLP Speech Recognition and Translation Project [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**Welcome to the NLP Speech Recognition and Translation Project!** πŸŒπŸ”Š

In today's globalized world, effective communication across different languages is more important than ever. Our project addresses this need by providing a seamless and intuitive solution for real-time speech translation and text-to-speech conversion. Whether you're traveling, working with international teams, or learning a new language, our application is designed to make language barriers a thing of the past.

![Project Screenshot](assets/project-image-desktop.png)

## Table of Contents

- [Features](#features)
- [Technologies Used](#technologies-used)
- [Project Structure](#project-structure)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)

## Features

- **Speech to Text Translation** πŸŽ€βž‘οΈπŸ“: Speak in your native language, and watch as your words are translated into text in another language in real-time.
- **Text to Speech Conversion** πŸ“βž‘οΈπŸ”Š: Convert written text into natural-sounding speech in both the source and target languages.
- **Manual Text Input** πŸ–ŠοΈ: Double-click on the editor to manually enter text if you prefer typing over speaking.
- **Copy Text Functionality** πŸ“‹: Easily copy the translated text with a single click.
- **User-Friendly Interface** πŸ–₯️: Our application features a clean and intuitive UI built with Chakra UI, ensuring a smooth user experience.

## Technologies Used





### Frontend

- **Next.js**: A React framework for server-side rendering and static site generation.
- **React**: A JavaScript library for building user interfaces.
- **Chakra UI**: A simple, modular, and accessible component library that gives you the building blocks to build React applications.

### Backend

- **FastAPI**: A modern, fast (high-performance) web framework for building APIs with Python.
- **Google Translator**: Library for translating text.
- **gTTS (Google Text-to-Speech)**: A Python library and CLI tool to interface with Google Translate’s text-to-speech API.

### Containerization

- **Docker**: Containerization platform to package applications and their dependencies.

## Project Structure

```plaintext
.
β”œβ”€β”€ backend
β”‚ β”œβ”€β”€ Dockerfile
β”‚ β”œβ”€β”€ app.py
β”‚ β”œβ”€β”€ requirements.txt
β”œβ”€β”€ frontend
β”‚ β”œβ”€β”€ Dockerfile
β”‚ β”œβ”€β”€ package.json
β”‚ β”œβ”€β”€ public
β”‚ β”œβ”€β”€ app
β”‚ β”‚ β”œβ”€β”€ api
β”‚ β”‚ β”œβ”€β”€ pages
| β”œβ”€β”€ components
β”œβ”€β”€ docker-compose.yml
```

## Installation

### Prerequisites

- **Docker**: Make sure Docker is installed and running on your machine.
- **Node.js**: Node 18+ is required if running the frontend manually.

### Running with Docker

1. Clone the repository:

```sh
git clone https://github.com/Kritagya-web/NLP-Speech-Translator-Website.git
cd NLP-Speech-Translator-Website
```

2. Build and start the containers:

```sh
docker-compose up --build -d
```

3. Access the application:

- Frontend: `http://localhost:3000`
- Backend: `http://localhost:8000`

### Running Manually (skip if using Docker)

#### Backend

1. Navigate to the backend directory:

```sh
cd backend
```

2. Install dependencies:

```sh
pip install -r requirements.txt
```

3. Start the backend server:

```sh
uvicorn app:app --host 0.0.0.0 --port 8000
```

#### Frontend

1. Navigate to the frontend directory:

```sh
cd frontend
```

2. Add a `.env.local` file in the root (frontend).

3. In the `.env.local` file, add the following environment variable for the frontend to access the backend API:

```sh
# Or you may add the IP at which the Python backend is running here
NEXT_PUBLIC_TRANSLATOR_API_URL=http://localhost:8000
```

4. Install dependencies:

```sh
npm install
```

5. Start the frontend server:

```sh
npm run dev
```

6. Access the frontend:

- Frontend: `http://localhost:3000`

## Usage

- **Speak to Translate**: Click the microphone icon to start speaking. The spoken words will be translated into text in the target language.
- **Text to Speech**: Click the speaker icon to convert text to speech in the selected language.
- **Manual Text Input**: Double-click the editor to enter text manually.
- **Copy Text**: Use the copy button to copy translated text.

## Configuration

### Environment Variables

The `docker-compose.yml` file includes environment variables for the frontend service. These variables are set to interact with the backend service running at `http://172.17.0.1:8000`.

```yaml
environment:
- NEXT_PUBLIC_TRANSLATOR_API_URL=http://172.17.0.1:8000
```

You can modify these values based on your setup.

### CORS Configuration

The `app.py` file in the backend specifies allowed origins for CORS. By default, it includes:

```python
origins = [
"http://localhost:3000",
"http://172.17.0.1:3000",
]
```

Add or modify origins as needed.

## Contributing

Contributions are welcome! Please follow these steps:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Commit your changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Open a pull request.

## License [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contact

Developed by [Kritagya Kumra](https://github.com/Kritagya-web). For any inquiries, please contact me via [kritagyakumra@gmail.com](mailto:kritagyakumra@gmail.com).

**LinkedIn:** [Kritagya Kumra](https://www.linkedin.com/in/kritagya-kumra-bba9b41b6/)

**LeetCode:** [Kritagya Kumra](https://leetcode.com/u/Kritagya7777/)

---

Thank you for using the NLP Speech Recognition and Translation Project! We hope you find it helpful and easy to use.