CoolFace
Apppublic

aseveryn/alc-data-collection

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

ALC Data Collection App

A mobile-optimized web app for collecting sober and intoxicated speech recordings, designed for evaluating the ALC intoxication detection model beyond the original German-only corpus.

Why We Collect This Data

The ALC model detects alcohol intoxication by comparing a speaker's sober baseline voice against a test recording. It learns acoustic changes — pitch, articulation rate, speech errors — rather than absolute voice properties. This pairwise approach is why we need both sober and intoxicated recordings from the same person, using the same device and environment when possible.

Why a sober baseline?

The model uses a Siamese architecture: it takes a sober reference and a test sample, encodes both, and classifies based on the difference. Without a sober baseline, the model has no anchor — it would need to learn what "sober" sounds like for every speaker, which varies enormously across individuals, languages, and recording conditions.

Why 30+ seconds?

The model processes audio in 5-second windows and uses majority voting across multiple windows to make a prediction. Longer recordings yield more windows, which means more stable and accurate votes. At 30 seconds we get 5-6 windows — enough for a reliable majority vote. Shorter recordings risk unstable predictions.

Why multiple BAK levels?

Recording the same person at different blood alcohol concentrations (e.g., 0.5‰, 1.0‰, 1.5‰) enables dose-response analysis: how does detection accuracy vary with intoxication level? This also helps calibrate model confidence thresholds.

UI Flow

Home Screen

Shows collection stats (participants, baseline sessions, intoxicated sessions, total recordings) and three actions:

  • Register + Record Baseline — new participant
  • Look Up Participant — returning participant for intoxicated recording
  • All Participants — overview of everyone and their session counts

Flow 1: Register + Sober Baseline

Home → Register → BAK Entry (pre-filled 0.00) → Record [Reading] → Record [Free Speech] → Done
  1. 1.Register: enter nickname (auto-suggested), age, sex, mother tongue, recording language, nationality, environment. Form defaults are remembered across sessions via localStorage.
  2. 2.BAK Entry: pre-filled with 0.00 for sober baseline. Language and environment are pre-filled from registration (collapsed, editable).
  3. 3.Record: two tasks in sequence — reading passage then free speech. The passage and prompt are displayed in the recording language (8 languages supported). Auto-save mode advances to the next task automatically.

Flow 2: Intoxicated Recording

Home → Look Up → Select Participant → BAK Entry → Record [Reading] → Record [Free Speech] → Done
  1. 1.Look Up: search by nickname. The list shows each participant's sober/intoxicated session counts.
  2. 2.BAK Entry: enter the breathalyzer reading (e.g., 0.85). Language and environment default to previous values.
  3. 3.Record: same two tasks. Can be repeated at different BAK levels — each level is a separate session.

Recording Page

  • Large circular REC button — tap to start/stop
  • Reading passage or free speech prompt displayed in the recording language
  • Timer shows elapsed time
  • Auto-save: when enabled, recordings save automatically and advance to the next task
  • Wake Lock: screen stays on during recording
  • Haptic feedback: vibration on start/stop (on supported devices)
  • Recordings can be deleted and re-recorded if needed
  • Session history shows all sessions for the participant

Data Model

Participant (1) ──→ (N) Session (1) ──→ (N) Recording
  • Participant: ID, nickname, age, sex, mother tongue, languages, nationality
  • Session: linked to participant, has a type (sober/intoxicated), BAK reading, language, environment
  • Recording: linked to session, has a task type (reading/free_speech), audio filename, duration, notes

Data Persistence

  • SQLite database (participants.db): stores all participant, session, and recording metadata
  • Audio files: saved as WebM in the audio/ directory, named {participant_id}_{session_type}_{task}_{timestamp}_{recording_id}.webm
  • Data directory: configurable via ALC_DATA_DIR env var (defaults to ./collected_data/, set to /data in Docker for HF Spaces persistent storage)
  • Export: GET /api/export returns all metadata as JSON for backup/analysis

Deployment

Local

bash
pip install -r requirements.txt
python app.py
# → http://localhost:5000

HuggingFace Spaces (Docker)

The app runs as a Docker Space on HuggingFace:

bash
./deploy_hf.sh   # syncs files and pushes to HF Space

Configuration on HF Spaces:

  • Secret ALC_PASSWORD: enables basic auth (login page shown if set)
  • Persistent storage: must be enabled so data survives container restarts (stored at /data)

Environment Variables

VariableDefaultPurpose
ALC_DATA_DIR./collected_data/Directory for SQLite DB and audio files
ALC_PASSWORD(none)Enables basic auth if set
ALC_DEBUG0Set to 1 for Flask debug mode
PORT5000Server port (7860 in Docker for HF Spaces)

Supported Languages

Reading passages and free speech prompts are available in: English, German, Russian, Georgian, Ukrainian, French, Spanish, and Chinese (Mandarin).