Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -160,48 +160,48 @@ if uploaded_file:
|
|
160 |
if os.path.exists(audio_path):
|
161 |
os.remove(audio_path)
|
162 |
|
163 |
-
|
164 |
|
165 |
with tab1:
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
|
172 |
with tab2:
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
|
189 |
with tab3:
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
|
197 |
with tab4:
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
160 |
if os.path.exists(audio_path):
|
161 |
os.remove(audio_path)
|
162 |
|
163 |
+
tab1, tab2, tab3, tab4 = st.tabs(["π Transcript", "π Summary", "π¬ Emotions", "π Trends"])
|
164 |
|
165 |
with tab1:
|
166 |
+
st.subheader("π Speaker-Simulated Transcript")
|
167 |
+
if 'diarized_transcript' in locals():
|
168 |
+
st.markdown(diarized_transcript, unsafe_allow_html=True)
|
169 |
+
else:
|
170 |
+
st.warning("Transcript not available.")
|
171 |
|
172 |
with tab2:
|
173 |
+
st.subheader("π Contextual Summary")
|
174 |
+
if 'summary' in locals():
|
175 |
+
|
176 |
+
# Insight Tracking based on previous sessions
|
177 |
+
insights = []
|
178 |
+
if "music" in raw_transcript.lower():
|
179 |
+
if any("walking" in s["coping"] for s in past_sessions):
|
180 |
+
insights.append("Patient previously mentioned walking as a helpful coping mechanism. This time, music is highlighted instead.")
|
181 |
+
if "sleep" in raw_transcript.lower():
|
182 |
+
insights.append("Sleep continues to be a recurring theme across sessions.")
|
183 |
+
|
184 |
+
final_output = f"{summary[0]['summary_text']}\n\nContextual Observations:\n" + "\n".join(insights)
|
185 |
+
st.write(final_output)
|
186 |
+
else:
|
187 |
+
st.warning("Summary not available.")
|
188 |
|
189 |
with tab3:
|
190 |
+
st.subheader("π¬ Emotional Insights (Overall)")
|
191 |
+
if 'emotion_scores' in locals():
|
192 |
+
for emo in emotion_scores[0]:
|
193 |
+
st.write(f"{emo['label']}: {round(emo['score']*100, 2)}%")
|
194 |
+
else:
|
195 |
+
st.warning("No emotional data to display.")
|
196 |
|
197 |
with tab4:
|
198 |
+
st.subheader("π Emotional Trends Over Time")
|
199 |
+
session_dates = ["2024-04-01", "2024-04-08", "2024-04-15", "2024-04-22"]
|
200 |
+
anxiety_scores = [70, 65, 55, 40]
|
201 |
+
sadness_scores = [30, 20, 25, 15]
|
202 |
+
|
203 |
+
fig = go.Figure()
|
204 |
+
fig.add_trace(go.Scatter(x=session_dates, y=anxiety_scores, mode='lines+markers', name='Anxiety'))
|
205 |
+
fig.add_trace(go.Scatter(x=session_dates, y=sadness_scores, mode='lines+markers', name='Sadness'))
|
206 |
+
fig.update_layout(title='Emotional Trends', xaxis_title='Date', yaxis_title='Score (%)')
|
207 |
+
st.plotly_chart(fig)
|