shiihaa Breath Detection: Live Biofeedback via Phone Microphone
Real-time Breath Detection via Mobile Microphones
shiihaa breath detection is an on-device system designed to provide live biofeedback by estimating a user's breathing phases—inhale, exhale, and transitions—using only a smartphone microphone. Unlike many mindfulness applications that act as distractions, this system aims to increase self-awareness by reflecting the user's own breathing patterns back to them in real time.
Technical Architecture of the Detection Pipeline
The system processes audio signals through three distinct layers to isolate breathing patterns from environmental noise.
1. Signal Processing
The audio stream is divided into short, overlapping windows. For each window, the system derives an amplitude/energy measure and basic spectral features. The detection relies on the fact that inhalations typically exhibit more turbulence and higher frequency energy, while exhalations are generally lower and smoother in the spectrum.
2. Breathing State Machine
To prevent erratic phase switching, the system uses a state machine rather than deciding the phase for each window in isolation. This machine tracks plausible transitions (e.g., inhale $\rightarrow$ exhale) and employs adaptive thresholds that recalibrate as ambient noise levels drift, allowing the system to distinguish genuine phase changes from momentary audio spikes.
3. Data-Quality Layer
To ensure reliability, a quality-check layer rejects windows that are too noisy, too quiet, or acoustically ambiguous. The system is designed to "fail honestly," preferring a brief period of uncertainty over providing a confident but incorrect phase detection.
Privacy and Data Constraints
The project implements strict privacy boundaries to ensure the microphone is not used for surveillance or speech recognition:
- On-Device Processing: All audio is analyzed locally; raw microphone streams never leave the device.
- No Speech Analysis: The pipeline focuses on the energy envelope and spectral shape of breathing; it is not built to recognize or transcribe spoken words.
- Bounded Machine Learning: ML is used only to refine the rule-based pipeline and sharpen feedback based on quality-checked examples, rather than serving as a "black box" for the primary detection.
Real-World Implementation Challenges
Developing the system required significant engineering effort to handle mobile audio quirks, including varying microphone placements, automatic gain control (AGC) interference, and the physical orientation of the phone (e.g., resting on fabric versus being held in a hand).
Future Directions: Personal Resonance Range
The long-term goal is to estimate a user's "personal resonance range"—the specific slow breathing pace (often near six breaths per minute) where an individual's physiology settles most. By combining detected breath stability with optional heart rate or HRV sensors, the system aims to adapt guided breathing patterns to the individual's physiology rather than relying on fixed presets.
Community Insights and Limitations
The project is currently a wellness tool and not a medical device. The author notes that microphone-only detection in uncontrolled environments is significantly more difficult than wearable-based detection.
Community feedback highlights the difficulty of this approach, with one developer noting:
"A microphone in itself wasn't sufficient in my case, and detection was quite hard. I ended up using wired earbuds with microphones."
Other users reported regional availability issues with the app in the Netherlands and Germany. The project documentation and research pitch are available via the shiihaa-app GitHub repository under a CC BY 4.0 license.