jaisun2004 commited on
Commit
6890e44
Β·
verified Β·
1 Parent(s): a1a69c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -35
app.py CHANGED
@@ -14,7 +14,7 @@ from datetime import datetime
14
  st.set_page_config(page_title="Atma.ai - Session Summarizer + Export", layout="wide")
15
 
16
  st.title("🧠 Atma.ai – Advanced Mental Health Session Summarizer")
17
- st.markdown("Upload a therapy session audio (Tamil-English mix) to view the transcript, summary, emotional analysis, and export everything to Word!")
18
 
19
  # Upload audio
20
  uploaded_file = st.file_uploader("πŸŽ™οΈ Upload audio file", type=["wav", "mp3", "m4a"])
@@ -58,21 +58,21 @@ if uploaded_file:
58
  ]
59
  rag_context = "\n".join([f"Session {i+1}: {s['coping']}, {s['emotion']}, {s['notes']}" for i, s in enumerate(past_sessions)])
60
  prompt_input = f"""Previous session context:\n{rag_context}\n\nCurrent session:\n{raw_transcript}"""
61
- summary = summarizer(prompt_input, max_length=256, min_length=60, do_sample=False)
62
 
63
- # Emotion tagging
64
- st.info("🎭 Extracting emotional tones...")
65
- emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)
66
- emotion_scores = emotion_model(raw_transcript)
67
 
68
- # Layout with Tabs
69
 
70
- with tab1:
71
- st.subheader("πŸ“ Speaker-Simulated Transcript")
72
- st.markdown(diarized_transcript, unsafe_allow_html=True)
73
 
74
- with tab2:
75
- st.subheader("πŸ“‹ Contextual Summary")
76
 
77
  # Insight Tracking based on previous sessions
78
  insights = []
@@ -85,26 +85,26 @@ if uploaded_file:
85
  final_output = f"{summary[0]['summary_text']}\n\nContextual Observations:\n" + "\n".join(insights)
86
  st.write(final_output)
87
 
88
- with tab3:
89
- st.subheader("πŸ’¬ Emotional Insights (Overall)")
90
- if 'emotion_scores' in locals():
91
- for emo in emotion_scores[0]:
92
- st.write(f"{emo['label']}: {round(emo['score']*100, 2)}%")
93
- else:
94
- st.write("No emotional data to display.")
 
 
 
 
 
 
 
95
 
96
- with tab4:
97
- st.subheader("πŸ“ˆ Emotional Trends Over Time")
98
-
99
- session_dates = ["2024-04-01", "2024-04-08", "2024-04-15", "2024-04-22"]
100
- anxiety_scores = [70, 65, 55, 40]
101
- sadness_scores = [30, 20, 25, 15]
102
-
103
- fig = go.Figure()
104
- fig.add_trace(go.Scatter(x=session_dates, y=anxiety_scores, mode='lines+markers', name='Anxiety'))
105
- fig.add_trace(go.Scatter(x=session_dates, y=sadness_scores, mode='lines+markers', name='Sadness'))
106
- fig.update_layout(title='Emotional Trends', xaxis_title='Date', yaxis_title='Score (%)')
107
- st.plotly_chart(fig)
108
 
109
  # Export Button
110
  st.subheader("πŸ“₯ Export Session Report")
@@ -162,14 +162,14 @@ if uploaded_file:
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
 
@@ -186,7 +186,7 @@ with tab2:
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]:
@@ -194,7 +194,7 @@ with tab3:
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]
 
14
  st.set_page_config(page_title="Atma.ai - Session Summarizer + Export", layout="wide")
15
 
16
  st.title("🧠 Atma.ai – Advanced Mental Health Session Summarizer")
17
+ st.markdown("Upload a therapy session audio (Tamil-English mix) to view the transcript, summary, emotional analysis, and export everything to Word!")
18
 
19
  # Upload audio
20
  uploaded_file = st.file_uploader("πŸŽ™οΈ Upload audio file", type=["wav", "mp3", "m4a"])
 
58
  ]
59
  rag_context = "\n".join([f"Session {i+1}: {s['coping']}, {s['emotion']}, {s['notes']}" for i, s in enumerate(past_sessions)])
60
  prompt_input = f"""Previous session context:\n{rag_context}\n\nCurrent session:\n{raw_transcript}"""
61
+ summary = summarizer(prompt_input, max_length=256, min_length=60, do_sample=False)
62
 
63
+ # Emotion tagging
64
+ st.info("🎭 Extracting emotional tones...")
65
+ emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)
66
+ emotion_scores = emotion_model(raw_transcript)
67
 
68
+ # Layout with Tabs
69
 
70
+ with tab1:
71
+ st.subheader("πŸ“ Speaker-Simulated Transcript")
72
+ st.markdown(diarized_transcript, unsafe_allow_html=True)
73
 
74
+ with tab2:
75
+ st.subheader("πŸ“‹ Contextual Summary")
76
 
77
  # Insight Tracking based on previous sessions
78
  insights = []
 
85
  final_output = f"{summary[0]['summary_text']}\n\nContextual Observations:\n" + "\n".join(insights)
86
  st.write(final_output)
87
 
88
+ with tab3:
89
+ st.subheader("πŸ’¬ Emotional Insights (Overall)")
90
+ if 'emotion_scores' in locals():
91
+ for emo in emotion_scores[0]:
92
+ st.write(f"{emo['label']}: {round(emo['score']*100, 2)}%")
93
+ else:
94
+ st.write("No emotional data to display.")
95
+
96
+ with tab4:
97
+ st.subheader("πŸ“ˆ Emotional Trends Over Time")
98
+
99
+ session_dates = ["2024-04-01", "2024-04-08", "2024-04-15", "2024-04-22"]
100
+ anxiety_scores = [70, 65, 55, 40]
101
+ sadness_scores = [30, 20, 25, 15]
102
 
103
+ fig = go.Figure()
104
+ fig.add_trace(go.Scatter(x=session_dates, y=anxiety_scores, mode='lines+markers', name='Anxiety'))
105
+ fig.add_trace(go.Scatter(x=session_dates, y=sadness_scores, mode='lines+markers', name='Sadness'))
106
+ fig.update_layout(title='Emotional Trends', xaxis_title='Date', yaxis_title='Score (%)')
107
+ st.plotly_chart(fig)
 
 
 
 
 
 
 
108
 
109
  # Export Button
110
  st.subheader("πŸ“₯ Export Session Report")
 
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
 
 
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]:
 
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]