Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
from audio_recorder_streamlit import audio_recorder
|
5 |
+
import time
|
6 |
+
from pathlib import Path
|
7 |
+
import json
|
8 |
+
|
9 |
+
# Load environment variables
|
10 |
+
load_dotenv()
|
11 |
+
|
12 |
+
# Page config
|
13 |
+
st.set_page_config(
|
14 |
+
page_title="MI Assistant",
|
15 |
+
page_icon="🧊",
|
16 |
+
layout="wide",
|
17 |
+
initial_sidebar_state="expanded"
|
18 |
+
)
|
19 |
+
|
20 |
+
# Initialize session state variables
|
21 |
+
if 'role' not in st.session_state:
|
22 |
+
st.session_state.role = None
|
23 |
+
if 'current_mode' not in st.session_state:
|
24 |
+
st.session_state.current_mode = None
|
25 |
+
|
26 |
+
# Sidebar
|
27 |
+
def sidebar():
|
28 |
+
with st.sidebar:
|
29 |
+
# Role switcher at the top
|
30 |
+
st.session_state.role = st.radio(
|
31 |
+
"Switch Role",
|
32 |
+
["Consumer", "Therapist"],
|
33 |
+
index=0 if st.session_state.role == "Consumer" else 1
|
34 |
+
)
|
35 |
+
|
36 |
+
st.title("Navigation")
|
37 |
+
|
38 |
+
# Tutorial button
|
39 |
+
if st.button("Tutorial"):
|
40 |
+
st.session_state.current_mode = "tutorial"
|
41 |
+
|
42 |
+
# Main navigation
|
43 |
+
st.subheader("Main Features")
|
44 |
+
if st.button("Live Session"):
|
45 |
+
st.session_state.current_mode = "live_session"
|
46 |
+
if st.button("Moti Chat"):
|
47 |
+
st.session_state.current_mode = "moti_chat"
|
48 |
+
if st.button("Session Analysis"):
|
49 |
+
st.session_state.current_mode = "session_analysis"
|
50 |
+
|
51 |
+
# Welcome page
|
52 |
+
def welcome_page():
|
53 |
+
st.title("Welcome to MI Assistant")
|
54 |
+
st.write("Please select your role to continue:")
|
55 |
+
|
56 |
+
col1, col2 = st.columns(2)
|
57 |
+
with col1:
|
58 |
+
if st.button("I am a Consumer"):
|
59 |
+
st.session_state.role = "Consumer"
|
60 |
+
st.session_state.current_mode = "tutorial"
|
61 |
+
with col2:
|
62 |
+
if st.button("I am a Therapist"):
|
63 |
+
st.session_state.role = "Therapist"
|
64 |
+
st.session_state.current_mode = "tutorial"
|
65 |
+
|
66 |
+
# Main app logic
|
67 |
+
def main():
|
68 |
+
if st.session_state.role is None:
|
69 |
+
welcome_page()
|
70 |
+
else:
|
71 |
+
sidebar()
|
72 |
+
|
73 |
+
if st.session_state.current_mode == "tutorial":
|
74 |
+
show_tutorial()
|
75 |
+
elif st.session_state.current_mode == "live_session":
|
76 |
+
show_live_session()
|
77 |
+
elif st.session_state.current_mode == "moti_chat":
|
78 |
+
show_moti_chat()
|
79 |
+
elif st.session_state.current_mode == "session_analysis":
|
80 |
+
show_session_analysis()
|
81 |
+
|
82 |
+
if __name__ == "__main__":
|
83 |
+
main()
|