Spaces:
Sleeping
Sleeping
Upload 7 files
Browse files- .env +1 -0
- .gitignore +4 -0
- README.md +56 -12
- app.py +27 -0
- requirements.txt +9 -0
- setup.py +10 -0
- template.py +34 -0
.env
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
GOOGLE_API_KEY = 'AIzaSyDftMfBzRX-VKPHga-3Pvr2ie_vziKXRjc'
|
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
multilingual
|
2 |
+
/.env
|
3 |
+
env
|
4 |
+
aivenv
|
README.md
CHANGED
@@ -1,12 +1,56 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Multilingual Assistant
|
2 |
+
|
3 |
+
|
4 |
+
# How to run?
|
5 |
+
### STEPS:
|
6 |
+
|
7 |
+
Clone the repository
|
8 |
+
|
9 |
+
```bash
|
10 |
+
Project repo: https://github.com/
|
11 |
+
```
|
12 |
+
### STEP 01- Create a conda environment after opening the repository
|
13 |
+
|
14 |
+
```bash
|
15 |
+
conda create -n llmapp python=3.8 -y
|
16 |
+
```
|
17 |
+
|
18 |
+
```bash
|
19 |
+
conda activate llmapp
|
20 |
+
```
|
21 |
+
|
22 |
+
|
23 |
+
### STEP 02- install the requirements
|
24 |
+
```bash
|
25 |
+
pip install -r requirements.txt
|
26 |
+
```
|
27 |
+
|
28 |
+
### Create a `.env` file in the root directory and add your GOOGLE_API_KEY credentials as follows:
|
29 |
+
|
30 |
+
```ini
|
31 |
+
GOOGLE_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
32 |
+
```
|
33 |
+
|
34 |
+
|
35 |
+
```bash
|
36 |
+
# Finally run the following command
|
37 |
+
streamlit run app.py
|
38 |
+
```
|
39 |
+
|
40 |
+
Now,
|
41 |
+
```bash
|
42 |
+
open up localhost:
|
43 |
+
```
|
44 |
+
|
45 |
+
|
46 |
+
### Techstack Used:
|
47 |
+
|
48 |
+
- Python
|
49 |
+
- Google API
|
50 |
+
- Streamlit
|
51 |
+
- PaLM2
|
52 |
+
- s2t
|
53 |
+
- t2s
|
54 |
+
|
55 |
+
|
56 |
+
|
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from src.helper import voice_input, llm_model_object, text_to_speech
|
3 |
+
|
4 |
+
|
5 |
+
def main():
|
6 |
+
st.title("Multilingual AI Assistant 🤖")
|
7 |
+
|
8 |
+
if st.button("Ask me anything"):
|
9 |
+
with st.spinner("Listening..."):
|
10 |
+
text=voice_input()
|
11 |
+
response=llm_model_object(text)
|
12 |
+
text_to_speech(response)
|
13 |
+
|
14 |
+
|
15 |
+
audio_file=open("speech.mp3","rb")
|
16 |
+
audio_bytes=audio_file.read()
|
17 |
+
|
18 |
+
|
19 |
+
st.text_area(label="Response:",value=response,height=350)
|
20 |
+
st.audio(audio_bytes)
|
21 |
+
st.download_button(label="Download Speech",
|
22 |
+
data=audio_bytes,
|
23 |
+
file_name="speech.mp3",
|
24 |
+
mime="audio/mp3")
|
25 |
+
|
26 |
+
if __name__=='__main__':
|
27 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
SpeechRecognition
|
2 |
+
pipwin
|
3 |
+
PyAudio
|
4 |
+
gTTS
|
5 |
+
google-generativeai
|
6 |
+
python-dotenv
|
7 |
+
streamlit
|
8 |
+
|
9 |
+
-e .
|
setup.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from setuptools import find_packages, setup
|
2 |
+
|
3 |
+
setup(
|
4 |
+
name="multilingual assistant",
|
5 |
+
version="0.0.1",
|
6 |
+
author="bijay",
|
7 |
+
author_email="[email protected]",
|
8 |
+
packages=find_packages(),
|
9 |
+
install_requires=["SpeechRecognition","pipwin","pyaudio","gTTS","google-generativeai","python-dotenv","streamlit"]
|
10 |
+
)
|
template.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import logging
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
logging.basicConfig(level=logging.INFO, format='[%(asctime)s]: %(message)s:')
|
6 |
+
|
7 |
+
list_of_files = [
|
8 |
+
"src/__init__.py",
|
9 |
+
"src/helper.py",
|
10 |
+
".env",
|
11 |
+
"requirements.txt",
|
12 |
+
"setup.py",
|
13 |
+
"app.py",
|
14 |
+
"research/trials.ipynb"
|
15 |
+
]
|
16 |
+
|
17 |
+
|
18 |
+
for filepath in list_of_files:
|
19 |
+
filepath = Path(filepath)
|
20 |
+
filedir, filename = os.path.split(filepath)
|
21 |
+
|
22 |
+
|
23 |
+
if filedir !="":
|
24 |
+
os.makedirs(filedir, exist_ok=True)
|
25 |
+
logging.info(f"Creating directory; {filedir} for the file: {filename}")
|
26 |
+
|
27 |
+
if (not os.path.exists(filepath)) or (os.path.getsize(filepath) == 0):
|
28 |
+
with open(filepath, "w") as f:
|
29 |
+
pass
|
30 |
+
logging.info(f"Creating empty file: {filepath}")
|
31 |
+
|
32 |
+
|
33 |
+
else:
|
34 |
+
logging.info(f"{filename} is already exists")
|