Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,11 +14,17 @@
|
|
| 14 |
|
| 15 |
import gradio as gr
|
| 16 |
import numpy as np
|
|
|
|
| 17 |
import soundfile as sf
|
| 18 |
from sentence_transformers import SentenceTransformer
|
| 19 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
# Load the pre-trained Sentence Transformer model
|
|
|
|
| 22 |
model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
|
| 23 |
|
| 24 |
# Function to generate a subliminal message
|
|
@@ -184,6 +190,18 @@ def wellness_analyzer(input_text, uploaded_file=None):
|
|
| 184 |
|
| 185 |
return output, audio_file
|
| 186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
# Define custom CSS
|
| 188 |
custom_css = """
|
| 189 |
.footer {
|
|
|
|
| 14 |
|
| 15 |
import gradio as gr
|
| 16 |
import numpy as np
|
| 17 |
+
from groq import Groq
|
| 18 |
import soundfile as sf
|
| 19 |
from sentence_transformers import SentenceTransformer
|
| 20 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 21 |
|
| 22 |
+
# Initialize Groq client
|
| 23 |
+
client = Groq(
|
| 24 |
+
api_key=os.environ.get("GROQ_API_KEY"),
|
| 25 |
+
)
|
| 26 |
# Load the pre-trained Sentence Transformer model
|
| 27 |
+
|
| 28 |
model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
|
| 29 |
|
| 30 |
# Function to generate a subliminal message
|
|
|
|
| 190 |
|
| 191 |
return output, audio_file
|
| 192 |
|
| 193 |
+
try:
|
| 194 |
+
chat_completion = client.chat.completions.create(
|
| 195 |
+
messages=[
|
| 196 |
+
{
|
| 197 |
+
"role": "user",
|
| 198 |
+
"content": prompt,
|
| 199 |
+
}
|
| 200 |
+
],
|
| 201 |
+
model="llama-3.1-8b-instant",
|
| 202 |
+
max_tokens=10, # Increased to allow for longer emotion words
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
# Define custom CSS
|
| 206 |
custom_css = """
|
| 207 |
.footer {
|