Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,17 +14,11 @@
|
|
| 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
|
|
@@ -172,15 +166,12 @@ def wellness_analyzer(input_text, uploaded_file=None):
|
|
| 172 |
output = """
|
| 173 |
<div style="font-family: Arial, sans-serif; line-height: 1.6;">
|
| 174 |
<h3 style="color: #4a4a4a;">Detected Emotional State: {0}</h3>
|
| 175 |
-
|
| 176 |
<p><strong>Recommended Tone:</strong> {1}</p>
|
| 177 |
-
|
| 178 |
<p><strong>Personalized Advice:</strong></p>
|
| 179 |
<ol>
|
| 180 |
{2}
|
| 181 |
</ol>
|
| 182 |
-
|
| 183 |
-
<p><em>Listen to the generated audio file for a custom 30-second vibrational experience.</em></p>
|
| 184 |
</div>
|
| 185 |
""".format(
|
| 186 |
emotion.capitalize(),
|
|
@@ -190,18 +181,6 @@ def wellness_analyzer(input_text, uploaded_file=None):
|
|
| 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 {
|
|
@@ -234,12 +213,12 @@ with gr.Blocks(css=custom_css) as interface:
|
|
| 234 |
|
| 235 |
with gr.Column(scale=3):
|
| 236 |
output_text = gr.HTML(label="Analysis and Advice")
|
| 237 |
-
output_audio = gr.Audio(label="Your Custom 30-second Vibrational Tone🎶", type="filepath")
|
| 238 |
|
| 239 |
gr.Markdown(
|
| 240 |
"""
|
| 241 |
<div class="footer">
|
| 242 |
-
<p>Vers3Dynamics - Harmonizing your well-being through vibrational frequencies.</p>
|
| 243 |
</div>
|
| 244 |
"""
|
| 245 |
)
|
|
|
|
| 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
|
|
|
|
| 166 |
output = """
|
| 167 |
<div style="font-family: Arial, sans-serif; line-height: 1.6;">
|
| 168 |
<h3 style="color: #4a4a4a;">Detected Emotional State: {0}</h3>
|
|
|
|
| 169 |
<p><strong>Recommended Tone:</strong> {1}</p>
|
|
|
|
| 170 |
<p><strong>Personalized Advice:</strong></p>
|
| 171 |
<ol>
|
| 172 |
{2}
|
| 173 |
</ol>
|
| 174 |
+
<p><em>Listen to the generated audio file for a custom 30-second vibrational experience with subliminal messaging.</em></p>
|
|
|
|
| 175 |
</div>
|
| 176 |
""".format(
|
| 177 |
emotion.capitalize(),
|
|
|
|
| 181 |
|
| 182 |
return output, audio_file
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
# Define custom CSS
|
| 185 |
custom_css = """
|
| 186 |
.footer {
|
|
|
|
| 213 |
|
| 214 |
with gr.Column(scale=3):
|
| 215 |
output_text = gr.HTML(label="Analysis and Advice")
|
| 216 |
+
output_audio = gr.Audio(label="Your Custom 30-second Vibrational Tone with Subliminal Message 🎶", type="filepath")
|
| 217 |
|
| 218 |
gr.Markdown(
|
| 219 |
"""
|
| 220 |
<div class="footer">
|
| 221 |
+
<p>Vers3Dynamics - Harmonizing your well-being through vibrational frequencies and subliminal messaging.</p>
|
| 222 |
</div>
|
| 223 |
"""
|
| 224 |
)
|