feat: add storage and training modules for snore detection
- Implemented `storage.py` for managing metadata storage, including sample addition, retrieval, and review state management. - Created `training.py` for training a local model using Random Forest, including functions for training and predicting samples. - Developed a web interface in `app.js` for capturing audio samples, managing labels, and training the model. - Added HTML structure in `index.html` for the SnoreStopper control room with sections for sample capture, overnight gathering, training, and status display. - Styled the application with `styles.css` to enhance user experience and interface aesthetics.
This commit is contained in:
383
web/styles.css
Normal file
383
web/styles.css
Normal file
@@ -0,0 +1,383 @@
|
||||
:root {
|
||||
--bg-a: #0b2238;
|
||||
--bg-b: #153a2e;
|
||||
--panel: rgba(255, 255, 255, 0.92);
|
||||
--ink: #112333;
|
||||
--ink-soft: #35516b;
|
||||
--accent: #0d8d72;
|
||||
--accent-strong: #096f5a;
|
||||
--outline: rgba(17, 35, 51, 0.16);
|
||||
--danger: #b14d40;
|
||||
--success: #198754;
|
||||
--success-strong: #146c43;
|
||||
--danger-strong: #9f2f24;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: "Chakra Petch", "Segoe UI", sans-serif;
|
||||
color: var(--ink);
|
||||
min-height: 100vh;
|
||||
background: radial-gradient(circle at 20% 10%, #245f7e 0%, transparent 45%),
|
||||
radial-gradient(circle at 85% 20%, #2c6f47 0%, transparent 50%),
|
||||
linear-gradient(145deg, var(--bg-a), var(--bg-b));
|
||||
}
|
||||
|
||||
.ambient-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background-image: linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
|
||||
linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
|
||||
background-size: 22px 22px;
|
||||
opacity: 0.42;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.layout {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: min(1200px, 92vw);
|
||||
margin: 2rem auto 3rem;
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
grid-template-columns: repeat(12, minmax(0, 1fr));
|
||||
animation: fade-in 500ms ease;
|
||||
}
|
||||
|
||||
.hero,
|
||||
.panel {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--outline);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 18px 30px rgba(9, 20, 28, 0.16);
|
||||
}
|
||||
|
||||
.hero {
|
||||
grid-column: 1 / -1;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
margin: 0.3rem 0 0.5rem;
|
||||
font-size: clamp(2rem, 4vw, 2.8rem);
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.hero p {
|
||||
margin: 0;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 0.9rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
color: var(--accent-strong);
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 1.2rem;
|
||||
}
|
||||
|
||||
.controls {
|
||||
grid-column: span 6;
|
||||
}
|
||||
|
||||
.overnight {
|
||||
grid-column: span 6;
|
||||
}
|
||||
|
||||
.training {
|
||||
grid-column: span 8;
|
||||
}
|
||||
|
||||
.status {
|
||||
grid-column: span 4;
|
||||
}
|
||||
|
||||
.samples {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.pending {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0 0 0.8rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
margin-bottom: 0.85rem;
|
||||
}
|
||||
|
||||
.split {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.overnight-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
.toggle-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin: 0.45rem 0 0.9rem;
|
||||
font-size: 0.92rem;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.toggle-row input {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
label {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 0.8rem;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
input,
|
||||
select,
|
||||
button {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
input,
|
||||
select {
|
||||
width: 100%;
|
||||
border: 1px solid var(--outline);
|
||||
border-radius: 10px;
|
||||
padding: 0.55rem 0.7rem;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border: 1px solid var(--outline);
|
||||
border-radius: 10px;
|
||||
padding: 0.55rem 0.8rem;
|
||||
background: #ecf3f7;
|
||||
color: var(--ink);
|
||||
cursor: pointer;
|
||||
transition: transform 120ms ease, background 120ms ease;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-1px);
|
||||
background: #dfeaf1;
|
||||
}
|
||||
|
||||
.btn.primary {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn.primary:hover {
|
||||
background: var(--accent-strong);
|
||||
}
|
||||
|
||||
.btn.success {
|
||||
background: var(--success);
|
||||
border-color: var(--success);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn.success:hover {
|
||||
background: var(--success-strong);
|
||||
}
|
||||
|
||||
.btn.danger {
|
||||
background: #c0392b;
|
||||
border-color: #c0392b;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn.danger:hover {
|
||||
background: var(--danger-strong);
|
||||
}
|
||||
|
||||
.btn.ghost {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.output {
|
||||
margin: 0.8rem 0 0;
|
||||
padding: 0.8rem;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--outline);
|
||||
background: #f4f8fb;
|
||||
color: #1b384f;
|
||||
min-height: 72px;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.samples-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0.8rem;
|
||||
}
|
||||
|
||||
.sample-list,
|
||||
.pending-list {
|
||||
display: grid;
|
||||
gap: 0.85rem;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
border: 1px solid var(--outline);
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
padding: 0.9rem;
|
||||
display: grid;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.record-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.record-header code {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 0.78rem;
|
||||
background: #eff5f9;
|
||||
border-radius: 8px;
|
||||
padding: 0.2rem 0.45rem;
|
||||
}
|
||||
|
||||
.meta-text {
|
||||
color: var(--ink-soft);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.chip {
|
||||
border: 1px solid var(--outline);
|
||||
border-radius: 999px;
|
||||
background: #f3f8fb;
|
||||
color: #23475f;
|
||||
padding: 0.2rem 0.55rem;
|
||||
font-size: 0.78rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.proposal-chip {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
}
|
||||
|
||||
.record-media {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(180px, 230px) minmax(180px, 240px);
|
||||
gap: 0.8rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.record-meta-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.7rem;
|
||||
}
|
||||
|
||||
.record-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.6rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.record-actions .actions {
|
||||
border: 1px solid var(--outline);
|
||||
border-radius: 10px;
|
||||
background: #fbfdff;
|
||||
padding: 0.45rem;
|
||||
}
|
||||
|
||||
img.spectrogram {
|
||||
width: min(220px, 100%);
|
||||
height: auto;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--outline);
|
||||
}
|
||||
|
||||
audio {
|
||||
width: min(230px, 100%);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
margin: 0;
|
||||
border: 1px dashed var(--outline);
|
||||
border-radius: 10px;
|
||||
background: #f8fbfd;
|
||||
color: var(--ink-soft);
|
||||
padding: 0.9rem;
|
||||
}
|
||||
|
||||
.status-error {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.status-ok {
|
||||
color: var(--accent-strong);
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.controls,
|
||||
.overnight,
|
||||
.training,
|
||||
.status {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.split {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.overnight-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.record-media {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
img.spectrogram,
|
||||
audio {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user