Johan713 commited on
Commit
3dba470
·
verified ·
1 Parent(s): 801ce00

Delete pages/meditation.py

Browse files
Files changed (1) hide show
  1. pages/meditation.py +0 -130
pages/meditation.py DELETED
@@ -1,130 +0,0 @@
1
- import streamlit as st
2
- import time
3
- import random
4
- from pydub import AudioSegment
5
- from pydub.generators import Sine
6
- import io
7
- import base64
8
-
9
- # Function to generate binaural beats
10
- def generate_binaural_beat(freq1, freq2, duration_ms):
11
- beat1 = Sine(freq1).to_audio_segment(duration=duration_ms)
12
- beat2 = Sine(freq2).to_audio_segment(duration=duration_ms)
13
-
14
- stereo_beat = AudioSegment.from_mono_audiosegments(beat1, beat2)
15
-
16
- buffer = io.BytesIO()
17
- stereo_beat.export(buffer, format="wav")
18
- return buffer.getvalue()
19
-
20
- # Function to get binary audio data as base64
21
- def get_binary_file_downloader_html(bin_file, file_label='File'):
22
- bin_str = base64.b64encode(bin_file).decode()
23
- href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{file_label}.wav">Download {file_label}</a>'
24
- return href
25
-
26
- # Streamlit app
27
- def main():
28
- st.set_page_config(page_title="Meditation & Mindfulness Hub", layout="wide")
29
-
30
- st.title("🧘 Meditation & Mindfulness Hub")
31
- st.markdown("Improve your mental health and focus with our holistic learning experience.")
32
-
33
- # Sidebar for navigation
34
- menu = st.sidebar.selectbox("Choose a Practice", ["Meditation", "Mindfulness Exercises", "Binaural Beats", "Positive Affirmations"])
35
-
36
- if menu == "Meditation":
37
- meditation_page()
38
- elif menu == "Mindfulness Exercises":
39
- mindfulness_page()
40
- elif menu == "Binaural Beats":
41
- binaural_beats_page()
42
- elif menu == "Positive Affirmations":
43
- affirmations_page()
44
-
45
- def meditation_page():
46
- st.header("Guided Meditation")
47
-
48
- meditation_types = {
49
- "Breath Awareness": "Focus on your breath, observing each inhale and exhale...",
50
- "Body Scan": "Starting from your toes, gradually move your attention up through your body...",
51
- "Loving-Kindness": "Direct feelings of love and compassion towards yourself and others...",
52
- "Visualization": "Imagine a peaceful scene, like a serene beach or a tranquil forest..."
53
- }
54
-
55
- selected_meditation = st.selectbox("Choose a meditation type:", list(meditation_types.keys()))
56
- duration = st.slider("Meditation duration (minutes):", 5, 30, 10)
57
-
58
- if st.button("Start Meditation"):
59
- with st.spinner(f"Meditating for {duration} minutes..."):
60
- st.text(meditation_types[selected_meditation])
61
- meditation_progress = st.progress(0)
62
- for i in range(duration * 60):
63
- time.sleep(1)
64
- meditation_progress.progress((i + 1) / (duration * 60))
65
- st.success("Meditation complete. How do you feel?")
66
-
67
- def mindfulness_exercises_page():
68
- st.header("Mindfulness Exercises")
69
-
70
- exercises = [
71
- "Take three deep breaths, focusing on the sensation of air entering and leaving your body.",
72
- "Notice five things you can see, four things you can touch, three things you can hear, two things you can smell, and one thing you can taste.",
73
- "Spend one minute focusing solely on the present moment, acknowledging thoughts without judgment.",
74
- "Practice mindful walking by paying attention to each step and the sensations in your feet.",
75
- "Eat a small snack mindfully, noticing the taste, texture, and aroma with each bite."
76
- ]
77
-
78
- selected_exercise = st.selectbox("Choose a mindfulness exercise:", exercises)
79
-
80
- if st.button("Start Exercise"):
81
- with st.spinner("Practicing mindfulness..."):
82
- st.text(selected_exercise)
83
- time.sleep(60) # Give the user a minute to practice
84
- st.success("Exercise complete. Remember to carry this mindfulness with you throughout your day.")
85
-
86
- def binaural_beats_page():
87
- st.header("Binaural Beats Generator")
88
-
89
- st.write("Binaural beats are created when two slightly different frequencies are played in each ear, potentially influencing brainwave activity.")
90
-
91
- base_freq = st.slider("Base Frequency (Hz):", 100, 500, 200)
92
- beat_freq = st.slider("Desired Beat Frequency (Hz):", 1, 40, 10)
93
- duration = st.slider("Duration (seconds):", 30, 300, 60)
94
-
95
- if st.button("Generate Binaural Beat"):
96
- with st.spinner("Generating binaural beat..."):
97
- audio_data = generate_binaural_beat(base_freq, base_freq + beat_freq, duration * 1000)
98
- st.audio(audio_data, format='audio/wav')
99
- st.markdown(get_binary_file_downloader_html(audio_data, f"binaural_beat_{base_freq}_{beat_freq}Hz"), unsafe_allow_html=True)
100
-
101
- def affirmations_page():
102
- st.header("Positive Affirmations")
103
-
104
- predefined_affirmations = [
105
- "I am capable of achieving great things.",
106
- "Every day, I'm getting stronger and more confident.",
107
- "I trust in my abilities and embrace new challenges.",
108
- "I radiate positivity and attract positive experiences.",
109
- "I am worthy of love, respect, and success."
110
- ]
111
-
112
- affirmation_type = st.radio("Choose affirmation type:", ["Predefined", "Custom"])
113
-
114
- if affirmation_type == "Predefined":
115
- affirmation = st.selectbox("Select an affirmation:", predefined_affirmations)
116
- else:
117
- affirmation = st.text_input("Enter your custom affirmation:")
118
-
119
- repetitions = st.slider("Number of repetitions:", 1, 50, 10)
120
- interval = st.slider("Interval between repetitions (seconds):", 1, 10, 3)
121
-
122
- if st.button("Start Affirmations"):
123
- with st.spinner(f"Repeating affirmation {repetitions} times..."):
124
- for i in range(repetitions):
125
- st.write(affirmation)
126
- time.sleep(interval)
127
- st.success("Affirmation session complete. Carry this positive energy with you!")
128
-
129
- if __name__ == "__main__":
130
- main()