import streamlit as st import datasets import numpy as np import soundfile as sf def show_examples(category_name, dataset_name, model_lists): st.divider() sample_folder = f"./examples/{category_name}/{dataset_name}" dataset = datasets.load_from_disk(sample_folder) for index in range(len(dataset)): with st.expander(f'EXAMPLE {index+1}'): col1, col2 = st.columns([0.3, 0.7], vertical_alignment="center") with col1: st.audio(f'{sample_folder}/sample_{index}.wav', format="audio/wav") with col2: with st.container(): custom_css = """ """ st.markdown(custom_css, unsafe_allow_html=True) st.markdown(f"""

QUESTION: {dataset[index]['instruction']['text']}

""", unsafe_allow_html=True) with st.container(): custom_css = """ """ st.markdown(custom_css, unsafe_allow_html=True) st.markdown(f"""

CORRECT ANSWER: {dataset[index]['answer']['text']}

""", unsafe_allow_html=True) st.divider() with st.container(): custom_css = """ """ st.markdown(custom_css, unsafe_allow_html=True) model_lists.sort() s = '' for model in model_lists: try: s += f""" {model} {dataset[index][model]['text']} {dataset[index][model]['model_prediction']} """ except: print(f"{model} is not in {dataset_name}") continue body_details = f""" {s}
MODEL QUESTION MODEL PREDICTION
""" st.markdown(f"""
{body_details}
""", unsafe_allow_html=True) # st.markdown(body_details, unsafe_allow_html=True)