def audio_widget(key): username = st.text_input("Username", value="", key=key) uploaded_file = st.file_uploader("Choose an audio file", key=key) if uploaded_file is not None and len(username) > 0: audio_bytes = uploaded_file.read() st.audio(audio_bytes, format="audio/wav") if st.button(key): audio_path = store_bytes_as_wav(audio_bytes, username) if key == "Enroll": Model.enroll(audio_path, username) elif key == "Verify": st.write(Model.verify(audio_path, username)) remove_file(audio_path)
def enroll_user(audio: UploadFile = File(...), username: str = Form(...)): path = store_audio(audio, username) Model.enroll(path, username) clear_audio_embeddings() return "user profile added"