Home

Development of Snoring Monitor App

The development of my snoring monitor app was a process marked by a series of challenges, learning experiences, and iterative improvements. The goal was to design an app that could monitor snoring at night using microphone data, process the sound signals, and display snoring information in a user-friendly interface. This narrative highlights the key steps I took, the hurdles I encountered, and the solutions I implemented to refine the app.

The initial setup phase presented some challenges, primarily related to the installation of Python and the necessary libraries. Installing libraries like pySerial, pyAudio, and pyhjtson was not always straightforward. I ran into compatibility issues between the versions of Python and the libraries I was using, particularly with pyAudio. The installation process for pyAudio required specific dependencies, and I had to ensure that the correct versions were installed. Moreover, on some systems, microphone access permissions had to be configured properly to allow the app to capture audio input. Despite these hurdles, I managed to overcome the installation issues by ensuring all dependencies were correctly handled and updated.

The first stage of coding focused on the microphone data collection. The idea was to capture audio signals from the microphone, process the data, and extract useful features that could help detect snoring events. Initially, I used a basic framework to record audio from the microphone and save it as a raw signal. However, the main challenge at this stage was processing the raw audio data and converting it into something meaningful for snoring detection. The microphone’s sensitivity and the varying intensity of snoring made it difficult to separate relevant sounds from background noise, leading to inaccurate or inconsistent detection. I experimented with different methods for processing the sound, such as noise filtering, but struggled to find a reliable approach that worked across different environments and conditions.

One of the most significant setbacks came when I encountered issues with the libraries used for sound processing. I tried multiple libraries, such as pyAudio and numpy, to handle the audio data, but performance and compatibility issues arose frequently. pyAudio sometimes failed to capture the microphone input correctly, while numpy was sometimes inefficient for the volume of data I was trying to process. After debugging these issues, I learned that I needed a more specialized library to filter out background noise and capture only the snoring sound signals. Eventually, I resolved this by introducing a combination of pydub and scipy, which provided more precise control over the audio signal processing. This library combination allowed me to implement better noise reduction algorithms and improved the overall accuracy of snoring detection.

Error message related to microphone access

Throughout the development process, I encountered numerous error messages that required careful debugging. One such issue occurred when trying to integrate the microphone input with the Kivy framework for the app’s user interface. I received error messages related to missing components in Kivy, such as ModuleNotFoundError when trying to import kivy.uix.graph, which was required for displaying the snoring data graphically. This issue arose due to missing or incompatible library versions. After resolving the dependencies and ensuring Kivy was correctly installed, I faced issues with the microphone’s connection to the app. The microphone input was not being captured properly, which led to error messages related to device access. Through trial and error, I identified the issue as a permission problem in the system’s audio settings and rectified it by adjusting the access permissions.

Error message related to microphone access

Another error occurred when the app would occasionally fail to process the microphone data due to performance issues with real-time audio streaming. The error would stop the data processing, and I could not display the graph or update the sound data in real-time. After reviewing the code, I identified inefficiencies in how the data was being buffered and processed. By implementing a more efficient buffer and using threading to handle the real-time audio stream, I resolved the issue and significantly improved the app’s performance.

Error message related to data processing

Once the major issues with microphone access and audio processing were addressed, I moved into the refinement phase. The user interface was initially basic, featuring only a simple graph to display the snoring data. I iterated on the design to make it more user-friendly by adding features such as labels showing the highest snore intensity and the exact time of occurrence. The graph itself was also refined, with improvements in the x-axis to represent a 12-hour section from 6 PM to 6 AM, corresponding to typical sleeping hours.

I also added functionality for saving the data to a JSON file, allowing users to store their snoring data and access it later through buttons labeled "Previous" and "Next." This functionality was designed to allow users to track their snoring patterns over time. The snoring detection algorithm was continuously improved, with adjustments made to the sensitivity and filtering parameters to ensure that snoring sounds were accurately captured and represented.

The final version of the app was functional and efficient. The app's main flow involved capturing microphone data, processing it to detect snoring, and displaying the results on a user-friendly interface. The microphone input was captured in real-time, and the data was processed to detect snoring events based on sound intensity. The data was displayed in a graph, with the highest snore intensity and the time it occurred clearly shown. Users could save and load past snoring data through the “Save”, “Previous”, and “Next” buttons. The app was designed to monitor snoring across a 12-hour night cycle, displaying data from 6 PM to 6 AM.

Snoring Monitor App Interface

In the final iteration, optimizations were made to improve the overall performance, particularly in terms of handling microphone data in real-time. The code was cleaned up, and unnecessary complexity was removed, making the app more efficient. I also fine-tuned the sensitivity of the snoring detection algorithm to better differentiate between snoring and other environmental sounds.

The development of the snoring monitor app was a process of trial, error, and learning. From initial setup challenges with Python libraries to refining the user interface and optimizing the app’s performance, each step required persistence and adaptation. The final working version of the app successfully monitors snoring patterns, provides valuable feedback to users, and allows them to track their snoring over time. While there were numerous obstacles along the way, the project was ultimately a success, with each challenge providing valuable insights into app development and sound processing.