Spaces:
Sleeping
Sleeping
File size: 5,565 Bytes
7a152c6 5a0849d 7a152c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
import streamlit as st
from PIL import Image
import pandas as pd
import os
import json
import csv
st.header("Practice Section")
# Replace this with the directory containing the sample audio files
PRACTICE_AUDIO_DIR = 'audio/'
# Replace this with the excel file (converted to csv) that contains the answers.
practice_data = pd.read_csv('practice-quiz.csv')
for practice in practice_data.index:
ann_id = practice_data.loc[practice, 'naijavoices_audio_filename']
# st.write(f'## Practice Audio: {practice_data.loc[practice, "text"]}')
with st.expander(f'Click to view evaluation task'):
with st.form(key=f'practice-{ann_id}'):
st.caption(":red[Instruction: first read the transcript carefully. Then listen to the audio thoroughly (can listen multiple times), before proceeding to answer the following questions. While answering the questions, come back to listen to the audio again as needed.]")
st.write(f'## {practice_data.loc[practice, "text"]}')
path = os.path.join(PRACTICE_AUDIO_DIR+f'{practice_data.loc[practice, "language"]}', practice_data.loc[practice, 'naijavoices_audio_filename'])
print(path)
st.audio(path)
score = 0
min_score = 10
if practice_data.loc[practice, "Marker"] == 'Alignment':
alignment = st.radio(
"Select the option that best describes the alignment of the audio and transcript",
options=["Audio contains EXTRA words not in the transcript", "Audio is MISSING words that are in the transcript", "Audio is MISSING words AND includes EXTRA words", "No missing or extra words"],
index=None,
key=f'{ann_id}-alignment'
)
submit_practice_button = st.form_submit_button(label='Submit')
if submit_practice_button:
if alignment == practice_data.loc[practice, "correct_alignment"]:
feedback = "Alignment: β
Correct"
score +=1
else:
feedback = f"Alignment: β Incorrect. Correct answer: {practice_data.loc[practice, 'correct_alignment']}"
st.write("### Feedback")
st.write(feedback)
elif practice_data.loc[practice, "Marker"] == 'Pronunciation':
pronunciation = st.radio(
"How accurate is the pronunciation?",
options=["1: Very Inaccurate", "2: Inaccurate", "3: Neutral", "4: Accurate", "5: Very Accurate"],
index=None,
key=f'{ann_id}-pronunciation'
)
submit_practice_button = st.form_submit_button(label='Submit')
if submit_practice_button:
if pronunciation == practice_data.loc[practice, "correct_pronunciation"]:
feedback = "Pronunciation: β
Correct"
score += 1
else:
feedback = f"Pronunciation: β Incorrect. Correct answer: {practice_data.loc[practice, 'correct_pronunciation']}"
st.write("### Feedback")
st.write(feedback)
elif practice_data.loc[practice, "Marker"] == 'Naturalness':
naturalness = st.radio(
"How natural does the audio sound?",
options=["1: Very Unnatural", "2: Unnatural", "3: Neutral", "4: Natural", "5: Extremely Natural"],
index=None,
key=f'{ann_id}-naturalness'
)
submit_practice_button = st.form_submit_button(label='Submit')
if submit_practice_button:
if naturalness == practice_data.loc[practice, "correct_naturalness"]:
feedback = "Naturalness: β
Correct"
score += 1
else:
feedback = f"Naturalness: β Incorrect. Correct answer: {practice_data.loc[practice, 'correct_naturalness']}"
st.write("### Feedback")
st.write(feedback)
elif practice_data.loc[practice, "Marker"] == 'Emotion':
emotion = st.radio(
"How expressive is the audio?",
options=["1: No Emotional Expressiveness", "2: Slightly Expressive", "3: Moderately Expressive", "4: Expressive", "5: Highly Expressive and Appropriate"],
index=None,
key=f'{ann_id}-emotion'
)
submit_practice_button = st.form_submit_button(label='Submit')
if submit_practice_button:
if emotion == practice_data.loc[practice, "correct_emotion"]:
feedback ="Emotion: β
Correct"
score += 1
else:
feedback = f"Emotion: β Incorrect. Correct answer: {practice_data.loc[practice, 'correct_emotion']}"
st.write("### Feedback")
st.write(feedback)
# Check if the evaluator passes the practice
if score >= min_score:
st.write(f'β
Practice Passed! Your Score: {score}/{len(practice_data)}')
passed_practice = True
else:
st.write(f'β οΈ Your score is {score}/{len(practice_data)}. Please retry the evaluations again before proceeding.')
|