Spaces:
Sleeping
Sleeping
Enhance VoiceField with detailed voice characteristics and improved somatic tracking
Browse files- src/streamlit_app.py +164 -139
src/streamlit_app.py
CHANGED
@@ -68,72 +68,118 @@ Created by [Jocelyn Skillman LMHC](http://www.jocelynskillman.com), this tool he
|
|
68 |
4. Receive a comprehensive somatic-relational debrief
|
69 |
""")
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
# Voice selection and setup form
|
72 |
with st.form("setup_form"):
|
73 |
st.header("Set Up Your Exploration")
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
scenario = st.text_area(
|
86 |
"What would you like to explore or discuss?",
|
87 |
-
placeholder="Example: I want to understand why I freeze when receiving feedback"
|
|
|
88 |
)
|
89 |
|
90 |
somatic_focus = st.text_area(
|
91 |
"What bodily sensations would you like to track?",
|
92 |
-
placeholder="Example: Tension in shoulders, breath patterns, gut responses"
|
|
|
93 |
)
|
94 |
|
95 |
goals = st.text_area(
|
96 |
"What are your exploration goals?",
|
97 |
-
placeholder="Example: Notice how different voices affect my nervous system activation"
|
|
|
98 |
)
|
99 |
|
100 |
submitted = st.form_submit_button("Begin Exploration")
|
101 |
|
102 |
if submitted:
|
103 |
st.session_state.current_voice = voice_type
|
104 |
-
st.session_state.voice_transitions = [(datetime.now().strftime("%H:%M:%S"), voice_type)]
|
105 |
|
106 |
# Prepare system message with voice parameters
|
107 |
-
voice_characteristics = {
|
108 |
-
"Nurturing": {
|
109 |
-
"style": "warm, empathetic, and supportive",
|
110 |
-
"language": "gentle, validating, and attuned",
|
111 |
-
"pacing": "slow and patient",
|
112 |
-
"focus": "creating safety and connection"
|
113 |
-
},
|
114 |
-
"Challenging": {
|
115 |
-
"style": "direct, provocative, and growth-oriented",
|
116 |
-
"language": "clear, bold, and respectfully confrontational",
|
117 |
-
"pacing": "dynamic and engaging",
|
118 |
-
"focus": "expanding awareness and capacity"
|
119 |
-
},
|
120 |
-
"Neutral": {
|
121 |
-
"style": "objective, clear, and grounded",
|
122 |
-
"language": "balanced, factual, and measured",
|
123 |
-
"pacing": "steady and consistent",
|
124 |
-
"focus": "observing patterns and processes"
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
voice = voice_characteristics[voice_type]
|
129 |
st.session_state.system_message = f"""
|
130 |
You are a conversational partner helping someone explore their somatic responses to different relational styles.
|
131 |
|
132 |
VOICE TYPE: {voice_type}
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
|
138 |
CONTEXT:
|
139 |
- Scenario: {scenario}
|
@@ -143,44 +189,43 @@ with st.form("setup_form"):
|
|
143 |
KEY INSTRUCTIONS:
|
144 |
1. Stay consistently in the {voice_type} voice style
|
145 |
2. Keep responses focused and concise (2-3 sentences max)
|
146 |
-
3. Occasionally
|
147 |
-
|
148 |
-
- "How is your breath responding to this?"
|
149 |
-
- "Where do you feel this in your body?"
|
150 |
|
151 |
If the user types "debrief" or "end exploration", provide a comprehensive therapeutic debrief including:
|
152 |
|
153 |
1. **Somatic Patterns**:
|
154 |
-
- Track
|
155 |
-
- Note
|
156 |
-
- Identify
|
157 |
|
158 |
-
2. **
|
159 |
-
-
|
160 |
-
-
|
161 |
-
-
|
162 |
|
163 |
-
3. **Relational
|
164 |
-
-
|
165 |
-
-
|
166 |
-
-
|
167 |
|
168 |
4. **Integration Tools**:
|
169 |
-
-
|
170 |
-
-
|
171 |
-
-
|
172 |
|
173 |
5. **Growth Edges**:
|
174 |
-
-
|
175 |
-
-
|
176 |
-
-
|
177 |
|
178 |
-
6. **Therapeutic
|
179 |
-
-
|
180 |
-
-
|
181 |
-
-
|
182 |
|
183 |
Maintain a warm, psychodynamically-informed therapeutic voice in the debrief.
|
|
|
184 |
"""
|
185 |
|
186 |
st.session_state.messages = []
|
@@ -195,22 +240,14 @@ if st.session_state.setup_complete:
|
|
195 |
chat_col, journal_col = st.columns([3, 2])
|
196 |
|
197 |
with chat_col:
|
198 |
-
# Voice switching interface
|
199 |
-
if not st.session_state.in_debrief:
|
200 |
-
new_voice = st.selectbox(
|
201 |
-
"Switch voice type:",
|
202 |
-
["Nurturing", "Challenging", "Neutral"],
|
203 |
-
index=["Nurturing", "Challenging", "Neutral"].index(st.session_state.current_voice)
|
204 |
-
)
|
205 |
-
|
206 |
-
if new_voice != st.session_state.current_voice:
|
207 |
-
st.session_state.current_voice = new_voice
|
208 |
-
timestamp = datetime.now().strftime("%H:%M:%S")
|
209 |
-
st.session_state.voice_transitions.append((timestamp, new_voice))
|
210 |
-
st.rerun()
|
211 |
-
|
212 |
st.subheader(f"Conversation with {st.session_state.current_voice} Voice")
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
# Display chat history
|
215 |
for message in st.session_state.messages:
|
216 |
with st.chat_message(message["role"]):
|
@@ -222,11 +259,6 @@ if st.session_state.setup_complete:
|
|
222 |
if prompt.lower() in ["debrief", "end exploration"] and not st.session_state.in_debrief:
|
223 |
st.session_state.in_debrief = True
|
224 |
# Prepare debrief request
|
225 |
-
voice_history = "\n".join([
|
226 |
-
f"[{time}] Switched to {voice} voice"
|
227 |
-
for time, voice in st.session_state.voice_transitions
|
228 |
-
])
|
229 |
-
|
230 |
journal_summary = "\n".join([
|
231 |
f"[{entry['timestamp']}] {entry['note']}"
|
232 |
for entry in st.session_state.somatic_journal
|
@@ -234,8 +266,8 @@ if st.session_state.setup_complete:
|
|
234 |
|
235 |
prompt = f"""Please provide a therapeutic debrief for this somatic exploration:
|
236 |
|
237 |
-
Voice
|
238 |
-
{
|
239 |
|
240 |
Somatic Journal Entries:
|
241 |
{journal_summary}
|
@@ -278,72 +310,65 @@ if st.session_state.setup_complete:
|
|
278 |
with journal_col:
|
279 |
st.subheader("Somatic Journal")
|
280 |
|
281 |
-
#
|
282 |
-
st.
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
"Engagement": ["π₯ Connected", "π‘οΈ Protected", "β Disconnected"]
|
289 |
-
}
|
290 |
-
|
291 |
-
for i, (category, buttons) in enumerate(reactions.items()):
|
292 |
-
with reaction_cols[i]:
|
293 |
-
st.write(f"**{category}**")
|
294 |
-
for button in buttons:
|
295 |
-
if st.button(button):
|
296 |
-
timestamp = datetime.now().strftime("%H:%M:%S")
|
297 |
-
st.session_state.somatic_journal.append({
|
298 |
-
"timestamp": timestamp,
|
299 |
-
"note": f"Quick reaction: {button}"
|
300 |
-
})
|
301 |
-
st.rerun()
|
302 |
|
303 |
st.markdown("""
|
304 |
Use this space to note bodily sensations, emotions, and nervous system responses as they arise.
|
305 |
Each entry will be automatically timestamped.
|
306 |
-
|
307 |
-
π‘ Consider tracking:
|
308 |
-
- Physical sensations
|
309 |
-
- Breath patterns
|
310 |
-
- Muscle tension/release
|
311 |
-
- Energy levels
|
312 |
-
- Emotional shifts
|
313 |
-
- Relational impulses
|
314 |
""")
|
315 |
|
316 |
# Journal input
|
317 |
-
journal_entry = st.text_area(
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
|
327 |
# Display journal entries
|
328 |
-
st.
|
329 |
-
|
330 |
-
st.
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
|
|
|
|
|
|
335 |
|
336 |
# Add restart button after debrief
|
337 |
if st.session_state.in_debrief:
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
st.
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
|
|
347 |
|
348 |
# Footer
|
349 |
st.markdown("---")
|
|
|
68 |
4. Receive a comprehensive somatic-relational debrief
|
69 |
""")
|
70 |
|
71 |
+
# Voice characteristics and prompts
|
72 |
+
VOICE_CHARACTERISTICS = {
|
73 |
+
"Nurturing": {
|
74 |
+
"description": "Warm, empathetic, and supportive",
|
75 |
+
"style": "Use gentle language, validate feelings, and create safety",
|
76 |
+
"examples": [
|
77 |
+
"I hear how challenging this feels...",
|
78 |
+
"Take all the time you need...",
|
79 |
+
"Your response makes so much sense..."
|
80 |
+
],
|
81 |
+
"somatic_prompts": [
|
82 |
+
"Notice if your shoulders can soften...",
|
83 |
+
"How is your breath moving now?",
|
84 |
+
"What sensations of support can you feel?"
|
85 |
+
]
|
86 |
+
},
|
87 |
+
"Challenging": {
|
88 |
+
"description": "Direct, provocative, and growth-oriented",
|
89 |
+
"style": "Push for deeper insight while maintaining respect",
|
90 |
+
"examples": [
|
91 |
+
"Let's look at this pattern more closely...",
|
92 |
+
"What might you be avoiding here?",
|
93 |
+
"I wonder if there's more beneath this..."
|
94 |
+
],
|
95 |
+
"somatic_prompts": [
|
96 |
+
"Notice if there's any bracing or tension...",
|
97 |
+
"Where do you feel the edge of your comfort?",
|
98 |
+
"What happens in your body as we explore this?"
|
99 |
+
]
|
100 |
+
},
|
101 |
+
"Neutral": {
|
102 |
+
"description": "Objective, clear, and grounded",
|
103 |
+
"style": "Focus on facts and patterns without strong emotional coloring",
|
104 |
+
"examples": [
|
105 |
+
"Let's track what happened step by step...",
|
106 |
+
"I notice a pattern emerging here...",
|
107 |
+
"Can you tell me more about the sequence?"
|
108 |
+
],
|
109 |
+
"somatic_prompts": [
|
110 |
+
"What do you notice in your body right now?",
|
111 |
+
"How is your nervous system responding?",
|
112 |
+
"Where do you feel most grounded?"
|
113 |
+
]
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
# Voice selection and setup form
|
118 |
with st.form("setup_form"):
|
119 |
st.header("Set Up Your Exploration")
|
120 |
|
121 |
+
col1, col2 = st.columns([2,1])
|
122 |
+
|
123 |
+
with col1:
|
124 |
+
voice_type = st.selectbox(
|
125 |
+
"Choose the voice you'd like to explore:",
|
126 |
+
list(VOICE_CHARACTERISTICS.keys()),
|
127 |
+
help="Select the relational style you want to engage with"
|
128 |
+
)
|
129 |
+
|
130 |
+
# Display voice characteristics
|
131 |
+
voice = VOICE_CHARACTERISTICS[voice_type]
|
132 |
+
st.markdown(f"""
|
133 |
+
**{voice_type} Voice**
|
134 |
+
- *Style*: {voice['description']}
|
135 |
+
- *Approach*: {voice['style']}
|
136 |
+
|
137 |
+
*Example phrases*:
|
138 |
+
{"".join([f"- {ex}\\n" for ex in voice['examples']])}
|
139 |
+
""")
|
140 |
+
|
141 |
+
with col2:
|
142 |
+
st.markdown("""
|
143 |
+
### π― Voice Impact
|
144 |
+
Notice how different voices affect:
|
145 |
+
- Nervous system state
|
146 |
+
- Emotional accessibility
|
147 |
+
- Relational patterns
|
148 |
+
- Somatic responses
|
149 |
+
""")
|
150 |
|
151 |
scenario = st.text_area(
|
152 |
"What would you like to explore or discuss?",
|
153 |
+
placeholder="Example: I want to understand why I freeze when receiving feedback",
|
154 |
+
help="This can be a situation, pattern, or feeling you want to explore"
|
155 |
)
|
156 |
|
157 |
somatic_focus = st.text_area(
|
158 |
"What bodily sensations would you like to track?",
|
159 |
+
placeholder="Example: Tension in shoulders, breath patterns, gut responses",
|
160 |
+
help="Name specific areas of your body or types of sensations you want to pay attention to"
|
161 |
)
|
162 |
|
163 |
goals = st.text_area(
|
164 |
"What are your exploration goals?",
|
165 |
+
placeholder="Example: Notice how different voices affect my nervous system activation",
|
166 |
+
help="What would make this exploration meaningful for you?"
|
167 |
)
|
168 |
|
169 |
submitted = st.form_submit_button("Begin Exploration")
|
170 |
|
171 |
if submitted:
|
172 |
st.session_state.current_voice = voice_type
|
|
|
173 |
|
174 |
# Prepare system message with voice parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
st.session_state.system_message = f"""
|
176 |
You are a conversational partner helping someone explore their somatic responses to different relational styles.
|
177 |
|
178 |
VOICE TYPE: {voice_type}
|
179 |
+
Your responses should be {VOICE_CHARACTERISTICS[voice_type]['style']}
|
180 |
+
|
181 |
+
EXAMPLES OF YOUR VOICE STYLE:
|
182 |
+
{chr(10).join([f"- {ex}" for ex in VOICE_CHARACTERISTICS[voice_type]['examples']])}
|
183 |
|
184 |
CONTEXT:
|
185 |
- Scenario: {scenario}
|
|
|
189 |
KEY INSTRUCTIONS:
|
190 |
1. Stay consistently in the {voice_type} voice style
|
191 |
2. Keep responses focused and concise (2-3 sentences max)
|
192 |
+
3. Occasionally use these somatic prompts:
|
193 |
+
{chr(10).join([f"- {prompt}" for prompt in VOICE_CHARACTERISTICS[voice_type]['somatic_prompts']])}
|
|
|
|
|
194 |
|
195 |
If the user types "debrief" or "end exploration", provide a comprehensive therapeutic debrief including:
|
196 |
|
197 |
1. **Somatic Patterns**:
|
198 |
+
- Track the progression of bodily responses
|
199 |
+
- Note any recurring sensations or shifts
|
200 |
+
- Identify nervous system patterns (activation/settling)
|
201 |
|
202 |
+
2. **Voice Impact**:
|
203 |
+
- How this voice style affected their nervous system
|
204 |
+
- Patterns of engagement or protection that emerged
|
205 |
+
- Moments of regulation or dysregulation
|
206 |
|
207 |
+
3. **Relational Insight**:
|
208 |
+
- Connection between voice style and their responses
|
209 |
+
- Historical patterns this might relate to
|
210 |
+
- Resources and resilience observed
|
211 |
|
212 |
4. **Integration Tools**:
|
213 |
+
- Specific somatic practices for this voice style
|
214 |
+
- Nervous system regulation techniques
|
215 |
+
- Ways to work with similar dynamics
|
216 |
|
217 |
5. **Growth Edges**:
|
218 |
+
- Gentle observations about growth opportunities
|
219 |
+
- Validation of protective responses
|
220 |
+
- Invitation to future exploration
|
221 |
|
222 |
+
6. **Therapeutic Context**:
|
223 |
+
- Brief psychoeducation about observed patterns
|
224 |
+
- Normalization of responses
|
225 |
+
- Connection to broader relational themes
|
226 |
|
227 |
Maintain a warm, psychodynamically-informed therapeutic voice in the debrief.
|
228 |
+
Focus on somatic intelligence and nervous system wisdom.
|
229 |
"""
|
230 |
|
231 |
st.session_state.messages = []
|
|
|
240 |
chat_col, journal_col = st.columns([3, 2])
|
241 |
|
242 |
with chat_col:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
st.subheader(f"Conversation with {st.session_state.current_voice} Voice")
|
244 |
|
245 |
+
# Voice reminder
|
246 |
+
st.info(f"""
|
247 |
+
**Current Voice**: {st.session_state.current_voice}
|
248 |
+
*{VOICE_CHARACTERISTICS[st.session_state.current_voice]['description']}*
|
249 |
+
""")
|
250 |
+
|
251 |
# Display chat history
|
252 |
for message in st.session_state.messages:
|
253 |
with st.chat_message(message["role"]):
|
|
|
259 |
if prompt.lower() in ["debrief", "end exploration"] and not st.session_state.in_debrief:
|
260 |
st.session_state.in_debrief = True
|
261 |
# Prepare debrief request
|
|
|
|
|
|
|
|
|
|
|
262 |
journal_summary = "\n".join([
|
263 |
f"[{entry['timestamp']}] {entry['note']}"
|
264 |
for entry in st.session_state.somatic_journal
|
|
|
266 |
|
267 |
prompt = f"""Please provide a therapeutic debrief for this somatic exploration:
|
268 |
|
269 |
+
Voice Type: {st.session_state.current_voice}
|
270 |
+
Voice Style: {VOICE_CHARACTERISTICS[st.session_state.current_voice]['description']}
|
271 |
|
272 |
Somatic Journal Entries:
|
273 |
{journal_summary}
|
|
|
310 |
with journal_col:
|
311 |
st.subheader("Somatic Journal")
|
312 |
|
313 |
+
# Add somatic prompts based on current voice
|
314 |
+
with st.expander("π‘ Somatic Prompts", expanded=True):
|
315 |
+
st.markdown("""
|
316 |
+
As you engage with this voice, you might notice:
|
317 |
+
""")
|
318 |
+
for prompt in VOICE_CHARACTERISTICS[st.session_state.current_voice]['somatic_prompts']:
|
319 |
+
st.markdown(f"- {prompt}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
st.markdown("""
|
322 |
Use this space to note bodily sensations, emotions, and nervous system responses as they arise.
|
323 |
Each entry will be automatically timestamped.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
""")
|
325 |
|
326 |
# Journal input
|
327 |
+
journal_entry = st.text_area(
|
328 |
+
"What are you noticing in your body right now?",
|
329 |
+
key="journal_input",
|
330 |
+
help="Notice sensations, emotions, tension, ease, or any other bodily experiences"
|
331 |
+
)
|
332 |
+
|
333 |
+
col1, col2 = st.columns([1,2])
|
334 |
+
with col1:
|
335 |
+
if st.button("π Add Entry"):
|
336 |
+
if journal_entry:
|
337 |
+
timestamp = datetime.now().strftime("%H:%M:%S")
|
338 |
+
st.session_state.somatic_journal.append({
|
339 |
+
"timestamp": timestamp,
|
340 |
+
"note": journal_entry
|
341 |
+
})
|
342 |
+
with col2:
|
343 |
+
st.markdown("*Entries are saved automatically*")
|
344 |
|
345 |
# Display journal entries
|
346 |
+
if st.session_state.somatic_journal:
|
347 |
+
st.markdown("### Journal Entries")
|
348 |
+
for entry in reversed(st.session_state.somatic_journal):
|
349 |
+
st.markdown(f"""
|
350 |
+
**{entry['timestamp']}**
|
351 |
+
{entry['note']}
|
352 |
+
---
|
353 |
+
""")
|
354 |
+
else:
|
355 |
+
st.info("Your somatic journal entries will appear here...")
|
356 |
|
357 |
# Add restart button after debrief
|
358 |
if st.session_state.in_debrief:
|
359 |
+
st.markdown("---")
|
360 |
+
col1, col2 = st.columns([1,2])
|
361 |
+
with col1:
|
362 |
+
if st.button("π Start New Exploration"):
|
363 |
+
st.session_state.setup_complete = False
|
364 |
+
st.session_state.in_debrief = False
|
365 |
+
st.session_state.messages = []
|
366 |
+
st.session_state.somatic_journal = []
|
367 |
+
st.session_state.system_message = ""
|
368 |
+
st.session_state.current_voice = "Nurturing"
|
369 |
+
st.rerun()
|
370 |
+
with col2:
|
371 |
+
st.markdown("*Begin a new exploration with a different voice*")
|
372 |
|
373 |
# Footer
|
374 |
st.markdown("---")
|