File size: 3,002 Bytes
137b499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1ff431
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

---
title: Voice Chat Assistant
emoji: 🐒
colorFrom: gray
colorTo: blue
sdk: docker
pinned: false
license: apache-2.0
---

# Voice-Enabled Chat Application

This is a web-based chat application that allows users to interact with a personal assistant through both text and voice. It features a clean user interface with light and dark modes and voice input.

## Features

- **Personal Assistant:** The backend is powered by the Groq API to provide helpful and conversational responses.
- **Text and Voice Input:** Users can type messages or use their microphone to speak to the assistant.
- **Light/Dark Mode:** The user interface can be switched between light and dark themes for user comfort.
- **Multi-language Speech-to-Text:** Users can select from multiple languages for speech-to-text transcription.
- **Docker Support:** The application can be easily containerized and deployed using Docker.

## Technologies Used

- **Docker**

### Frontend

- HTML5
- CSS3
- JavaScript
- jQuery
- Bootstrap
- Font Awesome

### Backend

- Python
- Flask
- Flask-Cors
- Groq API
- SpeechRecognition

## Prerequisites

- Python 3.x
- `pip` for installing Python packages
- A Groq API key

## Installation and Setup

1.  **Clone the repository:**

    ```bash
    git clone https://github.com/your-username/chatapp-with-voice.git
    cd chatapp-with-voice
    ```

2.  **Create a virtual environment (optional but recommended):**

    ```bash
    python -m venv env
    source env/bin/activate  # On Windows, use `env\Scripts\activate`
    ```

3.  **Install the required Python packages:**

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

4.  **Set up your environment variables:**

    Create a `.env` file in the root of the project and add your Groq API key:

    ```
    GROQ_API_KEY=your_groq_api_key
    ```

## Usage

To run the application, execute the following command from the root of the project:

```bash
python -u server.py
```

The application will be available at `http://localhost:8000`.

## Project Structure

```
.
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ server.py
β”œβ”€β”€ static
β”‚   β”œβ”€β”€ js
β”‚   β”‚   β”œβ”€β”€ WebAudioRecorder.min.js
β”‚   β”‚   └── WebAudioRecorderWav.min.js
β”‚   β”œβ”€β”€ script.js
β”‚   └── style.css
β”œβ”€β”€ templates
β”‚   └── index.html
└── worker.py
```

-   `server.py`: The main Flask application file that handles routing and serves the web pages.
-   `worker.py`: Contains the core logic for speech-to-text and processing user messages with the Groq API.
-   `static/`: Contains the frontend JavaScript and CSS files.
-   `templates/`: Contains the HTML templates for the web pages.
-   `requirements.txt`: A list of the Python packages required for the project.
-   `Dockerfile`: Allows for building a Docker image of the application.

## License

This project is licensed under the terms of the Apache-2.0 license. See the `LICENSE` file for more details.