Spaces:
Sleeping
Sleeping
Update pages/ai_buddy.py
Browse files- pages/ai_buddy.py +11 -11
pages/ai_buddy.py
CHANGED
@@ -12,12 +12,12 @@ import tempfile
|
|
12 |
import time
|
13 |
import numpy as np
|
14 |
import threading
|
15 |
-
import sounddevice as sd
|
16 |
-
from playsound import playsound
|
17 |
-
import pygame
|
18 |
-
from scipy.io import wavfile
|
19 |
|
20 |
-
pygame.mixer.init()
|
21 |
|
22 |
# Load environment variables
|
23 |
load_dotenv()
|
@@ -61,7 +61,7 @@ def get_ai_response(user_input, buddy_config, therapy_technique=None):
|
|
61 |
response = chat.invoke(messages).content
|
62 |
return response
|
63 |
|
64 |
-
def play_sound_loop(sound_file, stop_event):
|
65 |
while not stop_event.is_set():
|
66 |
playsound(sound_file)
|
67 |
|
@@ -173,7 +173,7 @@ def show_meditation_timer():
|
|
173 |
st.session_state.achievements = set()
|
174 |
st.session_state.achievements.add("Zen Master")
|
175 |
st.success("Achievement Unlocked: Zen Master π§ββοΈ")
|
176 |
-
|
177 |
def show_personalized_recommendations():
|
178 |
st.subheader("π― Personalized Recommendations")
|
179 |
|
@@ -243,7 +243,7 @@ def show_personalized_recommendations():
|
|
243 |
for rec in additional_recs:
|
244 |
st.markdown(f"- {rec}")
|
245 |
|
246 |
-
def generate_binaural_beat(freq1, freq2, duration_seconds, sample_rate=44100):
|
247 |
t = np.linspace(0, duration_seconds, int(sample_rate * duration_seconds), False)
|
248 |
left_channel = np.sin(2 * np.pi * freq1 * t)
|
249 |
right_channel = np.sin(2 * np.pi * freq2 * t)
|
@@ -400,7 +400,7 @@ def show_binaural_beats():
|
|
400 |
# Ensure the app updates every second
|
401 |
if st.session_state.audio_playing:
|
402 |
time.sleep(1)
|
403 |
-
st.experimental_rerun()
|
404 |
|
405 |
def main():
|
406 |
st.set_page_config(page_title="S.H.E.R.L.O.C.K. AI Buddy", page_icon="π΅οΈ", layout="wide")
|
@@ -557,11 +557,11 @@ def main():
|
|
557 |
with tab2:
|
558 |
tool_choice = st.selectbox("Select a tool", ["Meditation Timer", "Binaural Beats", "Recommendations"])
|
559 |
if tool_choice == "Meditation Timer":
|
560 |
-
|
561 |
elif tool_choice == "Recommendations":
|
562 |
show_personalized_recommendations()
|
563 |
elif tool_choice == "Binaural Beats":
|
564 |
-
|
565 |
|
566 |
# Mood tracker
|
567 |
st.sidebar.markdown("---")
|
|
|
12 |
import time
|
13 |
import numpy as np
|
14 |
import threading
|
15 |
+
#import sounddevice as sd
|
16 |
+
#from playsound import playsound
|
17 |
+
#import pygame
|
18 |
+
#from scipy.io import wavfile
|
19 |
|
20 |
+
#pygame.mixer.init()
|
21 |
|
22 |
# Load environment variables
|
23 |
load_dotenv()
|
|
|
61 |
response = chat.invoke(messages).content
|
62 |
return response
|
63 |
|
64 |
+
'''def play_sound_loop(sound_file, stop_event):
|
65 |
while not stop_event.is_set():
|
66 |
playsound(sound_file)
|
67 |
|
|
|
173 |
st.session_state.achievements = set()
|
174 |
st.session_state.achievements.add("Zen Master")
|
175 |
st.success("Achievement Unlocked: Zen Master π§ββοΈ")
|
176 |
+
'''
|
177 |
def show_personalized_recommendations():
|
178 |
st.subheader("π― Personalized Recommendations")
|
179 |
|
|
|
243 |
for rec in additional_recs:
|
244 |
st.markdown(f"- {rec}")
|
245 |
|
246 |
+
'''def generate_binaural_beat(freq1, freq2, duration_seconds, sample_rate=44100):
|
247 |
t = np.linspace(0, duration_seconds, int(sample_rate * duration_seconds), False)
|
248 |
left_channel = np.sin(2 * np.pi * freq1 * t)
|
249 |
right_channel = np.sin(2 * np.pi * freq2 * t)
|
|
|
400 |
# Ensure the app updates every second
|
401 |
if st.session_state.audio_playing:
|
402 |
time.sleep(1)
|
403 |
+
st.experimental_rerun()'''
|
404 |
|
405 |
def main():
|
406 |
st.set_page_config(page_title="S.H.E.R.L.O.C.K. AI Buddy", page_icon="π΅οΈ", layout="wide")
|
|
|
557 |
with tab2:
|
558 |
tool_choice = st.selectbox("Select a tool", ["Meditation Timer", "Binaural Beats", "Recommendations"])
|
559 |
if tool_choice == "Meditation Timer":
|
560 |
+
st.warning('Due to some limitation on hugging face we cant play the audio on it so please go the git hub repo and try this file out over there', icon="β οΈ")
|
561 |
elif tool_choice == "Recommendations":
|
562 |
show_personalized_recommendations()
|
563 |
elif tool_choice == "Binaural Beats":
|
564 |
+
st.warning('Due to some limitation on hugging face we cant play the audio on it so please go the git hub repo and try this file out over there', icon="β οΈ")
|
565 |
|
566 |
# Mood tracker
|
567 |
st.sidebar.markdown("---")
|