import streamlit as st from st_aggrid import AgGrid import pandas as pd #set page config st.set_page_config(page_title='auditory skills resources', page_icon='icon-128x128.png') #define session variables if 'one' not in st.session_state: st.session_state['one'] = 'value' if 'two' not in st.session_state: st.session_state['two'] = 'value' if 'three' not in st.session_state: st.session_state['three'] = 'value' if 'four' not in st.session_state: st.session_state['four'] = 'value' #main page content with st.sidebar: st.title('auditory skills') st.header('powered by rascal') st.markdown(''' ## About This is a questionaire for parents to asses their child's auditory skills and recieve a custom list of resources that are customized for their child at their current stage of development. It is recommended that parents re-take the assessment every 4-6 weeks as their child progresses to ensure that the child is best able to build upon established auditory competencies. ''') st.write('Made with resources provided by the HATCH (Helping Adults Talk to Children) Lab. The HATCH lab is located at Idaho State University in Meridian, Idaho and seeks to ensure that adults have access to tools and resources to optimize the language of children through connection and engagement') def main(): #st.markdown('hello') if 'current_view' not in st.session_state: st.session_state['current_view'] = 'Grid' if 'current_step' not in st.session_state: st.session_state['current_step'] = 1 def set_page_view(page): st.session_state['current_view'] = page st.session_state['current_step'] = 1 def set_form_step(action,step=None): if action == 'Next': st.session_state['current_step'] = st.session_state['current_step'] + 1 if action == 'Back': st.session_state['current_step'] = st.session_state['current_step'] - 1 if action == 'Jump': st.session_state['current_step'] = step ##### wizard functions #### def wizard_form_header(): sf_header_cols = st.columns([1,1.75,1]) with sf_header_cols[1]: st.subheader('Auditory Stages') # determines button color which should be red when user is on that given step wh_type = 'primary' if st.session_state['current_step'] == 1 else 'secondary' ff_type = 'primary' if st.session_state['current_step'] == 2 else 'secondary' lo_type = 'primary' if st.session_state['current_step'] == 3 else 'secondary' sf_type = 'primary' if st.session_state['current_step'] == 4 else 'secondary' step_cols = st.columns([.5,.85,.85,.85,.85,.5]) step_cols[1].button('Does your child respond to a familiar voice?',on_click=set_form_step,args=['Jump',1]) step_cols[2].button('Does your child listen to somebody speaking?',on_click=set_form_step,args=['Jump',2]) step_cols[3].button('Is your child interested in toys producing sounds or music?',on_click=set_form_step,args=['Jump',3]) step_cols[4].button('Does your child look for a speaker they cannot see?',on_click=set_form_step,args=['Jump',4]) ### Replace Wizard Form Body with this ### def wizard_form_body(): if st.session_state['current_step'] == 1: form1 = st.form("question-1") form1.write("Describe how your child reacts when a familiar voice is presented. Responses can be anything such as looking at the person, moving, a facial expression (e.g., smile), or a sound they make.") textone = form1.text_input(" ") submitted1 = form1.form_submit_button("Submit") if submitted1: st.session_state['one'] = textone if st.session_state['current_step'] == 2: form2 = st.form("question-2") form2.write("Describe how your child reacts when someone is talking to them and responds with actions (e.g., looking at the person speaking, smiling) and vocalizations (e.g., laughing, babbling back and forth with speaker).") texttwo = form2.text_input(" ") submitted2 = form2.form_submit_button("Submit") if submitted2: st.session_state['two'] = texttwo if st.session_state['current_step'] == 3: form3 = st.form("question-3") form3.write("Describe what happens when your child plays with or notices toys that are musical or have sound qualities. Your child may pick up the toy, move it, look at it, and/or mouth it.") textthree = form3.text_input(" ") submitted3 = form3.form_submit_button("Submit") if submitted3: st.session_state['three'] = textthree if st.session_state['current_step'] == 4: form4 = st.form("question-4") form4.write("Describe what would happen if, while interacting with your child, another person begins talking behind you. Would your child stop talking? Turn and look? Search for the sound? Or perhaps vocalize?") textfour = form4.text_input(" ") submitted4 = form4.form_submit_button("Submit") if submitted4: st.session_state['four'] = textfour def wizard_form_footer(): form_footer_container = st.empty() with form_footer_container.container(): disable_back_button = True if st.session_state['current_step'] == 1 else False disable_next_button = True if st.session_state['current_step'] == 4 else False form_footer_cols = st.columns([5,1,1,1.75]) form_footer_cols[0].button('Cancel',on_click=set_page_view,args=['Grid']) form_footer_cols[1].button('Back',on_click=set_form_step,args=['Back'],disabled=disable_back_button) form_footer_cols[2].button('Next',on_click=set_form_step,args=['Next'],disabled=disable_next_button) ### Replace Render Wizard View With This ### def render_wizard_view(): with st.expander('',expanded=True): wizard_form_header() st.markdown('---') wizard_form_body() st.markdown('---') wizard_form_footer() render_wizard_view() st.subheader('Your resources') #st.markdown(st.session_state['one']) #st.markdown(st.session_state['two']) #st.markdown(st.session_state['three']) #st.markdown(st.session_state['four']) #sequence = "My kid will look at me when the tv is on but I'm in the other room" #sequence_labels=["Detection", "discrimination", "Identification", "Classification"] #output = classifier(sequence, sequence_labels) #st.markdown(output) with st.form("get-results"): #st.write("get results form") submitted = st.form_submit_button("Get Results") if submitted: #load everything from transformers import pipeline #define classifier for zero shot classification classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") #define sequence sequence_labels=["Detection", "Discrimination", "Identification", "Classification"] sequence = st.session_state['one'] output = classifier(sequence, sequence_labels) #st.markdown(output) df = pd.DataFrame(output) #st.markdown(df) #st.markdown("For your response: " + str(df.at[0,'sequence'])) st.markdown("Your responses indicate your child is at the " + str(df.at[0,'labels']) + " " + str(df.at[0,'scores']) + " step of auditory processing") st.markdown("Here is a link to the " + str(df.at[0,'labels']) + " resource.") #run main if __name__ == '__main__': main()