auditory / app.py
aftersix
adding presidio
1cc6ea3
import streamlit as st
import streamlit as st
from st_aggrid import AgGrid
import pandas as pd
#for the PII masking
#resource list to display after the assessment is complete
resourceList = pd.read_csv('resources.csv')
import csv
prompts = []
questions = []
details = []
with open('auditorytext.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
x=0
for row in reader:
#print(row['\ufeffno'], row['question'],x)
questions.insert(x,row['question'])
prompts.insert(x,row['prompt'])
x=x+1
#set page config
st.set_page_config(page_title='auditory skills resources', page_icon='icon-128x128.png')
#masking set up
# Call analyzer to get results
#define session variables
if 'one' not in st.session_state:
st.session_state['one'] = '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():
x=0
assessment = []
while x < 36:
assessment.insert(x,False)
x=x+1
st.header("Auditory Skills Assessment")
st.markdown("Auditory skill development is an important way to ensure that a child is using their hearing technology as part of communication. Auditory skills follow a specific path of development and our assessment helps you know how to incorporate language and other audio into your child's development.")
st.subheader("How it works")
st.markdown("""You can get your personalized set of recommendations in three steps: </br>
1. ***Skills Identification*** - Answer 35 different questions to identify which auditory skills your child has. </br>
2. ***Development Assessment*** - Provide a bit more information about each skill in order to allow our AI to compare your child to our dataset to match the right resources to your child's current phase of development.</br>
3. ***Get Results*** - Get your assessment results and resources to use with your child.</br> """,unsafe_allow_html=True)
with st.expander('Skills Identification'):
st.markdown('Check the box to answer "yes" to each question')
assessment[0] = st.checkbox('Does your child respond to a familiar voice?')
assessment[1] = st.checkbox('Does your child listen to somebody speaking?')
assessment[2] = st.checkbox('When somebody is speaking, does your child turn their head towards the speaker?')
assessment[3] = st.checkbox('Is your child interested in toys producing sounds or music?')
assessment[4] = st.checkbox('Does your child look for a speaker they cannot see?')
assessment[5] = st.checkbox('Does your child listen when the radio/CD/tape player is turned on?')
assessment[6] = st.checkbox('Does your child respond to distant sounds?')
assessment[7] = st.checkbox('Does your child stop crying when you speak to them without them seeing you?')
assessment[8] = st.checkbox('Does your child respond with alarm when hearing an angry voice?')
assessment[9] = st.checkbox('Does your child "recognize" acoustic rituals?')
assessment[10] = st.checkbox('Does your child look for sound sources located at the left, right, or back?')
assessment[11] = st.checkbox('Does your child react to their name?')
assessment[12] = st.checkbox('Does your child look for sound sources located above or below?')
assessment[13] = st.checkbox('When your child is sad or moody, can they be calmed down or influenced by music?')
assessment[14] = st.checkbox('Does your child listen on the telephone and do they seem to recognize that somebody is talking?')
assessment[15] = st.checkbox(' Does your child respond to music with rhythmical movements?')
assessment[16] = st.checkbox(' Does your child know that a certain sound is related to a certain object or event?')
assessment[17] = st.checkbox(' Does your child appropriately respond to short and simple remarks?')
assessment[18] = st.checkbox('Does your child respond to "no" by typically interrupting their current activity?')
assessment[19] = st.checkbox('Does your child know family members names?')
assessment[20] = st.checkbox(' Does your child imitate sound when asked?')
assessment[21] = st.checkbox(' Does your child follow simple commands?')
assessment[22] = st.checkbox(' Does your child understand simple questions?')
assessment[23] = st.checkbox('Does your child bring items when asked?')
assessment[24] = st.checkbox('Does your child imitate sounds or words you say? ')
assessment[25] = st.checkbox('Does your child produce the right sound to a toy?')
assessment[26] = st.checkbox('Does your child know that certain sounds go with certain animals?')
assessment[27] = st.checkbox('Does your child imitate environmental sounds?')
assessment[28] = st.checkbox('Does your child correctly repeat a sequence of short and long syllables you have said?')
assessment[29] = st.checkbox('Does your child select the right object from a number of objects when asked?')
assessment[30] = st.checkbox('Does your child try to sing along when hearing a song?')
assessment[31] = st.checkbox('Does your child repeat certain words when asked?')
assessment[32] = st.checkbox('Does your child like being read to?')
assessment[33] = st.checkbox('Does your child follow complex commands?')
assessment[34] = st.checkbox('Does your child try to sing along with familiar songs?')
with st.expander('Tell us more about how your child responds to sound'):
x=0
while x < 35:
if assessment[x]!=False:
input = st.text_input(prompts[x])
details.insert(x,input)
else:
details.insert(x,"none")
x=x+1
#print(details)
with st.expander('Get resources here'):
with st.form("get-results"):
submitted = st.form_submit_button("Get Results")
if submitted:
#load everything
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
analyzer = AnalyzerEngine()
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", "COMPREHENSION"]
x=0
print('start loop')
while x < 35:
if details[x] != "none":
st.markdown(questions[x])
text=details[x]
results = analyzer.analyze(text=text,
language='en')
anonymizer = AnonymizerEngine()
anonymized_text = anonymizer.anonymize(text=text,analyzer_results=results)
maskedText = anonymized_text.text
st.markdown("**"+maskedText+"**")
sequence = details[x]
print(details[x])
output = classifier(sequence, sequence_labels)
#get row category for lookup in resources.csv
rowCategory = str(x)+output['labels'][0]
print(rowCategory)
#look up resources list in csv file
for ind in resourceList.index:
if resourceList["no"][ind].astype(str) + resourceList["category"][ind] == rowCategory:
showResource = resourceList["link"][ind]
print(resourceList["link"][ind])
st.markdown("For this skill, your child's auditory skill level is: " + str(output['labels'][0]) + ", the best resource to use to work on your child's language development is: " + showResource)
x=x+1
#run main
if __name__ == '__main__':
main()