메뉴
HN
Hacker News 19일 전

새벽에 날 깨운 범인을 찾기 위해 AI가 만든 도구

IMP
6/10
핵심 요약

시끄러운 도심에서 밤중에 수면을 방해하는 소음의 원인을 파악하기 위해 개발자가 AI 코딩 도구를 활용해 하루 만에 스마트 홈 수면 트래킹 시스템을 구축한 후기를 공유했습니다. 라즈베리 파이와 저렴한 마이크, 스마트워치 데이터를 결합하여 수면 중 깨어난 순간의 소음을 녹음하고 분석하는 웹 앱을 AI의 도움으로 단 몇 시간 만에 완성했습니다. 이 사례는 AI 코딩 도구가 개인의 일상적인 문제를 해결하기 위한 맞춤형 프로토타입을 주말 내로 만들 수 있을 만큼 개발 생산성을 혁신했음을 보여줍니다.

번역된 본문

나는 삶의 질에 영향을 미치는 작은 요소들에 주의를 기울이려 노력합니다. 무언가가 계속 신경 쓰일 때면 그 원인을 조사하고 유력한 이유를 찾아 해결하곤 합니다. 최근 달라진 점은 이를 뒷받침하기 위해 직접 도구를 만들려는 의지입니다. AI 도구의 등장으로, 몇 년 전만 해도 '노력에 비해 얻는 게 너무 적다'며 포기했을 프로젝트들을 이제는 주말 안에 끝낼 수 있게 되었습니다. 그래서 일상에서 문제에 부딪힐 때마다 '사실 이 문제를 분석할 뭔가를 만들 수 있겠는데'라는 생각이 자연스럽게 떠오릅니다. 이 글은 바로 그런 문제 중 하나인 '수면'에 관한 이야기입니다.

문제 상황 나는 시끄러운 도시에 살고 있습니다. 어떤 밤에는 새벽 3시에 무엇 때문에 깼는지도 모른 채 눈을 뜹니다. 또 어떤 밤에는 완전히 깨지는 않지만, 다음 날 아침 스마트워치를 확인해 보면 새벽 3시 32분에 무언가가 나를 깊은 수면에서 끌어냈다는 것을 알게 됩니다. 가장 답답한 점은 원인을 거의 알 수 없다는 것입니다. 소리에 깨더라도 뇌는 아직 수면 단계에서 벗어나는 과정에 있어서 제대로 기능을 회복하는 데 시간이 걸립니다. 상황을 인지할 수 있을 때쯤이면 그 소리는 이미 사라진 뒤입니다. 그 소리가 반복되거나(천둥, 멈추지 않는 자동차 경보음) 명확한 흔적을 남기지 않는 한(천둥소리 직후의 번개 섬광) 혼란스러운 상태로 깨어나고 원인은 미스터리로 남게 됩니다. 원인을 특정하지 못하면 해결할 수도 없습니다. 집 안이었을까요? 집 밖? 이웃집? 트럭? 문 닫히는 소리? 시도하는 모든 '해결책'은 그저 찍어보는 것에 불과하고, 이런 추측은 돈만 낭비하기 쉽습니다. 그래서 나는 하나의 미션을 갖게 되었습니다 😏

내가 만든 것 (전체적인 개요) 먼저 배경 설명을 조금 하자면, 나는 이미 홈 어시스턴트(Home Assistant)와 집안 곳곳에 설치된 다수의 센서(동작 감지, 도어 센서, 조도, 온도, 습도, 이산화탄소, 공기질)를 활용하는 스마트 홈 환경을 갖추고 있습니다. 이 프로젝트에 필요한 많은 데이터가 이미 수집되고 있었습니다. 오디오 기능을 추가하고 수면 데이터를 끌어와서 이 모든 것을 하나로 묶기만 하면 되었습니다.

나는 단지 몇 가지만 추가하면 되었습니다:

  • 저렴한 USB 마이크 두 개 (하나는 집 안, 하나는 거리를 향한 창문 밖)
  • 내가 집에 있고 침대에 누워있을 때만 소리를 수신하는 라즈베리 파이(Raspberry Pi, 초소형 컴퓨터)
  • 가민(Garmin) 스마트워치의 수면 데이터
  • 오디오, 수면 데이터, 기존 센서 이벤트를 결합하는 홈랩(Home lab)의 웹 앱

