import streamlit as st from st_audiorec import st_audiorec import matplotlib.pyplot as plt import sounddevice as sd import numpy as np import pandas as pd import torch # import torchaudio import wave import io from scipy.io import wavfile import pydub import time import os import atexit import librosa # MODEL LOADING and INITIALISATION def load_model(): model = torch.jit.load("snorenetv1_small.ptl") model.eval() return model model = load_model() # Audio parameters def process_data(waveform_chunks): snore = 0 other = 0 for chunk in waveform_chunks: input_tensor = torch.tensor(chunk).unsqueeze(0).to(torch.float32) # st.write(input_tensor[0][98]) result = model(input_tensor) # st.write(result) if np.abs(result[0][0]) > np.abs(result[0][1]): other += 1 else: snore += 1 return snore, other st.sidebar.markdown( """
Transform your sleep experience with the cutting-edge Snore Detector by Hypermind Labs! Discover the power to monitor and understand your nighttime sounds like never before. Take control of your sleep quality and uncover the secrets of your peaceful slumber with our innovative app.