Spaces:
Paused
Paused
Upload 3 files
Browse files- app.py +57 -0
- config.py +19 -0
- requirements.txt +172 -0
app.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
from models.jairvis import JAIRVISMKV
|
| 4 |
+
from utils.audio_utils import text_to_speech, speech_to_text
|
| 5 |
+
from utils.memory_manager import MemoryManager
|
| 6 |
+
from config import MODEL_NAME, API_KEY
|
| 7 |
+
|
| 8 |
+
class JairvisApp:
|
| 9 |
+
def __init__(self):
|
| 10 |
+
self.jairvis = JAIRVISMKV()
|
| 11 |
+
self.memory_manager = MemoryManager()
|
| 12 |
+
self.nlp_pipeline = pipeline("text-generation", model=MODEL_NAME)
|
| 13 |
+
|
| 14 |
+
def process_input(self, input_text):
|
| 15 |
+
# Process input and generate response
|
| 16 |
+
response = self.jairvis.generate_response(input_text)
|
| 17 |
+
|
| 18 |
+
# Update memory
|
| 19 |
+
self.memory_manager.store(input_text, response)
|
| 20 |
+
|
| 21 |
+
# Convert response to speech
|
| 22 |
+
audio_output = text_to_speech(response)
|
| 23 |
+
|
| 24 |
+
return response, audio_output
|
| 25 |
+
|
| 26 |
+
def voice_input(self, audio):
|
| 27 |
+
# Convert speech to text
|
| 28 |
+
input_text = speech_to_text(audio)
|
| 29 |
+
|
| 30 |
+
# Process the text input
|
| 31 |
+
response, audio_output = self.process_input(input_text)
|
| 32 |
+
|
| 33 |
+
return input_text, response, audio_output
|
| 34 |
+
|
| 35 |
+
# Set up the Gradio interface
|
| 36 |
+
def launch():
|
| 37 |
+
app = JairvisApp()
|
| 38 |
+
|
| 39 |
+
text_interface = gr.Interface(
|
| 40 |
+
fn=app.process_input,
|
| 41 |
+
inputs="text",
|
| 42 |
+
outputs=["text", "audio"],
|
| 43 |
+
title="JAIRVISMKV Text Interface"
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
voice_interface = gr.Interface(
|
| 47 |
+
fn=app.voice_input,
|
| 48 |
+
inputs="audio",
|
| 49 |
+
outputs=["text", "text", "audio"],
|
| 50 |
+
title="JAIRVISMKV Voice Interface"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
combined_interface = gr.TabbedInterface([text_interface, voice_interface], ["Text", "Voice"])
|
| 54 |
+
combined_interface.launch()
|
| 55 |
+
|
| 56 |
+
if __name__ == "__main__":
|
| 57 |
+
launch()
|
config.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
# Model configurations
|
| 4 |
+
MODEL_NAME = "gpt2-medium"
|
| 5 |
+
SPEECH_MODEL = "facebook/wav2vec2-base-960h"
|
| 6 |
+
TTS_MODEL = "v3_en"
|
| 7 |
+
|
| 8 |
+
# Device configuration
|
| 9 |
+
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
+
|
| 11 |
+
# Memory configurations
|
| 12 |
+
MEMORY_SIZE = 10 * 1024 * 1024 * 1024 # 10GB in bytes
|
| 13 |
+
LOCAL_MEMORY_SIZE = 3 * 1024 * 1024 * 1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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
absl-py==2.1.0
|
| 2 |
+
annotated-types==0.7.0
|
| 3 |
+
anyio==4.4.0
|
| 4 |
+
area==1.1.1
|
| 5 |
+
astunparse==1.6.3
|
| 6 |
+
attrs==24.2.0
|
| 7 |
+
beautifulsoup4==4.12.3
|
| 8 |
+
blis==0.7.11
|
| 9 |
+
bs4==0.0.2
|
| 10 |
+
cachetools==5.5.0
|
| 11 |
+
catalogue==2.0.10
|
| 12 |
+
certifi==2024.8.30
|
| 13 |
+
cffi==1.17.1
|
| 14 |
+
charset-normalizer==3.3.2
|
| 15 |
+
click==8.1.7
|
| 16 |
+
cloudpathlib==0.19.0
|
| 17 |
+
colorama==0.4.6
|
| 18 |
+
comtypes==1.4.7
|
| 19 |
+
confection==0.1.5
|
| 20 |
+
contourpy==1.3.0
|
| 21 |
+
cryptography==43.0.1
|
| 22 |
+
cycler==0.12.1
|
| 23 |
+
cymem==2.0.8
|
| 24 |
+
distro==1.9.0
|
| 25 |
+
face-detection-tflite==0.6.0
|
| 26 |
+
filelock==3.16.0
|
| 27 |
+
fitbit==0.3.1
|
| 28 |
+
flatbuffers==24.3.25
|
| 29 |
+
fonttools==4.53.1
|
| 30 |
+
fsspec==2024.9.0
|
| 31 |
+
gast==0.6.0
|
| 32 |
+
google-ai-generativelanguage==0.6.6
|
| 33 |
+
google-api-core==2.19.2
|
| 34 |
+
google-api-python-client==2.144.0
|
| 35 |
+
google-auth==2.34.0
|
| 36 |
+
google-auth-httplib2==0.2.0
|
| 37 |
+
google-auth-oauthlib==1.2.1
|
| 38 |
+
google-generativeai==0.7.2
|
| 39 |
+
google-oauth==1.0.1
|
| 40 |
+
google-pasta==0.2.0
|
| 41 |
+
googleapis-common-protos==1.65.0
|
| 42 |
+
GPUtil==1.4.0
|
| 43 |
+
gputils==1.0.6
|
| 44 |
+
grpcio==1.66.1
|
| 45 |
+
grpcio-status==1.62.3
|
| 46 |
+
h11==0.14.0
|
| 47 |
+
h5py==3.11.0
|
| 48 |
+
httpcore==1.0.5
|
| 49 |
+
httplib2==0.22.0
|
| 50 |
+
httpx==0.27.2
|
| 51 |
+
huggingface-hub==0.24.6
|
| 52 |
+
idna==3.8
|
| 53 |
+
jax==0.4.31
|
| 54 |
+
jaxlib==0.4.31
|
| 55 |
+
Jinja2==3.1.4
|
| 56 |
+
jiter==0.5.0
|
| 57 |
+
joblib==1.4.2
|
| 58 |
+
keras==3.5.0
|
| 59 |
+
keras-facenet==0.3.2
|
| 60 |
+
kiwisolver==1.4.7
|
| 61 |
+
langcodes==3.4.0
|
| 62 |
+
language_data==1.2.0
|
| 63 |
+
libclang==18.1.1
|
| 64 |
+
marisa-trie==1.2.0
|
| 65 |
+
Markdown==3.7
|
| 66 |
+
markdown-it-py==3.0.0
|
| 67 |
+
MarkupSafe==2.1.5
|
| 68 |
+
matplotlib==3.9.2
|
| 69 |
+
mdurl==0.1.2
|
| 70 |
+
mediapipe==0.10.14
|
| 71 |
+
ml-dtypes==0.4.0
|
| 72 |
+
MouseInfo==0.1.3
|
| 73 |
+
mpmath==1.3.0
|
| 74 |
+
mtcnn==0.1.1
|
| 75 |
+
murmurhash==1.0.10
|
| 76 |
+
namex==0.0.8
|
| 77 |
+
networkx==3.3
|
| 78 |
+
nltk==3.9.1
|
| 79 |
+
numpy==1.26.4
|
| 80 |
+
oauth2==1.9.0.post1
|
| 81 |
+
oauthlib==3.2.2
|
| 82 |
+
openai==1.44.1
|
| 83 |
+
opencv-contrib-python==4.10.0.84
|
| 84 |
+
opencv-python==4.10.0.84
|
| 85 |
+
opt-einsum==3.3.0
|
| 86 |
+
optree==0.12.1
|
| 87 |
+
packaging==24.1
|
| 88 |
+
pandas==2.2.2
|
| 89 |
+
pillow==10.4.0
|
| 90 |
+
preshed==3.0.9
|
| 91 |
+
progressbar2==4.5.0
|
| 92 |
+
proto-plus==1.24.0
|
| 93 |
+
protobuf==4.25.4
|
| 94 |
+
psutil==6.0.0
|
| 95 |
+
pushbullet.py==0.12.0
|
| 96 |
+
pyasn1==0.6.0
|
| 97 |
+
pyasn1_modules==0.4.0
|
| 98 |
+
PyAudio==0.2.14
|
| 99 |
+
PyAutoGUI==0.9.54
|
| 100 |
+
pycoral==0.2.0
|
| 101 |
+
pycparser==2.22
|
| 102 |
+
pycryptodome==3.20.0
|
| 103 |
+
pydantic==2.9.1
|
| 104 |
+
pydantic_core==2.23.3
|
| 105 |
+
pyDes==2.0.1
|
| 106 |
+
pydub==0.25.1
|
| 107 |
+
PyGetWindow==0.0.9
|
| 108 |
+
Pygments==2.18.0
|
| 109 |
+
PyMsgBox==1.0.9
|
| 110 |
+
pyOpenSSL==24.2.1
|
| 111 |
+
pyparsing==3.1.4
|
| 112 |
+
pyperclip==1.9.0
|
| 113 |
+
pypiwin32==223
|
| 114 |
+
PyRect==0.2.0
|
| 115 |
+
PyScreeze==1.0.1
|
| 116 |
+
python-dateutil==2.9.0.post0
|
| 117 |
+
python-magic==0.4.27
|
| 118 |
+
python-utils==3.8.2
|
| 119 |
+
pyttsx3==2.91
|
| 120 |
+
pytweening==1.2.0
|
| 121 |
+
pytz==2024.1
|
| 122 |
+
pywifi==1.1.12
|
| 123 |
+
pywin32==306
|
| 124 |
+
PyYAML==6.0.2
|
| 125 |
+
regex==2024.7.24
|
| 126 |
+
requests==2.32.3
|
| 127 |
+
requests-oauthlib==2.0.0
|
| 128 |
+
rich==13.8.0
|
| 129 |
+
rsa==4.9
|
| 130 |
+
safetensors==0.4.5
|
| 131 |
+
scapy==2.5.0
|
| 132 |
+
scikit-learn==1.5.1
|
| 133 |
+
scipy==1.14.1
|
| 134 |
+
shellingham==1.5.4
|
| 135 |
+
six==1.16.0
|
| 136 |
+
smart-open==7.0.4
|
| 137 |
+
sniffio==1.3.1
|
| 138 |
+
sounddevice==0.5.0
|
| 139 |
+
soupsieve==2.6
|
| 140 |
+
spacy==3.7.6
|
| 141 |
+
spacy-legacy==3.0.12
|
| 142 |
+
spacy-loggers==1.0.5
|
| 143 |
+
SpeechRecognition==3.10.4
|
| 144 |
+
srsly==2.4.8
|
| 145 |
+
sympy==1.13.2
|
| 146 |
+
tenacity==9.0.0
|
| 147 |
+
tensorboard==2.17.1
|
| 148 |
+
tensorboard-data-server==0.7.2
|
| 149 |
+
tensorflow==2.17.0
|
| 150 |
+
tensorflow-intel==2.17.0
|
| 151 |
+
termcolor==2.4.0
|
| 152 |
+
textblob==0.18.0.post0
|
| 153 |
+
tf_keras==2.17.0
|
| 154 |
+
thinc==8.2.5
|
| 155 |
+
threadpoolctl==3.5.0
|
| 156 |
+
tokenizers==0.19.1
|
| 157 |
+
torch==2.4.1
|
| 158 |
+
tqdm==4.66.5
|
| 159 |
+
transformers==4.44.2
|
| 160 |
+
typer==0.12.5
|
| 161 |
+
typing_extensions==4.12.2
|
| 162 |
+
tzdata==2024.1
|
| 163 |
+
uritemplate==4.1.1
|
| 164 |
+
urllib3==2.2.2
|
| 165 |
+
wasabi==1.1.3
|
| 166 |
+
weasel==0.4.1
|
| 167 |
+
websocket-client==1.8.0
|
| 168 |
+
Werkzeug==3.0.4
|
| 169 |
+
wrapt==1.16.0
|
| 170 |
+
gradio
|
| 171 |
+
fastapi
|
| 172 |
+
uvicorn
|