라즈베리 파이가 충분히 흥미로울 만큼 큰 소리를 감지하면, 그 전후의 상황을 담은 짧은 오디오 클립을 몇 초 단위로 저장합니다. 이 감지 모드는 전적으로 홈 어시스턴트에 의해 제어됩니다. 라즈베리 파이는 홈 어시스턴트 통합 구성 요소로 노출되며, 내가 집에 있고 침대에 누워있으며 평소 수면 시간대일 때만 자동화(Automation) 기능이 이를 켭니다. 이러한 조건을 벗어나면 마이크 접근 권한이 아예 없는 완전히 비활성화 상태가 됩니다. 이는 내 개인 홈 네트워크에서조차 내가 원했던 동작 방식입니다.

이 웹 앱이 진정한 쓸모를 발휘합니다. 매일 밤의 데이터가 음악 편집기의 트랙처럼 배치됩니다. 수면 단계 트랙 하나, 심박수 및 심박수 변이도(HRV) 트랙 하나, 센서 이벤트를 위한 몇 개의 트랙, 그리고 오디오가 로드된 소음 이벤트 트랙이 그것입니다. 가장 유용한 기능은 단연 수면 단계가 바뀌거나 내가 깨어난 순간을 시각적으로 표시해 주는 것입니다. 이것이 분석의 시작점입니다. 나는 밤새 기록된 데이터를 훑어보고, (빨간색으로) 강조 표시된 순간을 찾아 클릭하여 소리를 듣습니다.

한 가지 좋은 점이 더 있습니다. 프론트엔드는 웹 푸시(Web Push)를 지원하는 프로그레시브 웹 앱(PWA) 형태로, 홈 네트워크 내에서만 서비스됩니다. 아침에 일어나 휴대폰을 확인하는 순간, 어젯밤 데이터의 분석이 완료되었다는 알림을 받게 됩니다. 어떤 데이터도 외부 네트워크로 전송되지 않으며, 나는 이 점이 매우 마음에 듭니다.

AI의 역할과 한계 기대치를 명확히 하자면, AI 덕분에 나는 이 프로젝트를 주말 안에 만드는 것이 현실적으로 가능해졌습니다. 전체 작업에는 대략 8시간이 소요되었고, 그 이후 며칠에 걸쳐 약간의 개선이 있었습니다. AI 도구가 없었다면 나는 이 프로젝트를 아예 시작조차 하지 않았을 것입니다. 하지만 (적어도 아직은) 실제 소리를 식별하는 데 AI를 사용하지는 않습니다. 문 소리인지, 그릇 부딪치는 소리인지, 오토바이 소리인지 구분해서 듣는 일은 여전히 이어폰을 낀 나의 몫입니다. 이 도구는 내가 들을 만한 가치가 있는 순간을 짚어줄 뿐입니다. 그리고 작업 흐름에 대해 한 가지 덧붙이자면, 나는 코드를 읽지 않았습니다(의도적인 선택입니다). 나는 결과를 테스트하고 이상한 점이 있으면 직접 피드백을 주었습니다.

