An algorithm for detecting the height of air column in a water cup based on sound spectrum characteristics
Through the air column height detection algorithm based on sound spectrum characteristics, the problem of water dispenser liquid level detection was solved, the automatic valve closing function was realized, hot water overflow was prevented, and the safety and convenience of the water dispenser were improved.
Patent Information
- Application Number
- CN202211693546.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2042-12-28
AI Technical Summary
Existing water dispensers have difficulty in accurately detecting the liquid level in the water cup, which can cause users to be careless when heating water and cause hot water to overflow, posing a risk of scalding.
An air column height detection algorithm based on sound spectrum characteristics is adopted. The sound signal during the pouring process is collected through a microphone, and the features are extracted using a deep learning model. The post-processing algorithm is combined to predict the air column height in the water cup to achieve water level detection.
It effectively prevents hot water from overflowing, improves the safety and convenience of the water dispenser, and ensures the safety of users.
Smart Images

Figure CN116256040B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of household appliances, and in particular relates to an algorithm capable of detecting the height of a remaining air column in a water cup during a water pouring process and indirectly performing water level detection. Background Art
[0002] Water dispensers with water heating functions are becoming increasingly popular to meet people's drinking water needs. However, existing water dispensers often suffer from the following drawbacks: users must determine when to stop the water valve based on whether their cup is full. This can easily lead to overfilling the cup with hot water, resulting in burns. Therefore, water dispensers with water heating functions pose certain risks to users, especially children.
[0003] Therefore, a water dispenser with a water level detection function is needed to detect the remaining height in the water cup in real time and automatically stop the water valve when the water cup is about to be filled and the user has not manually stopped the water valve, thereby effectively ensuring the safety of the user.
[0004] In the existing technology, there are several mainstream methods for detecting water levels in industrial production:
[0005] Static pressure measurement: This method uses a bottom-mounted pressure sensor to detect the bottom pressure and convert it into the calculated liquid level. However, this method has drawbacks such as high accuracy requirements, the need for the water cup to be placed horizontally with the sensor, the need for constant calibration, and the influence of the water cup's weight, making it difficult to apply in this field.
[0006] Capacitive measurement: This method relies on the principle of capacitive sensing. When the height of the measuring electrode changes, the capacitance of the measured medium changes. It can convert changes in the level of various liquid media into a standard current signal, enabling display, alarms, or automatic control. However, this method suffers from the drawbacks of contact measurement and is susceptible to variations in container materials and solution properties, making it difficult to apply in this field.
[0007] Optical measurement: This measurement method can be divided into laser measurement and photoelectric refraction measurement. Laser measurement is based on the principle of optical detection, reflecting light from the surface of an object to a receiver for detection. Its light spot is small and concentrated. However, transparent liquids easily refract light, preventing it from reaching the receiver. Photoelectric refraction measurement, on the other hand, emits a light source from within the sensor, which is then totally reflected back to the sensor receiver. Upon encountering the liquid surface, some of the light is refracted into the liquid, and the sensor then detects the decrease in the amount of light reflected back to monitor the liquid level. However, this measurement method has different requirements for liquid transparency and is based on the sensor installation position rather than the cup rim, making it difficult to apply in this field.
[0008] Computer vision measurement: This method, based on computer vision principles, extracts features from the cup wall and liquid in the monitoring view to determine the current liquid level. However, this measurement method has drawbacks such as camera contamination from steam and condensation, which can prevent effective viewing; difficulty extracting features from transparent liquids; and noise from water ripples, which can cause algorithm failure. This makes it difficult to apply in this field. Summary of the Invention
[0009] This invention discloses an algorithm for detecting the height of the air column in a water cup based on sound spectrum characteristics. This algorithm can address the difficulty of applying liquid level detection to civilian water dispensers, thereby resolving the problem that existing water dispensers with water heating functions are prone to user negligence during use, resulting in hot water overflowing from the cup and scalding the user.
[0010] To address the aforementioned technical issues, the present invention discloses an algorithm for detecting the air column height within a water cup based on sound spectrum characteristics. This detection algorithm primarily comprises sound reception, a core computing network, and a post-processing algorithm. The algorithm converts the sound signal transmitted by the sound reception module into a spectrum and calculates the remaining air column height within the current water cup. When the cup is nearly full, the sound spectrum characteristics are less pronounced, so post-processing is used to predict the final remaining air column height.
[0011] The above-mentioned detection method for detecting the height of the remaining air column in a water cup is characterized in that the sound receiving algorithm includes a beamforming algorithm.
[0012] Furthermore, in this algorithm, the process of preprocessing the sound of pouring water includes the following steps:
[0013] Step S1: resample the audio with a 16Khz sampling rate and cut it into 2s segments.
[0014] Step S2: Use the STFT algorithm to output the audio spectrum, set the window time length to 32ms, set the frame shift to half the window size, perform FFT after framing, and set the number of FFT points to 512 points, which is consistent with the window size.
[0015] Step S3: truncate the spectrum graph, taking only half of the spectrum, and finally obtain the spectrum graph to be input into the network.
[0016] Furthermore, in this algorithm, the data set for the liquid level state of the pouring water sound includes the following steps: removing data samples with long periods of silence, large areas of static noise, mixed speech, and other noise; adding Gaussian noise with an average amplitude of 1% of the current segment of data to the audio data; randomly increasing or decreasing the frequency samples of the current segment of audio within a range of 5%; and randomly increasing or decreasing the amplitude samples of the current segment of audio within a range of 5%.
[0017] Furthermore, this algorithm utilizes a CNN network in the design of the deep learning model. To enable field deployment on AI chips, a relatively simple CNN network with a relatively small number of parameters is required. This ensures that the model can extract features for water level detection while maintaining a controlled number of parameters for easy field deployment. The network only uses convolutional and fully connected layers supported by the chip. After the convolution generates a feature map, it is flattened and fed into a fully connected layer, which ultimately outputs a vector representing the change in the length of the air column in the water cup over the period corresponding to the input spectrum.
[0018] Moreover, in this algorithm, in order to evaluate the performance of the model, the air column length prediction accuracy is set, and the calculation expression is:
[0019]
[0020] Where L represents the total number of frames, and Represents the predicted value and true value of the t-th frame, and thres represents the set threshold.
[0021] Assume that the model predicts a total of L frames of air column length change vectors, and compares the predicted vector with the true value vector for each frame one by one. If the absolute difference between the predicted value and the true value in a frame is within the preset threshold, it means that the length prediction of this frame is correct. Then the overall accuracy can be expressed as the ratio of the number of predicted correct frames to the total number of frames.
[0022] Moreover, when detecting the water level in a water cup based on audio spectrum features, when the height of the air column in the water cup approaches 0, the audio spectrum features will disappear, making it difficult to predict the final water level. This algorithm proposes a post-processing algorithm, which includes the following steps:
[0023] Step S1: Take a 2-second segment of underwater acoustic spectrum as a frame, shift the frame by 100 milliseconds, and feed each segment of the underwater acoustic spectrum into the CNN network to obtain a list of air column heights, taking the last predicted value.
[0024] Step S2: Every 20 predicted values are taken as a frame, and the frame is shifted by 10 points. The slope of the prediction curve is estimated by the least squares method. The confidence of the current slope is calculated by combining the standard error of the slope coefficient and the set slope threshold. The standard error of the slope coefficient is as follows:
[0025]
[0026] in, represents the true y value, Represents the y-value of the regression.
[0027] Step S3: The reliable predicted slopes obtained in step S2 are weighted and averaged according to their confidence levels to obtain a final slope, which is used to calculate the predicted value when the height of the air column in the water cup is close to 0. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 This is a schematic diagram of microphone installation in the air column height detection method according to an embodiment of the present invention.
[0029] Figure 2 Schematic diagram of the principle of the air column height detection method according to an embodiment of the present invention.
[0030] Figure 3 This is an overall flow chart of the air column height detection method according to an embodiment of the present invention.
[0031] Figure 4 Schematic diagram of the deep learning model structure of the air column height detection method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The following describes the embodiments of the present invention using specific examples and accompanying drawings. Those skilled in the art will readily understand the other advantages and benefits of the present invention from the disclosure herein. The present invention may also be implemented or applied through other different specific examples, and the details in this specification may be modified and altered based on different viewpoints and applications without departing from the spirit of the present invention.
[0033] like Figure 1 As shown, the present invention uses the audio collected by two microphones fixed on the axis of the water outlet as input, increases the signal-to-noise ratio through a beamforming algorithm, and then performs water level detection.
[0034] like Figure 2 As shown in the figure, the principle of the present invention is to indirectly detect the water level by monitoring the height of the remaining air column in the cup during pouring. The input is an audio spectrum captured by two microphones. During the pouring process, there is a distinct bright curve, which is actually the frequency change curve of the corresponding air column vibration. It can be assumed that there is a strong correlation between the height of the water level in the cup and the frequency of the air vibration. The present invention designs a network model to train the corresponding relationship between the two. However, when the cup is nearly full, because the water sound spectrum characteristics are not obvious, post-processing is used to predict the final remaining air column height.
[0035] like Figure 3 As shown, the air column height detection function mainly includes the following steps:
[0036] (1) Constructing an underwater sound dataset, which includes the preprocessing part. First, the dataset of the liquid level status of the pouring water sound includes: removing data samples with long periods of silence, large areas of static noise, mixed speech and other noises; adding Gaussian noise with an average amplitude of 1% of the current segment of data to the audio data; randomly increasing or decreasing the frequency samples of this segment of audio within a range of 5%; randomly increasing or decreasing the amplitude samples of this segment of audio within a range of 5%; followed by the preprocessing of the dataset: including the following steps:
[0037] Step S1: resample the audio with a 16Khz sampling rate and cut it into 2s segments.
[0038] Step S2: Use the STFT algorithm to output the audio spectrum, set the window time length to 32ms, set the frame shift to half the window size, and perform FFT after framing.
[0039] Step S3: truncate the spectrum graph, taking only half of the spectrum, and finally obtain the spectrum graph to be input into the network.
[0040] (2) Construct a deep learning model for air column height detection. The deep learning model is as follows: Figure 4 The network consists of convolutional and fully connected layers. After the convolution operation completes and generates a feature map, it is flattened and fed into a fully connected layer. The final output is a vector representing the change in the length of the air column in the water cup during the time period corresponding to the input spectrogram.
[0041] (3) Training model. The model uses ADAM as the optimizer, the training epoch is set to 350, the initial learning rate is 0.001, and cosine annealing is used as the learning rate descent strategy. The audio samples are trained up to three times. During training, the order of the audio samples is shuffled and randomly organized into batches, with 256 audio samples per batch.
[0042] (4) Evaluate the model using the test set. The prediction accuracy of the air column length is set, and the calculation expression is:
[0043]
[0044] Where L represents the total number of frames, and Denote the predicted and true values for frame t, and thres represents the set threshold. Assuming the model predicts L frames of air column length change vectors, the predicted vectors are compared with the true value vectors for each frame. If the absolute difference between the predicted and true values for a frame is within the preset threshold, the length prediction for that frame is correct. The overall accuracy can be expressed as the ratio of the number of correctly predicted frames to the total number of frames.
[0045] (5) Model deployment and post-processing: The model is deployed on the AI chip, and then the post-processing algorithm is performed. The steps include:
[0046] Step S1: Take a 2-second segment of underwater acoustic spectrum as a frame, shift the frame by 100 milliseconds, and feed each segment of the underwater acoustic spectrum into the CNN network to obtain a list of air column heights, taking the last predicted value.
[0047] Step S2: Every 20 predicted values are taken as a frame, and the frame is shifted by 10 points. The slope of the prediction curve is estimated by the least squares method, and the confidence of the current slope is calculated by combining the standard error of the slope coefficient and the set slope threshold. The standard error of the slope coefficient is as follows:
[0048]
[0049] in, represents the true y value, Represents the y-value of the regression.
[0050] Step S3: The reliable predicted slopes obtained in step S2 are weighted and averaged according to their confidence levels to obtain a final slope, which is used to calculate the predicted value when the height of the air column in the water cup is close to 0.
[0051] By adopting the above technical solution, this algorithm can achieve the following effects:
[0052] By utilizing the characteristics of the sound when pumping water and automatically extracting high-dimensional features through deep learning, the problem that liquid level detection in the existing technology is difficult to apply to civilian water dispensers is effectively solved. This effectively prevents the problem of users negligently overflowing from the cup and scalding the user when using a water dispenser with a water heating function. The safety of water dispensers with a water heating function is improved, and the safety of users is guaranteed. At the same time, the automatic valve closing function further improves the convenience of the water dispenser.
Claims
1. An algorithm for detecting the height of the remaining air column in a water cup during the pouring process of a water dispenser, characterized by: The core computing network's learning model uses a convolutional neural network to extract spectral features, and a fully connected network to regress the true value of the air column height in the water cup. Because the water sound spectrum features are not obvious when the cup is nearly full, a post-processing algorithm is used for final prediction. The post-processing algorithm includes the following steps: Step S1: Using a fixed segment of underwater acoustic spectrum as a frame, the spectrum is fed into the air column height detection deep learning network with a specific frame shift to obtain a list of air column heights, and the last predicted value is taken; Step S2: Taking the prediction value of a fixed number of points as a frame, the prediction value is sent to the least squares method with a specific frame shift to estimate the slope of the prediction curve, and the confidence of the current slope is calculated by combining the standard error of the slope coefficient and the set slope threshold; Step S3: The predicted slopes are weighted and averaged according to their confidence levels to obtain a final slope, which is then used to calculate the predicted value when the height of the air column in the water cup is close to 0.
Citation Information
Patent Citations
Power system short-term load probability forecasting method, device and system
CN109214605A
Intelligent water dispenser system based on sound spectrum feature recognition and control method
CN112043161A