White noise sound equipment sleep detection and volume gradually-decreasing control method based on sensor
By combining a single microphone and an LSTM-Transformer neural network with a DSP chip to implement a volume gradually decreasing control method, the problem of intelligent sleep detection and volume adjustment in white noise audio systems under complex environments has been solved, improving the user experience and reducing system complexity.
Patent Information
- Application Number
- CN202511455523.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2025-11-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing white noise sound systems lack intelligent sleep detection functions and cannot automatically adjust the volume according to the user's actual sleep state. In particular, in complex home environments, background noise and user activity sounds are mixed together, which seriously affects the reliability of detection.
A single-microphone configuration is used in conjunction with a sound energy attenuation detection algorithm (SEDA) and a three-layer LSTM-Transformer neural network architecture. The spectral modulation parameters are calculated through temporal pattern recognition and auditory masking characteristics, and the volume is gradually reduced by using a DSP chip to perform FFT/IFFT transformation.
It enables personalized sleep detection and volume control, improves the user experience of white noise speakers, reduces system costs and hardware complexity, avoids misjudgment and nonlinear distortion in traditional methods, and provides dynamic feedback control and adaptive adjustment.
Smart Images

Figure CN120980404A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of white noise audio technology, and in particular to a sensor-based method for detecting sleep onset and gradually reducing the volume of white noise audio. Background Technology
[0002] White noise speakers are an effective sleep aid, providing a consistent background sound environment that effectively masks ambient noise and helps users fall asleep faster. However, existing white noise speaker systems generally lack intelligent sleep detection capabilities and cannot automatically adjust the volume based on the user's actual sleep state. This forces users to manually control the volume or rely on simple timer functions. Especially in complex home environments, the aliasing of background noise and user activity sounds severely affects the reliability of detection. Summary of the Invention
[0003] This invention provides a sensor-based method for white noise sound sleep detection and volume reduction control. This invention maintains the spectral characteristics and phase consistency of white noise, achieves zero-distortion volume reduction control, and thus realizes personalized sleep detection and volume control, improving the user experience of white noise sound.
[0004] In a first aspect, the present invention provides a sensor-based method for detecting and gradually reducing the volume of white noise for sleep, the sensor-based method comprising: The user's voice signal is acquired using a single microphone in a white noise speaker. Detect sound attenuation characteristics based on the user's voice signal; Based on the sound attenuation characteristics, temporal pattern recognition is performed and the probability of falling asleep is calculated. Based on the sleep probability, the spectral modulation parameters are calculated in conjunction with the auditory masking characteristics. The DSP chip in the white noise speaker performs FFT transformation on the audio playback signal and performs amplitude modulation and IFFT transformation according to the spectrum modulation parameters to output the target audio signal.
[0005] In conjunction with the first aspect, in a first implementation of the first aspect of the present invention, the step of acquiring the user's voice signal using a single microphone in a white noise speaker includes: The system continuously records ambient sound waveforms using a single microphone in a white noise speaker and converts the sound waveforms into a raw sound data stream. Calculate the power spectral density of each frequency component in the original sound data stream, and establish an environmental noise benchmark model based on the power spectral density; Based on the environmental noise baseline model, the noise threshold is calculated and a bandpass filter is used to filter out out-of-band interference in the original sound data stream to obtain the environmental sound signal. Audio segments in the ambient sound signal that exceed the noise threshold are detected and marked as user activity sound segments to obtain the user sound signal.
[0006] In conjunction with the first aspect, in a second implementation of the first aspect of the present invention, the step of detecting sound attenuation characteristics based on the user's voice signal includes: Calculate the instantaneous energy of the user's voice signal, and calculate the arithmetic mean of the instantaneous energy; The instantaneous energy is smoothed based on the arithmetic mean to obtain a smoothed energy sequence; The energy decay rate is obtained by calculating the ratio of the energy difference to the time interval based on the smooth energy sequence using a preset sliding window. The system monitors the target period during which the energy decay rate continuously exceeds a preset threshold, and simultaneously calculates the duration of the cumulative sound silence state during the target period. When the duration reaches the target duration, a sleep candidate flag is triggered and a sound decay feature is generated.
[0007] In conjunction with the first aspect, in a third implementation of the first aspect of the present invention, the step of performing temporal pattern recognition and calculating the probability of falling asleep based on the sound attenuation characteristics includes: The sound attenuation feature sequence is divided into short-term time-series subsequences, medium-term time-series subsequences, and long-term time-series subsequences; The short-term time series subsequence, the medium-term time series subsequence, and the long-term time series subsequence are respectively input into three parallel bidirectional LSTM encoders. In each bidirectional LSTM encoder, local time series features at different time scales are extracted through a bidirectional gating mechanism and then concatenated and output to obtain the first feature vector. The first feature vector is input into the multi-head cross-attention Transformer layer for attention weight allocation and feature fusion to obtain the second feature vector; The second feature vector is input into the fusion decoding layer for temporal reconstruction to obtain the probability of falling asleep.
[0008] In conjunction with the first aspect, in a fourth implementation of the first aspect of the present invention, the step of inputting the second feature vector into the fusion decoding layer for temporal reconstruction to obtain the sleep probability includes: The second feature vector is input into a unidirectional LSTM decoder for sequence reconstruction to obtain the third feature vector; Calculate the fusion weights based on the third feature vector and the second feature vector; The third feature vector and the second feature vector are weighted and summed according to the fusion weights to obtain the fused feature vector; The fused feature vectors are sequentially input into a fully connected network, and the sigmoid activation function in the fully connected network is used to compress the fused feature vectors into a sleep probability between 0 and 1.
[0009] In conjunction with the first aspect, in a fifth implementation of the first aspect of the present invention, the step of calculating the spectral modulation parameters based on the sleep probability and auditory masking characteristics includes: Based on the auditory masking characteristics, the white noise spectrum is divided into low-frequency, mid-frequency, and high-frequency bands; When the probability of falling asleep is less than or equal to the first probability value, it is determined to be a waking state. The attenuation coefficients of the low frequency band, the mid frequency band and the high frequency band are all set to maintain the original volume, and the attenuation rate is set to 0 to keep the white noise playback intensity unchanged, so as to obtain the spectrum modulation parameters of the waking state. When the probability of falling asleep is between the first probability value and the second probability value, it is determined to be a light sleep state. The spectral modulation parameters of the light sleep state are calculated based on the low frequency band, the mid frequency band and the high frequency band respectively. When the probability of falling asleep is greater than or equal to the second probability value, it is determined to be a deep sleep state. The spectral modulation parameters of the deep sleep state are calculated based on the low frequency band, the mid frequency band, and the high frequency band, respectively.
[0010] In conjunction with the first aspect, in a sixth implementation of the first aspect of the present invention, the step of determining a light sleep state when the probability of falling asleep is between a first probability value and a second probability value, and calculating the spectral modulation parameters of the light sleep state based on the low-frequency band, the mid-frequency band, and the high-frequency band respectively, includes: When the probability of falling asleep is between the first probability value and the second probability value, it is determined to be a light sleep state, and a first attenuation control benchmark for the light sleep state is determined. A slight linear attenuation is applied to the low-frequency band based on the first attenuation control benchmark to obtain a first attenuation coefficient; Based on the first attenuation control benchmark, the mid-frequency band is subjected to moderate linear attenuation to obtain a second attenuation coefficient; Based on the first attenuation control benchmark, the high-frequency band is exponentially attenuated to obtain a third attenuation coefficient; The first attenuation coefficient, the second attenuation coefficient, and the third attenuation coefficient are combined to form the spectral modulation parameters for the light sleep state.
[0011] In conjunction with the first aspect, in the seventh implementation of the first aspect of the present invention, the step of determining a deep sleep state when the probability of falling asleep is greater than or equal to the second probability value, and calculating the spectral modulation parameters of the deep sleep state based on the low-frequency band, the mid-frequency band, and the high-frequency band respectively, includes: When the probability of falling asleep is greater than or equal to the second probability value, it is determined to be a deep sleep state, and a second attenuation control benchmark for the deep sleep state is determined. Based on the second attenuation control benchmark, the low-frequency band is subjected to standard linear attenuation to obtain a fourth attenuation coefficient; Based on the second attenuation control benchmark, the mid-frequency band is enhanced with linear attenuation to obtain the fifth attenuation coefficient; Based on the second attenuation control benchmark, the high-frequency band is subjected to enhanced exponential attenuation to obtain the sixth attenuation coefficient; The fourth attenuation coefficient, the fifth attenuation coefficient, and the sixth attenuation coefficient are integrated into the spectrum modulation parameters for deep sleep state.
[0012] In conjunction with the first aspect, in the eighth implementation of the first aspect of the present invention, the step of using the DSP chip in the white noise speaker to perform FFT transformation on the audio playback signal and perform amplitude modulation and IFFT transformation according to the said spectrum modulation parameters to output the target audio signal includes: The audio playback signal is divided into 1024 data blocks and input into the hardware FFT accelerator of the DSP chip for fast Fourier transform processing to obtain a complex signal matrix in the frequency domain. Based on the aforementioned spectrum modulation parameters, amplitude modulation operations are performed on each frequency component in the frequency domain complex signal matrix to obtain the modulated frequency domain signal matrix. The modulated frequency domain signal matrix is input into the DSP chip to perform a 1024-point inverse fast Fourier transform to obtain a gradually decreasing time domain audio sequence. The descent time-domain audio sequence is converted into analog audio by the digital-to-analog converter built into the DSP chip, and the target audio signal is output.
[0013] In conjunction with the first aspect, in a ninth implementation of the first aspect of the present invention, the step of performing amplitude modulation operations on each frequency component in the frequency domain complex signal matrix based on the spectral modulation parameters to obtain the modulated frequency domain signal matrix includes: Extract the first real part and the first imaginary part of each frequency component in the frequency domain complex signal matrix, construct an amplitude matrix based on the first real part and the first imaginary part, and calculate the phase angle of each frequency component using the arctangent function to obtain the phase matrix; Based on the spectrum modulation parameters, the corresponding attenuation coefficients are matched to the corresponding frequency positions in the amplitude matrix to establish a frequency index modulation mapping table. Based on the frequency index modulation mapping table, modulation operations are performed on each frequency component in the amplitude matrix to obtain the modulated amplitude matrix, while keeping all phase angle values in the phase matrix completely unchanged. The second real part and the second imaginary part of each frequency component after modulation are calculated based on the modulated amplitude matrix and the phase matrix, and the modulated frequency domain signal matrix is generated based on the second real part and the second imaginary part.
[0014] The technical solution provided by this invention significantly reduces system cost and hardware complexity by using a single-microphone configuration instead of the traditional multi-microphone array solution. Employing a Sound Energy Attenuation Detection (SEDA) algorithm combined with a three-layer LSTM-Transformer neural network architecture, it can accurately identify complex temporal patterns during the sleep process, effectively solving the misjudgment problem caused by the mixing of environmental noise and user activity sounds. Compared with traditional rule-based judgment methods, it has stronger environmental adaptability and detection accuracy. Based on the auditory masking effect, a differentiated spectrum modulation strategy is used, employing differentiated attenuation functions for different frequency bands to ensure that the volume reduction process strictly follows the characteristics of human hearing, significantly improving the naturalness of the sound. Utilizing DSP chip frequency domain processing technology, amplitude modulation is directly performed through FFT / IFFT transformation, fundamentally avoiding the quantization noise and nonlinear distortion of traditional digital potentiometers, achieving truly distortion-free volume control. Simultaneously, the dynamic feedback control mechanism can adaptively adjust parameters according to the user's historical patterns, providing a personalized and intelligent sleep experience. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a schematic flowchart illustrating the sensor-based white noise sound sleep detection and volume gradually decreasing control method provided in an embodiment of this application. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the described order. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change based on the actual situation.
[0019] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0020] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0021] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features described herein can be combined with each other.
[0022] Please see Figure 1 , Figure 1 This is a schematic flowchart of a sensor-based white noise sound sleep detection and volume gradually decreasing control method provided in an embodiment of this application, as shown below. Figure 1 As shown in the embodiments of this application, the sensor-based white noise sound sleep detection and volume gradually decreasing control method includes the following steps: Step S100: Acquire the user's voice signal using a single microphone in a white noise speaker; Specifically, a single microphone inside the white noise speaker continuously acquires ambient sound waveform signals at a high sampling frequency (e.g., 48kHz) and sufficient quantization precision (e.g., 16-bit). Simultaneously, the analog sound waves are converted to digital form, forming a time-series raw sound data stream. Frequency domain analysis is performed on the raw sound data stream. A Fast Fourier Transform (FFT) is used to decompose the time-domain signal into individual frequency components, and the power spectral density distribution of each frequency component is calculated to obtain a quantitative description of the ambient sound field characteristics. During the initial period after device startup, power spectral density data is continuously accumulated and statistically averaged to establish a stable environmental noise benchmark model, reflecting the average power level of noise in different frequency ranges under conditions without user interference. Based on the environmental noise benchmark model, a noise threshold is calculated. A threshold coefficient proportional to the benchmark noise power is set to determine the judgment boundary, and a bandpass filter is used to filter out out-of-band interference components below 20Hz and above 20kHz that are beyond the audible range, thus obtaining the ambient sound signal. The system monitors the processed ambient sound signals in real time and extracts audio segments whose instantaneous energy or power levels exceed the noise threshold. These segments are identified as user activity sound segments and marked in the signal stream to form user sound signals with activity identifiers.
[0023] Step S200: Detect sound attenuation characteristics based on the user's voice signal; Specifically, energy feature analysis is performed on the user's voice signal. Instantaneous energy is calculated by performing a short-time Fourier transform on the signal at a fixed time step or by directly summing the squares of the time-domain sample values, resulting in an energy value sequence reflecting the current sound intensity. The arithmetic mean of the energy value sequence is calculated, and the instantaneous energy is smoothed using this arithmetic mean as a benchmark. A moving average is used to average the values over multiple adjacent time points, resulting in a smoothed energy sequence with smaller fluctuations and a more stable trend. A preset-length sliding time window is introduced. The smoothed energy value at the start of the window and the current time after translation is compared, and the difference is calculated and divided by the corresponding time interval to obtain the rate of energy change per unit time, i.e., the energy decay rate. The energy decay rate is continuously monitored. When the energy decay rate consistently exceeds a preset threshold for a continuous period, it is determined that the sound intensity exhibits a stable decreasing trend within the target time period. Simultaneously, the cumulative duration of the user's voice being silent within the target time period is calculated. The duration of silence is accumulated using a sound activity detection flag when multiple sampling points are silent. When the cumulative duration reaches the preset target duration threshold, a sleep candidate flag is triggered, and the smooth energy change pattern and silent duration characteristics of the target period are combined and recorded as sound attenuation characteristics.
[0024] Step S300: Perform temporal pattern recognition based on sound attenuation characteristics and calculate the probability of falling asleep; Specifically, the sound attenuation characteristics are hierarchically sliced according to time scales, preserving both near-field fluctuations and long-term trends. For example, a short subsequence is constructed in 30-second intervals, a medium-term subsequence in 120-second intervals, and a long-term subsequence in 600-second intervals. Each segment is normalized and timestamp-encoded to prevent rhythmic information from being masked by smoothing. The three subsequences are input into three parallel bidirectional LSTM encoders. Each encoder simultaneously captures both rising and falling dynamics in both forward and reverse gating. The short-term branch focuses on the fine-grained fluctuations of instantaneous energy jitter and silent intervals, the medium-term branch focuses on the slow decreasing trajectory from active to calm, and the long-term branch models the baseline drift and the proportion of continuous silence at the ten-minute level. The three encoded outputs are concatenated to form the first feature vector, and the statistical distribution is stabilized through layer normalization and regularization with a dropout rate of approximately 0.3. To avoid a single timescale dominating decision-making, the first feature vector is input into a multi-head cross-attention Transformer layer. Representations at different time scales are aligned in a multi-head mapping of query, key, and value, and attention weights are dynamically allocated accordingly. This allows the model to increase attention to medium- and long-term branches when a typical sleep trajectory of "slowly decreasing energy and increasing silent proportion" occurs, while suppressing false triggers when "short-term perturbations" occur. The cross-scale attention output is fused with a residual connection and a feedforward network to obtain a second feature vector, which carries composite evidence such as short-term sharpness, rhythmic stability, and baseline decay strength. The second feature vector is input into a fusion decoding layer for temporal reconstruction and compression mapping. The decoding layer consists of a lightweight fully connected network and a gated smoothing unit, outputting a sleep probability sequence with a 1-second step size. During the training phase, a binary cross-entropy objective, an Adam optimizer, a learning rate of 0.001, and a batch size of 32 are used. Temperature scaling and moving average are used to calibrate and suppress noise in the inference phase, ensuring that the probability curve rises rapidly during the actual sleep transition and remains stable under short-term noise perturbations, generating the sleep probability.
[0025] Step S400: Calculate the spectral modulation parameters based on the probability of falling asleep and the auditory masking characteristics; Specifically, based on the auditory masking effect of the human ear, the entire spectrum of white noise is segmented. 20Hz to 500Hz is defined as the low-frequency band to preserve deeper perceptual support; 500Hz to 4kHz is defined as the mid-frequency band, the part most sensitive to the human ear and significantly affecting the comfort of white noise; and 4kHz to 20kHz is defined as the high-frequency band, which contains more components that interfere with sleep. The probability of falling asleep is compared with preset first and second probability values. When the probability of falling asleep is less than or equal to the first probability value, the user is considered awake. To maintain the original sound field atmosphere, the attenuation coefficients of the low-frequency, mid-frequency, and high-frequency bands are all set to 1.0 to maintain the original volume, while the attenuation rate is set to 0 to ensure that the playback intensity of the white noise remains constant over time, avoiding interference with the user's hearing. When the probability of falling asleep falls between the first and second probability values, the user is considered to be in a light sleep state. In the low-frequency range, only a slight linear attenuation is applied to maintain the thickness and sense of security of the sound; in the mid-frequency range, a moderate linear attenuation rate is set to maintain a natural listening experience while reducing stimulation; and in the high-frequency range, a faster exponential attenuation is used to weaken high-frequency noise components that could trigger awakening, with the attenuation rate dynamically adjusted to ensure a smooth transition. When the probability of falling asleep is greater than or equal to the second probability value, the user is considered to be in a deep sleep state. In the low-frequency range, the attenuation amplitude is moderately increased to reduce overall sound pressure; in the mid-frequency range, the attenuation speed is accelerated to reduce perceived stimulation; and in the high-frequency range, rapid attenuation is maintained and the attenuation amplitude is increased, significantly reducing high-frequency components in a short period. Through differentiated calculations by frequency band and sleep state, spectral modulation parameters matching auditory physiological characteristics are generated for different sleep states.
[0026] Step S500: Use the DSP chip in the white noise speaker to perform FFT transformation on the speaker playback signal and perform amplitude modulation and IFFT transformation according to the spectrum modulation parameters to output the target audio signal.
[0027] Specifically, the audio playback signal is segmented into 1024-point data blocks of fixed length. Each data block is input into the DSP chip inside the white noise speaker, where a hardware-level FFT accelerator performs a Fast Fourier Transform (FFT) to convert the time-domain waveform into a frequency-domain complex signal matrix. Each element contains amplitude and phase information for the corresponding frequency component. Based on the spectral modulation parameters, the amplitude value is scaled for each frequency component in the frequency-domain complex signal matrix while maintaining the phase, thus achieving differentiated amplitude modulation for different frequency bands. This allows control over the attenuation level and speed of low, mid, and high frequencies according to the sleep state. The amplitude-modulated frequency-domain signal matrix is then input into the inverse fast Fourier transform (IFT) unit inside the DSP chip to perform a 1024-point IFT, restoring the modulated frequency-domain data to the corresponding fading time-domain audio sequence. Real-time processing methods, such as overlapping and saving, ensure seamless connection between consecutive data blocks, avoiding boundary distortion or transient noise. The DSP chip uses a built-in high-precision digital-to-analog converter (DAC) to convert a sloping time-domain audio sequence into an analog audio signal while maintaining low total harmonic distortion and high dynamic range output performance. The signal is then driven by a power amplifier module to play through a speaker, thus obtaining the target audio signal.
[0028] In one specific embodiment, the process of performing step S100 may specifically include the following steps: The system continuously records ambient sound waveforms using a single microphone in a white noise speaker and converts the sound waveforms into raw sound data streams. Calculate the power spectral density of each frequency component in the original sound data stream, and establish an environmental noise benchmark model based on the power spectral density; The noise threshold is calculated based on the environmental noise baseline model, and the out-of-band interference in the original sound data stream is filtered out using a bandpass filter to obtain the environmental sound signal. The system detects audio segments in the ambient sound signal that exceed the noise threshold and marks them as user activity sound segments to obtain the user sound signal.
[0029] Specifically, based on the high-sensitivity single-microphone module integrated within the white noise speaker, the ambient sound field is continuously recorded at a set high sampling rate (e.g., 48kHz) and high quantization accuracy (e.g., 16-bit). The sound wave signal is converted from the analog domain to a digital waveform sequence in the time domain, forming the raw sound data stream. The raw sound data stream is input into a digital signal processing unit for frequency domain analysis. A Fast Fourier Transform (FFT) is used to decompose the discrete sampled values in the time domain into corresponding frequency components, and the power spectral density of each frequency component is calculated. This quantifies the energy distribution of specific frequency components in the overall signal, thus reflecting the spectral characteristics of the ambient background noise. The power spectral density data is accumulated and statistically averaged over a specific period after device startup (e.g., the first 120 seconds) to generate a stable and effective ambient noise benchmark model under the current acoustic environment. This benchmark model is based on background sound without user activity interference and reflects the long-term equilibrium level of noise energy across different frequency ranges. The ambient noise benchmark model has adaptive updating capabilities, periodically recalculating during system operation through a sliding time window to ensure dynamic adjustment as the ambient sound field changes. Based on the average power level of each frequency component in the environmental noise baseline model, a noise threshold is calculated using a preset scaling factor. This threshold serves as a critical condition for judging the difference between sound activity and background noise. A bandpass filter is applied to the raw audio data stream to filter out out-of-band interference signals below 20Hz and above 20kHz, resulting in the environmental sound signal. The environmental sound signal is monitored in real time, and the instantaneous energy level or spectral power distribution is calculated in each processing cycle. The instantaneous value is compared with the noise threshold. When the signal energy exceeds the threshold for several consecutive sampling cycles, the corresponding audio segment is extracted and marked as a user activity sound segment. This segment includes the timestamp of the activity, as well as descriptive data such as the corresponding frequency range and energy intensity, reflecting the user's activity in a white noise playback environment. After marking, the user activity sound segments are merged into a continuous user audio signal sequence.
[0030] This embodiment also includes adaptive sound activity state recognition processing in complex environments. Its features include: extracting 3D multi-resolution modulation-filtered cochlear map features from the user's voice signal to capture dynamic sound activity information; simultaneously calculating delta features and delta-delta features to enhance the dynamic changes of sound activity in the time and frequency domains; establishing a multi-dimensional sound activity feature representation to obtain a 3D sound activity feature matrix; inputting the 3D sound activity feature matrix into a sound activity BiMamba encoder; the sound activity BiMamba encoder, through a multi-temporal view bidirectional state-space model and a bidirectional parallel processing mechanism, captures complex sound activity patterns across time scales and retains short-term and long-term dependencies, solving the problem of recognizing overlapping environmental noise and sound activity cues, and obtaining the BiMamba... Encoding sound features; an adaptive sound activity denoising diffusion processor is established based on a diffusion denoising probability model. A confidence filtering mechanism is applied to select representative sound activity segments, and sound activity information from a clean environment is transferred to the sound signal in a noisy environment through the diffusion model. This solves the problems of scarce user sound activity data and decreased recognition accuracy in complex environments, resulting in denoised and enhanced sound features. An iterative confidence learning strategy is adopted to enhance the sound activity classification network through a two-stage learning process. In the first stage, the classification network is trained using high-confidence sound activity samples to establish a basic model. In the second stage, the classification network is gradually adapted to the feature distribution of the noisy environment through iterative updates, while ensuring the consistency of sound activity patterns during the diffusion denoising process. Finally, the environment-adaptive sound attenuation features are output for subsequent sleep probability calculation.
[0031] In one specific embodiment, the process of performing step S200 may specifically include the following steps: Calculate the instantaneous energy of the user's voice signal and the arithmetic mean of the instantaneous energy; The instantaneous energy is smoothed by applying the arithmetic mean to obtain a smoothed energy sequence. The energy decay rate is obtained by calculating the ratio of energy difference to time interval based on the smooth energy sequence using a preset sliding window. The system monitors the target period during which the energy decay rate continuously exceeds a preset threshold, and simultaneously calculates the duration of the cumulative sound silence state during the target period. When the duration reaches the target duration, a sleep candidate flag is triggered and a sound decay feature is generated.
[0032] Specifically, energy analysis is performed on the user's audio signal to calculate its instantaneous energy. The user's audio signal is segmented into fixed frame lengths (e.g., 1 second) within the time domain, and the squared amplitudes of the sampled points within each frame are summed to obtain the instantaneous energy value. The arithmetic mean of the instantaneous energy is calculated to obtain a more stable and representative statistical quantity compared to single-point energy. The instantaneous energy sequence is smoothed using the arithmetic mean. A moving average method is used to take the arithmetic mean of the instantaneous energy over several consecutive frames as the smoothed energy value at the current moment, effectively suppressing single-point fluctuations and obtaining a smoothed energy sequence. The attenuation rate of the smoothed energy sequence is calculated using a sliding time window of a preset length. The difference between the smoothed energy value at the start of the sliding window and the current moment is calculated, and this difference is divided by the time interval between the two to obtain the rate of energy change per unit time, i.e., the energy attenuation rate. To ensure real-time performance and accuracy, the sliding window is shifted once per processing cycle (e.g., per second) to continuously update the attenuation rate calculation results. The system continuously monitors whether the energy decay rate exceeds a preset threshold. This threshold, derived from extensive experimental data, effectively distinguishes between fluctuations in normal activity and the gradual weakening of sound during sleep. When the energy decay rate consistently exceeds the threshold across multiple sampling periods, this timeframe is designated as the target period, indicating a significant decrease in the user's auditory activity intensity. The system also simultaneously monitors the duration of silence within the target period. Silence is determined by a sound activity detection flag; when the sound energy at multiple consecutive sampling points falls below the ambient noise threshold, silence is established, and the duration is accumulated. This accumulated silence duration is compared to a preset target threshold. When the silence duration reaches or exceeds the target, it indicates that the user has maintained a sufficiently long period of quiet while experiencing significant energy decay, exhibiting highly correlated sleep-inducing characteristics. This triggers a sleep candidate flag, marking the current period as the sleep stage, and integrating the corresponding smoothed energy sequence, energy decay rate curve, and silence duration into a sound decay feature.
[0033] The monitoring process involves monitoring the target period during which the energy decay rate continuously exceeds a preset threshold, and simultaneously calculating the duration of the cumulative sound silence state during the target period. When the duration reaches the target duration, a sleep candidate flag is triggered, and sound decay characteristics are generated. This includes: establishing a 600-second sliding window energy decay rate calculation model; calculating the energy difference by comparing the current time with the smoothed energy sequence values from 600 seconds ago; dividing the energy difference by the 600-second time interval to obtain the instantaneous energy decay rate; setting an energy decay rate threshold of 0.001 joules per second to obtain a dynamic decay rate monitoring benchmark; continuously monitoring the instantaneous energy decay rate values at 20 sampling points within the dynamic decay rate monitoring benchmark; and determining a continuous energy decay state when the decay rate value at each sampling point exceeds the energy decay rate threshold within 20 consecutive seconds, and initiating a silence period. The cumulative calculation program obtains an energy decay confirmation signal. Based on the energy decay confirmation signal, the sound activity detection flag monitoring mechanism is activated. The sound activity detection flag is set by comparing the smooth energy sequence with the noise threshold. When the smooth energy sequence is below the noise threshold for 3 consecutive seconds, the flag is set to 0 to indicate a silent state. When the smooth energy sequence exceeds the noise threshold, the flag is set to 1 to indicate an active state. The duration of consecutive flags being 0 is accumulated to obtain the silent duration value. It is then determined whether the silent duration value reaches the target duration threshold of 180 seconds. When the silent duration exceeds 180 seconds and the energy decay confirmation signal remains valid, the sleep candidate flag is triggered simultaneously. The instantaneous energy decay rate, the silent duration value, and the sound activity detection flag status at the current moment are combined and encapsulated to obtain the sound decay characteristics.
[0034] In one specific embodiment, the process of performing step S300 may specifically include the following steps: The sound attenuation feature sequence is divided into short-term time-series subsequences, medium-term time-series subsequences, and long-term time-series subsequences; The short-term, medium-term, and long-term time series subsequences are respectively input into three parallel bidirectional LSTM encoders. In each bidirectional LSTM encoder, local time series features at different time scales are extracted through a bidirectional gating mechanism and then concatenated to output the first feature vector. The first feature vector is input into the multi-head cross-attention Transformer layer for attention weight allocation and feature fusion to obtain the second feature vector; The second feature vector is input into the fusion decoding layer for temporal reconstruction to obtain the probability of falling asleep.
[0035] Specifically, the sound attenuation feature sequence is decomposed on a time scale to capture short-term user behavior fluctuations, medium-term activity trends, and long-term state changes. Based on the time span, the entire feature sequence is divided into three distinct subsequences: a short-term subsequence covering tens of seconds to reflect the user's instantaneous vocalization patterns and short-term energy fluctuations; a medium-term subsequence spanning several minutes to describe the user's transition from active to gradually quiet periods; and a long-term subsequence covering even longer time periods, such as over ten minutes, to capture the slow decline of the overall activity baseline and the proportion of sustained silence. The short-term, medium-term, and long-term subsequences are then input into three parallel bidirectional LSTM encoders. The bidirectional LSTM processes the time series through two gated recurrent units: the forward unit captures feature dependencies in the forward time sequence, while the backward unit analyzes information in the reverse time series. In the short-term branch, the bidirectional gating mechanism is more sensitive to small energy fluctuations and short-term quiet intervals; in the medium-term branch, bidirectional gating captures the smooth decline curve of energy and the rhythm of quiet interval distribution; in the long-term branch, it focuses on the slow decay pattern and changes in baseline stability over larger time scales. Each bidirectional LSTM encoder, after processing its corresponding subsequence, outputs a high-dimensional vector containing local temporal features of the corresponding time scale. The outputs of the three branches are then concatenated into a unified first feature vector. This first feature vector is then input into a Transformer layer with multi-head cross-attention for processing. In the Transformer layer, the attention mechanism maps the first feature vector into three matrices: query (Q), key (K), and value (V), and evaluates the correlation between features at different time scales in different subspaces through multi-head parallel computation. Cross-attention allows the model to not only focus on the internal dependencies of a single time scale but also dynamically allocate weights based on the degree of matching between different time scales. For example, when medium- and long-term features show a stable decline trend while short-term features exhibit small energy fluctuations, the attention mechanism can reduce the weight of short-term features to avoid misjudgment. If short-term features show a significant increase in silence while medium- and long-term features have not yet decreased significantly, the weight of short-term features will be increased to accelerate the response judgment of the sleep state. After multi-head cross-attention fusion, a second feature vector is obtained. The second feature vector is input into the fusion decoding layer for temporal reconstruction and probability mapping. The fusion decoding layer consists of a fully connected layer, a non-linear activation function, and a gating unit, used to compress and map the high-dimensional fusion features into a one-dimensional sleep probability value. During the temporal reconstruction process, the decoding layer integrates the change trajectory of each time scale to identify typical patterns in the sleep process, such as gradual energy decline, accumulation of silence duration, and gradual reduction of short-term disturbances, thereby obtaining a continuous probability value between 0 and 1 at the output. The closer the continuous probability value is to 1, the higher the probability that the user has entered sleep.To improve the model's stability and generalization ability, binary cross-entropy is used as the loss function during the training phase, combined with regularization techniques such as Dropout to prevent overfitting. During the inference phase, moving average and probability smoothing are used to reduce output fluctuations.
[0036] The process involves inputting the first feature vector into a multi-head cross-attention Transformer layer for attention weight allocation and feature fusion to obtain the second feature vector. This includes: dividing the first feature vector into three feature subsets based on short-term, medium-term, and long-term time scales; assigning four dedicated attention heads to each feature subset to form a 12-head attention mechanism; generating query, key, and value matrices through linear transformation matrices to obtain the multi-head attention computation basis matrix; and performing self-attention computation on feature subsets within the same time scale based on the multi-head attention computation basis matrix. Attention scores are calculated by multiplying the query and key matrices and then normalized using a softmax function to obtain attention weights. Multiplying with the corresponding value matrix yields a weighted feature representation, resulting in self-attention features within the time scale. Cross-attention calculations are performed on feature subsets across different time scales. The short-term feature subset is used as the query matrix to interact with the key and value matrices of the mid-term and long-term feature subsets. Simultaneously, cross-attention calculations are performed on the mid-term and long-term feature subsets to achieve deep fusion of feature information across multiple time scales, resulting in cross-scale cross-attention features. The self-attention features within the time scale and the cross-scale cross-attention features are superimposed through a residual connection mechanism and stabilized by layer normalization. Sine and cosine positional encodings are added to maintain the relative positional relationship of temporal information, resulting in the second feature vector.
[0037] In one specific embodiment, the process of inputting the second feature vector into the fusion decoding layer for temporal reconstruction to obtain the probability of falling asleep can specifically include the following steps: The second feature vector is input into a unidirectional LSTM decoder for sequence reconstruction to obtain the third feature vector; The fusion weights are calculated based on the third and second feature vectors. The third and second feature vectors are weighted and summed according to the fusion weights to obtain the fused feature vector. The fused feature vectors are sequentially input into a fully connected network, and the sigmoid activation function in the fully connected network is used to compress the fused feature vectors into a sleep probability between 0 and 1.
[0038] Specifically, the second feature vector is input into a unidirectional LSTM decoder. The decoder employs a causal processing approach from past to present, progressively reading features in chronological order with a 1-second step size. This ensures that online inference does not rely on future information and avoids information leakage. The size of the decoder's hidden units matches the output dimension of the preceding encoder. At each step, gating units selectively retain long-term memories related to "slowly decreasing energy and increasing silent proportion," while suppressing short transient jitter. During training, teacher-mandated regularization with a dropout rate of approximately 0.3 is used to stabilize the decoding trajectory, and layer normalization at the end of the sequence eliminates batch-to-batch distribution drift. The decoded output obtained after progressive unfolding is the third feature vector, which contains the contextual representation after causal temporal reconstruction of the second feature vector, emphasizing the directional and stage-specific characteristics of the sleep transition period. Adaptive estimation of the fusion weights of the second and third feature vectors is performed on the same time scale. A lightweight gated scoring unit is introduced, concatenating the two feature vectors after linear transformation and nonlinear compression, and superimposing them with temporal location encoding to capture the importance of features at different stages. A small feedforward network with residual connections generates a fusion weight distribution between 0 and 1. At each time step, the third and second feature vectors are weighted and summed to obtain the fusion feature vector. The weighting process employs consistent weight broadcasting per channel, with mild temporal smoothing and intra-channel smoothing applied before and after fusion to ensure the fusion result is coherent on the time axis and avoids sharp abrupt changes on the feature axis. A residual bypass is introduced to preserve the direct path of the original attention-based fusion features, thus maintaining the robustness of the output when sleep-inducing features are not yet obvious. The fusion feature vector is sequentially input into a fully connected network consisting of two to three layers for compression mapping. The first layer is responsible for dimensionality reduction and enhancing nonlinear expression through modified linear unit activation. The second layer corrects class boundaries and, in conjunction with dropout regularization, suppresses overfitting. The output layer uses a sigmoid activation function to compress continuous features into sleep probabilities between 0 and 1. During the training phase, binary cross-entropy is used as the objective function, and an optimized configuration of learning rate 0.001 and batch size 32 is used, combined with early stopping strategy and validation set calibration to ensure generalization. During the inference phase, the probability per second is lightly averaged and temperature-scaled to make the probability curve rise rapidly during the actual sleep transition and remain stable under short noise disturbances.
[0039] In one specific embodiment, the process of performing step S400 may specifically include the following steps: Based on the auditory masking characteristics, the white noise spectrum is divided into low-frequency, mid-frequency, and high-frequency bands; When the probability of falling asleep is less than or equal to the first probability value, it is determined to be a waking state. The attenuation coefficients of the low-frequency, mid-frequency and high-frequency bands are all set to maintain the original volume, and the attenuation rate is set to 0 to keep the white noise playback intensity unchanged, so as to obtain the spectrum modulation parameters of the waking state. When the probability of falling asleep is between the first probability value and the second probability value, it is determined to be a light sleep state. The spectral modulation parameters of the light sleep state are calculated based on the low frequency band, the mid frequency band and the high frequency band respectively. When the probability of falling asleep is greater than or equal to the second probability value, it is determined to be a deep sleep state. The spectral modulation parameters of the deep sleep state are calculated based on the low frequency band, mid frequency band and high frequency band respectively.
[0040] Specifically, the entire frequency range of white noise is divided into zones based on the auditory masking characteristics of the human ear, and based on the differences in the human ear's sensitivity to sounds in different frequency ranges and their impact on the comfort of white noise. The frequency range of 20Hz to 500Hz is defined as the low-frequency band. Low-frequency sounds rely more on the human body's sense of touch and deep hearing, providing a stable sense of sound field immersion, which is preserved as much as possible during the sleep process to maintain a sense of security. The frequency range of 500Hz to 4kHz is defined as the mid-frequency band. The mid-frequency band is the part of the human ear most sensitive to and has the greatest impact on the recognition of speech and environmental sounds. The frequency range of 4kHz to 20kHz is defined as the high-frequency band. The high-frequency band contains more sharp noise components and environmental disturbance signals. The probability of falling asleep is read in real time and compared with two preset thresholds to determine the current sleep state. When the probability of falling asleep is less than or equal to the first probability value, the user is considered awake. In this awake state, to maintain the original sound field atmosphere and masking effect of the white noise playback, the attenuation coefficients for the low, mid, and high frequency bands are all set to 1.0, maintaining the original volume. Simultaneously, the attenuation rate parameter is set to 0, ensuring the white noise volume intensity remains constant during playback. This guarantees that the user's auditory experience is consistent with the initial usage, preventing volume fluctuations caused by accidental triggering from affecting attention or emotional stability. When the probability of falling asleep falls between the first and second probability values, the user is considered to be in a light sleep state. At this point, the sound control strategy balances two objectives: gradually reducing the white noise intensity to guide deeper sleep, while avoiding rapid volume changes that could cause abrupt perceptual changes. In the low-frequency range, a small linear attenuation coefficient is calculated based on the relative position of the probability of falling asleep to the first and second probability values. For example, the amplitude is gradually reduced to 90% to 80% of the original value to preserve the sense of sound field immersion. In the mid-frequency range, the attenuation amplitude is moderate and the change is smoother, allowing the human ear to gradually adapt to the sound field changes within a comfortable range and reducing attention to the external environment. In the high-frequency range, a relatively fast attenuation strategy is adopted, for example, reducing the amplitude exponentially to about 50% of the original value to quickly weaken potential disturbance signals. The attenuation coefficients of these frequency ranges are continuously interpolated based on the dynamic changes in the probability of falling asleep, thereby achieving gradual and abrupt volume adjustment. When the probability of falling asleep is greater than or equal to the second probability value, it is determined that the user has entered a deep sleep state. At this time, the volume control goal is to further reduce the interference of external sounds on sleep and maintain sound stability to prevent awakening. In the low-frequency range, the attenuation amplitude is moderately increased, for example, reducing the amplitude to 70% or lower of the original value, while maintaining a slow attenuation rate, to avoid the "hollow feeling" caused by a sudden reduction in low-frequency energy, which can lead to unstable sleep. In the mid-frequency range, the attenuation amplitude is significantly increased, for example, gradually decreasing to 60% or 50% of the original value, to effectively reduce sound pressure stimulation in the sensitive areas of the human ear. In the high-frequency range, the attenuation speed is the fastest and the amplitude is the largest, rapidly decreasing to 20% or even lower of the original value, thereby eliminating sharp components and potential arousal sources to the greatest extent.To ensure the continuity and naturalness of volume changes, a transition phase is introduced when switching between different states. A smooth interpolation algorithm is used to adjust the attenuation parameter within a few seconds to tens of seconds to avoid abrupt changes.
[0041] In one specific embodiment, the process of determining a light sleep state when the probability of falling asleep is between a first probability value and a second probability value, and calculating the spectral modulation parameters of the light sleep state based on the low-frequency band, mid-frequency band, and high-frequency band respectively, can specifically include the following steps: When the probability of falling asleep is between the first probability value and the second probability value, it is determined to be a light sleep state, and the first decay control benchmark for the light sleep state is determined. A slight linear attenuation is applied to the low-frequency band based on the first attenuation control benchmark to obtain the first attenuation coefficient; Based on the first attenuation control reference, a moderate linear attenuation is applied to the mid-frequency band to obtain the second attenuation coefficient; Based on the first attenuation control benchmark, the high-frequency band is exponentially attenuated to obtain the third attenuation coefficient; The first attenuation coefficient, the second attenuation coefficient, and the third attenuation coefficient are combined to form the spectral modulation parameters for the light sleep state.
[0042] Specifically, the real-time probability of falling asleep is compared with preset first and second probability values. When the probability of falling asleep is detected to be between the first and second probability values, it is determined that the user has transitioned from a waking state to a light sleep state. The goal of the sound control strategy is to further guide the user into a deeper sleep stage through gentle volume adjustments and reduce interference from external high-frequency noise. A first attenuation control benchmark is determined for the light sleep state, calculated by considering factors such as the current position of the fall-as-sleep probability within the range, the user's historical volume preferences, and the level of ambient noise. Based on the first attenuation control benchmark, each frequency band is processed differently according to the differences in the sensitivity of the human ear to different frequency bands. For the low-frequency band (20Hz to 500Hz), the sound in the low-frequency range plays an important role in creating a sense of immersion and security, so the attenuation should be relatively slight and the change should be gradual. A slight linear attenuation coefficient for the low-frequency band is calculated based on the first attenuation control benchmark to ensure that the low-frequency sound field remains full and stable throughout the light sleep process, so as not to cause discomfort to the user due to a sudden decrease in low-frequency energy. For the mid-frequency range (500Hz to 4kHz), which is within the range where the human ear is most sensitive and has the most direct impact on the perception of white noise, a moderate linear attenuation is applied based on the first attenuation control benchmark to reduce the stimulation of the central nervous system during the light sleep stage. This maintains a gradual approach while reducing mid-frequency sound pressure, thus minimizing stimulation of the auditory cortex. The calculation of the mid-frequency attenuation coefficient takes into account the specific position of the probability of falling asleep. If it is close to the upper limit of the second probability value, the attenuation will be slightly larger to facilitate a faster transition to deep sleep; conversely, if it is close to the lower limit of the first probability value, a gentler attenuation rate is maintained to avoid prematurely reducing the volume and attracting attention. For the high-frequency range (4kHz to 20kHz), which contains a large number of sharp components that interfere with sleep and residual environmental noise, a third attenuation coefficient is calculated based on the first attenuation control benchmark using an exponential attenuation method. Exponential attenuation rapidly weakens high-frequency energy in the initial stage, causing the high-frequency components to drop to a level that has almost no impact on sleep in a short period of time, and then slowly approaches a low value for the remainder of the time to maintain the balance and naturalness of the sound. The first attenuation coefficient, the second attenuation coefficient, and the third attenuation coefficient are combined to form the spectrum modulation parameter matrix in the light sleep state.
[0043] In one specific embodiment, the process of determining a deep sleep state when the probability of falling asleep is greater than or equal to a second probability value, and calculating the spectral modulation parameters of the deep sleep state based on the low-frequency band, mid-frequency band, and high-frequency band respectively, can specifically include the following steps: When the probability of falling asleep is greater than or equal to the second probability value, it is determined to be a deep sleep state, and the second decay control benchmark for the deep sleep state is determined. Based on the second attenuation control benchmark, standard linear attenuation is performed on the low-frequency band to obtain the fourth attenuation coefficient; Based on the second attenuation control benchmark, the mid-frequency band is enhanced with linear attenuation to obtain the fifth attenuation coefficient; Based on the second attenuation control benchmark, the high-frequency band is enhanced with exponential attenuation to obtain the sixth attenuation coefficient; The fourth, fifth, and sixth attenuation coefficients are integrated into the spectral modulation parameters for deep sleep.
[0044] Specifically, when the probability of falling asleep is detected to be greater than or equal to the second probability value, the user is determined to have entered a deep sleep state. Deep sleep indicates a significant reduction in the user's auditory sensitivity and a weakened response of the brain to external sound stimuli. Therefore, a larger amplitude and more efficient attenuation is employed in the volume control strategy to minimize the interference of external sounds on sleep quality. A second attenuation control benchmark for deep sleep is calculated based on the current probability of falling asleep, the user's historical sleep data, and the current ambient noise level. Based on this benchmark, and according to the auditory characteristics of the human ear in deep sleep, standard linear attenuation is applied to the low-frequency range (20Hz to 500Hz). While low frequencies have almost no impact on wakefulness during deep sleep, excessively high sound pressure can cause slight interference with sleep stability; therefore, sound energy is moderately reduced. A fourth attenuation coefficient is calculated based on the second benchmark, causing the amplitude of the low-frequency range to slowly and evenly decrease to the target level, controlled between 60% and 70% of the original amplitude, to preserve the basic sense of immersion in the sound field while reducing the physical pressure caused by low-frequency energy. Standard linear attenuation exhibits a stable decreasing slope over time, preventing auditory abrupt changes and maintaining sound field continuity. The mid-frequency range (500Hz to 4kHz) is the most sensitive area for the human ear. Even during deep sleep, excessively high sound pressure levels can trigger micro-awakening or disrupt sleep structure. Therefore, enhanced linear attenuation is applied to the mid-frequency range, with a fifth attenuation coefficient calculated based on the second attenuation control benchmark, rapidly reducing the amplitude to approximately 50% of its original value. Enhanced linear attenuation is characterized by a significantly higher attenuation rate than standard linear attenuation and takes effect immediately upon entering deep sleep, quickly controlling mid-frequency sound pressure within the safest range for sleep, effectively shielding mid-frequency noise signals from the environment. For the high-frequency range (4kHz to 20kHz), the most aggressive processing strategy is employed: enhanced exponential attenuation. High-frequency sound components include sharp, harsh noises, such as metallic friction sounds or high-frequency electrical noise. The sixth attenuation coefficient is calculated based on the second attenuation control benchmark, causing the high-frequency energy to drop sharply in a very short time, for example, reducing the amplitude to 20% or even 10% of the original value within a few seconds to tens of seconds, and maintaining a low amplitude level in the subsequent period. The fourth, fifth, and sixth attenuation coefficients are integrated into a spectrum modulation parameter matrix for deep sleep state.
[0045] In one specific embodiment, the process of executing step S500 may specifically include the following steps: The audio playback signal is divided into 1024 data blocks and input into the hardware FFT accelerator of the DSP chip for fast Fourier transform processing to obtain a complex signal matrix in the frequency domain. Amplitude modulation operation is performed on each frequency component in the frequency domain complex signal matrix based on the spectral modulation parameters to obtain the modulated frequency domain signal matrix. The modulated frequency domain signal matrix is input into the DSP chip to perform a 1024-point inverse fast Fourier transform, resulting in a gradually decreasing time-domain audio sequence. The descent time-domain audio sequence is converted into analog audio using the built-in digital-to-analog converter of the DSP chip, and the target audio signal is output.
[0046] Specifically, the audio playback signal is processed by frame segmentation, dividing it into data blocks of 1024 sampling points of a fixed length to obtain sufficient frequency resolution in the frequency domain analysis (for example, at a sampling rate of 48kHz, the resolution is approximately 46.875Hz). After framing, each 1024-point data block is sequentially input into the DSP chip built into the white noise speaker. The DSP chip uses its hardware-level FFT accelerator to perform a Fast Fourier Transform on the data block, converting the time-domain sampling sequence into a frequency-domain complex signal matrix. Each element of the frequency-domain complex signal matrix corresponds to the complex form of a specific frequency component, containing both amplitude and phase information. Spectral modulation parameters generated by sleep probability analysis and auditory masking models are then called, and these parameters are mapped one-to-one with each frequency component in the frequency-domain complex signal matrix. During modulation, only the amplitude portion of the complex signal is scaled, while the phase information remains unchanged. This ensures that the signal after amplitude adjustment does not produce phase distortion when restored to the time domain, preserving the spatial sense and naturalness of the sound. Specifically, for each frequency component, its original amplitude is multiplied by the attenuation coefficient of the corresponding frequency band in the modulation parameter matrix. For example, a smaller linear attenuation coefficient is used for the low-frequency band, a medium linear attenuation coefficient for the mid-frequency band, and a larger exponential attenuation coefficient for the high-frequency band. After amplitude scaling, the original frequency domain complex signal matrix is updated to the modulated frequency domain signal matrix. The modulated frequency domain signal matrix is input into the inverse FFT processing unit of the DSP chip to perform a 1024-point inverse fast Fourier transform (IFFT), restoring the modulated frequency domain data to a gradually decreasing time-domain audio sequence. During the IFFT process, the phase information of all frequency components is completely preserved, while the amplitude has been adjusted according to the spectral modulation parameters. Therefore, the reconstructed time-domain waveform retains the original auditory characteristics while the overall volume distribution changes according to the set attenuation curve. To ensure seamless splicing between consecutive data blocks and avoid auditory abnormalities caused by boundary effects, an overlapping storage or overlapping addition block splicing strategy is adopted to smoothly synthesize the overlapping parts of adjacent data blocks, thereby achieving a natural and coherent gradually decreasing transition in the entire audio stream. The gradually decreasing audio sequence is input into the high-precision digital-to-analog converter built into the DSP chip, which converts the digital waveform into the corresponding analog voltage signal according to the sampling rate, maintaining high dynamic range and low total harmonic distortion, ensuring that no additional noise or distortion is introduced during the sound decay process, and thus obtaining the target audio signal.
[0047] The modulated frequency domain signal matrix is input into a DSP chip to perform a 1024-point inverse fast Fourier transform (IFFT) to obtain a gradually decreasing time-domain audio sequence. This includes: establishing a double-buffered data processing mechanism, dividing the modulated frequency domain signal matrix into 512-point data blocks; while the current buffer performs the 1024-point IFFT inverse transformation, the backup buffer synchronously receives the frequency domain signal of the next data block, ensuring continuous audio stream processing capability and obtaining a double-buffered frequency domain data stream; and processing the double-buffered frequency domain data stream based on an overlap-preservation algorithm, where the first 512 points of each 1024-point IFFT processing block are the overlapped data from the previous processing, and the second 512 points are the newly input frequency domain signal data. Frequency domain multiplication is equivalently performed through temporal convolution to obtain an overlapping time-domain sequence. This overlapping time-domain sequence is then seamlessly spliced, discarding the first 512 overlapping data points of each processing block and retaining the last 512 valid output data points. These are then concatenated with the valid data of the next processing block in the temporal domain. The total audio processing delay is strictly controlled to be within 10.67 milliseconds to meet real-time requirements, resulting in a continuous time-domain audio stream. The continuous time-domain audio stream is then calibrated for sampling rate consistency using the clock synchronization control mechanism built into the DSP chip. This ensures that the time base of the output audio is precisely synchronized with the input speaker signal, preventing time drift or sampling rate mismatch during audio playback, thus obtaining a gradually decreasing time-domain audio sequence.
[0048] In one specific embodiment, the process of performing amplitude modulation operations on each frequency component in the frequency domain complex signal matrix based on spectral modulation parameters to obtain the modulated frequency domain signal matrix can specifically include the following steps: Extract the first real part and the first imaginary part of each frequency component in the frequency domain complex signal matrix, construct the amplitude matrix based on the first real part and the first imaginary part, and calculate the phase angle of each frequency component using the arctangent function to obtain the phase matrix; Based on the spectral modulation parameters, the corresponding attenuation coefficients are matched to the corresponding frequency positions in the amplitude matrix to establish a frequency index modulation mapping table. Based on the frequency index modulation mapping table, modulation operation is performed on each frequency component in the amplitude matrix to obtain the modulated amplitude matrix, while keeping all phase angle values in the phase matrix completely unchanged. The second real part and the second imaginary part of each frequency component after modulation are calculated based on the amplitude matrix and phase matrix after modulation, and the modulated frequency domain signal matrix is generated based on the second real part and the second imaginary part.
[0049] Specifically, the first real and first imaginary parts of each frequency component are sequentially read from the complex signal matrix in the frequency domain. Without changing the frequency index order, these parts are used to construct an amplitude matrix through modulus-length operations. Simultaneously, the phase angle of the same pair of real and imaginary parts is calculated using the arctangent function, resulting in a phase matrix that corresponds one-to-one with the amplitude matrix. To ensure numerical stability, the arctangent calculation employs a quadrant-based discrimination method, ensuring that the phase angle of each frequency component always falls within a predetermined interval. A frequency grid consistent with the number of FFT points is used for storage, thus maintaining a frequency resolution of approximately 46.875Hz and strict index alignment under a 1024-point transform. The spectral modulation parameters jointly generated by upstream auditory masking and sleep probability are read. The attenuation coefficients for the low-frequency band (e.g., 20Hz to 500Hz), mid-frequency band (e.g., 500Hz to 4kHz), and high-frequency band (e.g., 4kHz to 20kHz) are mapped line by line according to the discrete frequency indices derived from the frequency boundaries, sampling rate, and number of points, establishing a frequency index modulation mapping table. The frequency index modulation map clearly defines the attenuation coefficient to be applied to each discrete frequency point and maintains a conjugate symmetry relationship with the real signal spectrum in the mirror frequency region, thus providing a constant-time lookup path for amplitude modulation. Using the amplitude matrix as the operation object, amplitude scaling operations are performed on each frequency component according to the coefficients given in the frequency index modulation map. Mild or standard linear attenuation is applied to low frequencies, moderate or enhanced linear attenuation to mid-frequency frequencies, and exponential fast attenuation to high frequencies. Smoothing is performed at band boundaries using transition windows or interpolation weights to avoid abrupt changes in sound due to coefficient transitions at frequency band boundaries. Throughout the modulation process, the phase matrix remains read-only and is not modified, ensuring that the phase continuity and spatial sense of the waveform are not disrupted during time-domain reconstruction. To reduce sideband ripples in block processing, mild frequency-domain smoothing and leakage suppression are performed on the amplitude matrix, such as applying small-amplitude averaging operations between adjacent frequency points, while ensuring that the dominance of the target frequency index is not weakened. After amplitude modulation is completed, the complex spectrum reconstruction stage begins: based on the modulated amplitude matrix and the unchanged phase matrix, the amplitude and phase are rewritten back into the second real and second imaginary parts at each frequency point. These parts are then reprojected from the polar coordinate domain to the rectangular coordinate domain using trigonometric functions, and conjugate consistency checks are performed between the positive and negative frequency pairs. Simultaneously, the DC and Nyquist components are written at one end according to the special boundary conditions of the real signal spectrum to avoid energy repetition during the inverse transform. The modulated frequency domain signal matrix is then synthesized from the second real and second imaginary parts in the original index order.
[0050] The sensor-based white noise sound sleep detection and volume reduction control method further includes: monitoring the output spectral characteristics of the target audio signal and calculating the spectral distortion; automatically adjusting the FFT window function type of the DSP chip or adding frequency domain smoothing filtering when the spectral distortion exceeds the abnormal threshold of 0.01 to obtain an audio quality feedback control signal; recording the user's historical sleep time data, average sound activity intensity data, and preferred volume decay rate data for the past 30 days; calculating time correction coefficients, energy correction coefficients, and volume correction coefficients through statistical analysis; establishing a personalized user behavior pattern database; and obtaining user habit characteristics parameters. The system compares the current sleep detection result with the user's habitual characteristic parameters. When the deviation exceeds the preset range, a parameter correction mechanism is triggered. The energy decay rate threshold is adjusted to 1.2 times the original value, the silence duration threshold is adjusted to 1.1 times the original value, and the weight of the neural network output sleep probability is adjusted to 0.8 times the original value, thus obtaining adaptive correction control parameters. The audio quality feedback control signal, user habitual characteristic parameters, and adaptive correction control parameters are weighted and fused to dynamically update the system's sleep judgment threshold, spectrum modulation strategy, and DSP processing parameters, thereby achieving continuous optimization and improvement of system performance and obtaining a dynamically optimized control strategy.
[0051] In this invention, a single-microphone configuration is used instead of the traditional multi-microphone array scheme, significantly reducing hardware costs and system complexity. Simultaneously, digital signal processing technology achieves detection accuracy comparable to multi-sensor systems. A Sound Energy Attenuation Detection (SEDA) algorithm is proposed, which quantifies the energy change trend of user sound activity to accurately predict sleep state, effectively solving the misjudgment problem caused by the mixing of environmental noise and user activity sounds. Compared with traditional silence duration statistics or simple volume threshold judgment methods, it has stronger environmental adaptability. A three-layer LSTM-Transformer neural network architecture is adopted, combined with multi-scale temporal modeling and cross-attention mechanisms, to accurately identify complex sound activity patterns during sleep, overcoming the limitations of traditional rule-based judgment methods and providing high-precision sleep state prediction capabilities for single-microphone systems with limited sound samples. Based on the principle of auditory masking, a differentiated spectrum modulation strategy is established, using different attenuation functions for low-frequency, mid-frequency, and high-frequency bands. This fully considers the differences in human auditory sensitivity to different frequency bands, ensuring that the volume reduction process strictly follows the logarithmic attenuation law of human auditory characteristics, significantly improving the naturalness of the listening experience. By utilizing the frequency domain processing technology of DSP chips, amplitude modulation is directly performed in the frequency domain through FFT / IFFT transformation, fundamentally avoiding the quantization noise and nonlinear distortion generated by traditional digital potentiometer control. This maintains the spectral characteristics and phase consistency of white noise, achieving zero-distortion volume fading control. A dynamic feedback control mechanism is established, which, by monitoring the volume fading effect and user feedback in real time, adaptively adjusts parameters based on the user's historical sleep patterns and sound activity habits. This enables personalized sleep detection and volume control strategies, improving the system's intelligence and user experience.
[0052] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0053] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0054] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A sensor-based method for detecting sleepiness using white noise and controlling volume gradual decrease, characterized in that, include: The user's voice signal is acquired using a single microphone in a white noise speaker. Detect sound attenuation characteristics based on the user's voice signal; Based on the sound attenuation characteristics, temporal pattern recognition is performed and the probability of falling asleep is calculated. Based on the sleep probability, the spectral modulation parameters are calculated in conjunction with the auditory masking characteristics. The DSP chip in the white noise speaker performs FFT transformation on the audio playback signal and performs amplitude modulation and IFFT transformation according to the spectrum modulation parameters to output the target audio signal.
2. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 1, characterized in that, The method of acquiring user voice signals using a single microphone in a white noise speaker includes: The system continuously records ambient sound waveforms using a single microphone in a white noise speaker and converts the sound waveforms into a raw sound data stream. Calculate the power spectral density of each frequency component in the original sound data stream, and establish an environmental noise benchmark model based on the power spectral density; Based on the environmental noise baseline model, the noise threshold is calculated and a bandpass filter is used to filter out out-of-band interference in the original sound data stream to obtain the environmental sound signal. Audio segments in the ambient sound signal that exceed the noise threshold are detected and marked as user activity sound segments to obtain the user sound signal.
3. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 1, characterized in that, The step of detecting sound attenuation characteristics based on the user's voice signal includes: Calculate the instantaneous energy of the user's voice signal, and calculate the arithmetic mean of the instantaneous energy; The instantaneous energy is smoothed based on the arithmetic mean to obtain a smoothed energy sequence; The energy decay rate is obtained by calculating the ratio of the energy difference to the time interval based on the smooth energy sequence using a preset sliding window. The system monitors the target period during which the energy decay rate continuously exceeds a preset threshold, and simultaneously calculates the duration of the cumulative sound silence state during the target period. When the duration reaches the target duration, a sleep candidate flag is triggered and a sound decay feature is generated.
4. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 1, characterized in that, The step of performing temporal pattern recognition and calculating the probability of falling asleep based on the sound attenuation characteristics includes: The sound attenuation feature sequence is divided into short-term time-series subsequences, medium-term time-series subsequences, and long-term time-series subsequences; The short-term time series subsequence, the medium-term time series subsequence, and the long-term time series subsequence are respectively input into three parallel bidirectional LSTM encoders. In each bidirectional LSTM encoder, local time series features at different time scales are extracted through a bidirectional gating mechanism and concatenated to output the first feature vector. The first feature vector is input into the multi-head cross-attention Transformer layer for attention weight allocation and feature fusion to obtain the second feature vector; The second feature vector is input into the fusion decoding layer for temporal reconstruction to obtain the probability of falling asleep.
5. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 4, characterized in that, The step of inputting the second feature vector into the fusion decoding layer for temporal reconstruction to obtain the sleep probability includes: The second feature vector is input into a unidirectional LSTM decoder for sequence reconstruction to obtain the third feature vector; Calculate the fusion weights based on the third feature vector and the second feature vector; The third feature vector and the second feature vector are weighted and summed according to the fusion weights to obtain the fused feature vector; The fused feature vectors are sequentially input into a fully connected network, and the sigmoid activation function in the fully connected network is used to compress the fused feature vectors into a sleep probability between 0 and 1.
6. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 1, characterized in that, The step of calculating the spectral modulation parameters based on the sleep probability and auditory masking characteristics includes: Based on the auditory masking characteristics, the white noise spectrum is divided into low-frequency, mid-frequency, and high-frequency bands; When the probability of falling asleep is less than or equal to the first probability value, it is determined to be a waking state. The attenuation coefficients of the low frequency band, the mid frequency band and the high frequency band are all set to maintain the original volume, and the attenuation rate is set to 0 to keep the white noise playback intensity unchanged, so as to obtain the spectrum modulation parameters of the waking state. When the probability of falling asleep is between the first probability value and the second probability value, it is determined to be a light sleep state. The spectral modulation parameters of the light sleep state are calculated based on the low frequency band, the mid frequency band and the high frequency band respectively. When the probability of falling asleep is greater than or equal to the second probability value, it is determined to be a deep sleep state. The spectral modulation parameters of the deep sleep state are calculated based on the low frequency band, the mid frequency band, and the high frequency band, respectively.
7. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 6, characterized in that, The step of determining a light sleep state when the probability of falling asleep is between a first probability value and a second probability value involves calculating spectral modulation parameters for the light sleep state based on the low-frequency band, the mid-frequency band, and the high-frequency band, respectively, including: When the probability of falling asleep is between the first probability value and the second probability value, it is determined to be a light sleep state, and a first attenuation control benchmark for the light sleep state is determined. A slight linear attenuation is applied to the low-frequency band based on the first attenuation control benchmark to obtain a first attenuation coefficient; Based on the first attenuation control benchmark, the mid-frequency band is subjected to moderate linear attenuation to obtain a second attenuation coefficient; Based on the first attenuation control benchmark, the high-frequency band is exponentially attenuated to obtain a third attenuation coefficient; The first attenuation coefficient, the second attenuation coefficient, and the third attenuation coefficient are combined to form the spectral modulation parameters for the light sleep state.
8. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 7, characterized in that, The step of determining a deep sleep state when the probability of falling asleep is greater than or equal to the second probability value involves calculating the spectral modulation parameters of the deep sleep state based on the low-frequency band, the mid-frequency band, and the high-frequency band, respectively, including: When the probability of falling asleep is greater than or equal to the second probability value, it is determined to be a deep sleep state, and a second attenuation control benchmark for the deep sleep state is determined. Based on the second attenuation control benchmark, the low-frequency band is subjected to standard linear attenuation to obtain a fourth attenuation coefficient; Based on the second attenuation control benchmark, the mid-frequency band is enhanced with linear attenuation to obtain the fifth attenuation coefficient; Based on the second attenuation control benchmark, the high-frequency band is subjected to enhanced exponential attenuation to obtain the sixth attenuation coefficient; The fourth attenuation coefficient, the fifth attenuation coefficient, and the sixth attenuation coefficient are integrated into the spectrum modulation parameters for deep sleep state.
9. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 1, characterized in that, The process of using a DSP chip in a white noise speaker to perform FFT transformation on the audio playback signal and perform amplitude modulation and IFFT transformation according to the aforementioned spectrum modulation parameters to output the target audio signal includes: The audio playback signal is divided into 1024 data blocks and input into the hardware FFT accelerator of the DSP chip for fast Fourier transform processing to obtain a complex signal matrix in the frequency domain. Based on the aforementioned spectrum modulation parameters, amplitude modulation operations are performed on each frequency component in the frequency domain complex signal matrix to obtain the modulated frequency domain signal matrix. The modulated frequency domain signal matrix is input into the DSP chip to perform a 1024-point inverse fast Fourier transform to obtain a gradually decreasing time domain audio sequence. The descent time-domain audio sequence is converted into analog audio by the digital-to-analog converter built into the DSP chip, and the target audio signal is output.
10. The sensor-based white noise sound sleep detection and volume gradually decreasing control method according to claim 9, characterized in that, The step of performing amplitude modulation operations on each frequency component in the frequency domain complex signal matrix based on the spectral modulation parameters to obtain the modulated frequency domain signal matrix includes: Extract the first real part and the first imaginary part of each frequency component in the frequency domain complex signal matrix, construct an amplitude matrix based on the first real part and the first imaginary part, and calculate the phase angle of each frequency component using the arctangent function to obtain the phase matrix; Based on the spectrum modulation parameters, the corresponding attenuation coefficients are matched to the corresponding frequency positions in the amplitude matrix to establish a frequency index modulation mapping table. Based on the frequency index modulation mapping table, modulation operation is performed on each frequency component in the amplitude matrix to obtain the modulated amplitude matrix, while keeping all phase angle values in the phase matrix completely unchanged. The second real part and the second imaginary part of each frequency component after modulation are calculated based on the modulated amplitude matrix and the phase matrix, and the modulated frequency domain signal matrix is generated based on the second real part and the second imaginary part.