원문 보기
원문 보기 (영어)
I try to pay attention to the small things that affect my quality of life. When something keeps bothering me, I want to investigate, find a likely cause, and act on it. What changed recently is what I'm willing to build to support that. With AI tooling, projects I would have dismissed a few years ago as "too much effort for the payoff" now fit into a weekend. So whenever I bump into a problem in my daily life, I catch myself thinking, "actually, I could build something to look into this" . This post is about one of those problems: my sleep. The problem I live in a noisy city. Some nights I wake up at 3 am with no idea what woke me up. Other nights I don't fully wake up, but my watch the next morning shows that something pulled me out of deep sleep at 3:32 am. The frustrating part is that you almost never know what caused it. When a sound wakes you up, your brain is still transitioning out of whatever sleep stage you were in, and it takes a moment to come back online properly. By the time you can register what's happening, the noise is already gone. Unless it repeats (thunder, car alarm that won't stop) or leaves a clue afterwards (a flash of lightning following the boom) , you wake up confused and the cause stays a mystery. And without naming the cause, you can't fix it. Was it inside the flat? Outside? A neighbor? A truck? A door? Any "solution" you try is just a guess, and guessing tends to be expensive. So I was on a mission 😏 What I built, at a high level One bit of context first: I already have a smart home setup with Home Assistant and a bunch of sensors around the flat (motion, doors, lights, temperature, humidity, CO₂, air quality) . A lot of the data I needed for this project was already being collected. I only had to add the audio piece, pull in my sleep data, and tie everything together. I only needed to add a few things: Two cheap USB microphones, one inside the flat and one outside the window facing the street A Raspberry Pi (micro-computer) that listens, but only when I'm at home and in bed Sleep data from my Garmin* watch A web app on my home lab that combines the audio, the sleep data, and the existing sensor events When the Pi hears something loud enough to be interesting, it saves a short clip with a few seconds of context before and after. The whole detection mode is gated by Home Assistant: the Pi exposes itself as a Home Assistant integration, and an automation only switches it on when I'm at home, in bed, and around my usual sleep time. Outside of those conditions, it's completely disabled, no microphone access at all. That's the behavior I wanted, even on my own home network. The web app is where the actual usefulness happens. Each night is laid out like tracks in a music editor: one for sleep stages, one for heart rate and HRV, a few for the sensor events, and one for the noise events with the audio loaded in. The most useful feature, by far, is how it visually marks the moments where my sleep stage shifted or I woke up. That's the entry point. I scan a night, find the highlighted moments (in red) , and click to listen. One more nice touch: the frontend is a progressive web app with web push, served only inside my home network. The moment I wake up and check my phone, I get a notification that last night's data is ready to review. Nothing leaves the network, which I really like. What AI did, and what it didn't To set expectations clearly: AI is what made it realistic for me to build this in a weekend. The whole thing took roughly 8 hours of work, plus a few small improvements over the following days. Without AI tooling, I would not have started. But I'm not using AI to identify the actual sounds (at least, not yet) . The listening part, recognizing a door vs. dishes vs. a motorbike, is still me with headphones on. The tool just points me at the moments worth listening to. And on the workflow: I didn't read the code (conscious choice) . I tested the results, gave direct feedback when something was off, and let the AI verify its own output by letting it take screenshots of the running app in my browser. For the micro-computer side, I went one step further. The Raspberry Pi was a fresh, empty install, so I gave the coding agent SSH access and let it test things directly on the device. It would set up an experiment, ask me to shout, drop something, or run the kitchen tap, record the sample, and then analyze it for me, sometimes pulling out spectrograms. I had to be explicit about wanting it to work this way, but once instructed, the iteration loop was honestly quite fun. For a personal project running on my own hardware, this whole setup was enough. The interesting shift here isn't that AI solved my problem. It's that AI lowered the cost of building the thing that lets me solve my own problem. A note on the sleep data I get the sleep data from my Garmin* watch. Every watch and ring calculates sleep slightly differently, and to be honest, I don't fully trust any of them on the exact sleep stage I was in at any given second. What they're all reasonably good at, though, is detecting when you actually woke up. Those wake events, plus the rough transitions between stages, are what I actually care about here. They're not a clinical truth. They're visual markers that tell me "this moment is worth investigating" . Without them, I'd be sitting through hours of audio of the fridge humming and a neighbor doing nothing in particular. I'm not trying to do sleep science. I'm trying to find what sometimes made me feel rough in the morning. What I found, and what I did about it Once I started actually using this, the patterns came out fast. The usual suspects: Doors. A neighbor's door slamming, or someone in the flat going to the bathroom and not being especially careful with the door. Dishes. They make a high-pitched, sharp sound that travels surprisingly well through a flat, whether it's coming from our own kitchen or a neighbor's. The street. Motorbikes, scooters, trucks, and the trash collection truck passing by.. (guess the country I live in) Occasionally, things from inside that I had blamed on outside (and the other way around) . With actual data, I could finally act with some confidence instead of guessing: I added proper acoustic panels (the IKEA ones for offices to create meeting areas work surprisingly well) I added extra insulation around the bedroom door and the window (silicone, rubber, ...) For some of the inside noises, the fix was less about hardware and more about a small conversation 😄 It's not perfect (cities are cities) , but the difference shows up both in how I feel in the morning and in the Garmin* data over time. For the curious: how it actually works under the hood A bit more detail for anyone interested in the tech: The Pi continuously records into a rolling in-memory buffer (only while detection is enabled via Home Assistant) . Nothing hits disk until the volume crosses a threshold. There's a noise suppression profile on top of the input that tries to keep the ambient noise floor as low as possible . It mostly filters out the constant background stuff (distant traffic hum, the fridge, that kind of thing) so the threshold doesn't trigger on it. This cut down on false positives a lot. When the threshold is crossed , the snippet (with pre- and post-context) is saved with a timestamp, and a small JSON file tracks the events. The snipped is also compressed into a smaller audio file to be able to store multiple nights’ worth of data. A tiny web server on the Pi exposes the noise events and audio clips to my web app, plus a separate token-authorized control endpoint for changing the recording state. That control endpoint is consumed by a small custom Home Assistant integration I let the coding agent write . The integration is what lets my Home Assistant automations actually flip detection on or off. Sleep data from Garmin*: there are good open-source libraries that handle Garmin Connect authentication. A small job runs an