A voice interaction method of a single-chip microcomputer robot and a storage medium
Patent Information
- Application Number
- CN202611395751.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-09
- Publication Date
- 2026-10-23
AI Technical Summary
[0005]针对现有技术存在的单片机资源受限下语义解析效率低、语音模型无法自适应个性化发音以及语音指令与物理动作执行时延不同步的问题,本申请通过一种面向单片机机器人的语音交互方法,利用双数组字典树实现高效语义解析,结合本地模型增量更新与反向动力学补偿,实现了高准确率、低延迟且个性化的语音交互体验
[0007]上述方案通过双数组字典树的第一数组和第二数组协同形成连续的线性存储结构,将字典树的树形节点关系压缩编码为数组索引关系,实现了字典树的高密度压缩和无回溯的前缀匹配,减少了单片机内存的动态申请,解决了单片机资源受限下的高效语义理解与意图识别问题。用声学模型解码,声学模型天然具备一定的泛化能力,比固定模板对口音、语速的容忍度更高,灵活性和泛化能力更好。
Smart Images

Figure CN122967652A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of speech recognition, and in particular relates to a voice interaction method and storage medium for a microcontroller robot. Background Technology
[0002] With the popularization of smart homes and service robots, voice interaction has become one of the most natural and important methods of human-computer interaction. Microcontroller-based robots dominate the consumer and educational robot markets due to their advantages such as low cost, low power consumption, and high integration.
[0003] Currently, in applications targeting the elderly with limited resources, voice interaction technologies mainly fall into three categories: purely cloud-based voice interaction solutions, traditional local keyword retrieval and fixed template matching solutions, and lightweight semantic parsing solutions based on trie trees. Purely cloud-based voice interaction solutions heavily rely on network connectivity, exhibiting significant latency and completely failing in poor or no-network environments. Furthermore, uploading user voice data to the cloud poses a privacy risk. Traditional local keyword retrieval and fixed template matching solutions are extremely sensitive to the speaker's accent and speech rate, lacking flexibility and generalization ability. While lightweight semantic parsing solutions based on trie trees offer high search efficiency, their memory usage often exceeds the capacity of a microcontroller and they do not consider physical latency at the instruction execution level.
[0004] Therefore, there is an urgent need for a voice interaction method and storage medium for microcontroller robots. Summary of the Invention
[0005] To address the problems of low semantic parsing efficiency due to limited microcontroller resources, inability of speech models to adapt to personalized pronunciation, and asynchronous execution delay between voice commands and physical actions in existing technologies, this application proposes a voice interaction method for microcontroller robots. This method utilizes a double-array trie to achieve efficient semantic parsing, and combines local model incremental updates and inverse dynamics compensation to achieve a high-accuracy, low-latency, and personalized voice interaction experience.
[0006] The first aspect of this application proposes a voice interaction method for microcontroller-based robots, including: Acquire speech signals, preprocess the speech signals, and extract acoustic feature vectors; The acoustic feature vectors are input into the local acoustic model for decoding to obtain the text sequence. The text sequence is segmented to obtain slot information including several slot values; The slot information is used as query input, and prefix matching is performed in the double-array dictionary tree pre-stored in the local storage medium of the microcontroller to determine the user intent, which is used to generate the corresponding action instruction. The dual-array trie consists of a first array and a second array. The first array is used to record the base address offset of the state transition, and the second array is used to record the parent node verification information of the target state of the transition. The first array and the second array work together to form a continuous linear storage structure to compress and encode the tree node relationship of the trie into an array index relationship.
[0007] The above scheme forms a continuous linear storage structure through the collaborative operation of the first and second arrays of the dual-array trie. It compresses and encodes the tree-like node relationships of the trie into array index relationships, achieving high-density compression and backtrack-free prefix matching of the trie. This reduces dynamic memory allocation for the microcontroller and solves the problem of efficient semantic understanding and intent recognition under microcontroller resource constraints. Decoding using an acoustic model is further enhanced, as acoustic models naturally possess a certain degree of generalization ability, offering greater tolerance for accents and speech rates than fixed templates, and exhibiting better flexibility and generalization capabilities.
[0008] Preferably, the preprocessing of the speech signal to extract acoustic feature vectors includes: The speech signal is subjected to speech activity detection, and the effective speech signal segments are segmented. The effective speech signal segment is subjected to frequency domain transformation to extract acoustic feature vectors.
[0009] The above scheme accurately segments effective speech signals through speech activity detection, eliminates silence and background noise, and improves the accuracy of feature extraction.
[0010] Preferably, the step of performing frequency domain transformation on the effective speech signal segment to extract acoustic feature vectors includes: After applying a window function to the effective speech signal segment, a fast Fourier transform is performed to extract the Mel frequency cepstral coefficient feature vector or the perceptual linear prediction feature vector.
[0011] The above scheme provides acoustic features that are within the computing power limitations of a single-chip microcomputer by extracting the feature vector of Mel frequency cepstral coefficients or the feature vector of perceptual linear prediction.
[0012] Preferably, the step of inputting the acoustic feature vector into a local acoustic model for decoding to obtain a text sequence includes: The acoustic feature vector is input into the Hidden Markov Model-Gaussian Mixture Model acoustic model, the optimal state sequence is searched through the Viterbi algorithm, the phoneme probability distribution is output, and the phoneme probability distribution is converted into a text sequence.
[0013] The above scheme adopts a hidden Markov model-Gaussian mixture model acoustic model, which has low computational complexity and is suitable for fixed-point arithmetic of microcontrollers.
[0014] Preferably, determining the user intent includes: Find the intent set corresponding to each slot value; take the intersection of all intent sets corresponding to slot values as the final determined user intent.
[0015] The above scheme eliminates intent ambiguity and improves the accuracy of intent recognition by using the intersection verification method.
[0016] Preferably, the method further includes: The action instructions are stored in the instruction execution queue, and the queue depth of the instruction execution queue is monitored in real time. When the queue depth drops to a preset value, an interrupt service routine is triggered. In the interrupt service routine, a reverse braking signal is generated based on the current operating state of the motor.
[0017] The above solution monitors the queue depth of the instruction execution queue and triggers an interrupt service routine when the queue depth drops to a preset value, thereby achieving accurate prediction of the progress of action execution. This allows for the injection of a reverse braking signal in advance before the action is about to end, effectively eliminating the overshoot phenomenon caused by motor inertia and making voice control highly synchronized with robot actions.
[0018] Preferably, generating a reverse braking signal based on the current operating state of the motor includes: Obtain the current motor speed and load inertia; query the preset compensation mapping table to determine the corresponding compensation parameters; A reverse PWM pulse is generated based on the compensation parameters, and the reverse PWM pulse is injected into the motor drive circuit of the microcontroller robot.
[0019] The above scheme achieves precise reverse dynamic compensation by querying a preset compensation mapping table.
[0020] Preferably, the method further includes: Calculate the number of valid voice samples corresponding to the same user intent that have passed verification; When the number of valid speech samples reaches a preset threshold, an incremental update operation on the parameters of the local acoustic model is triggered.
[0021] The above scheme ensures the reliability of model updates by calculating the number of effective speech samples and triggering incremental model updates when a preset threshold is reached, thus enabling the model to adaptively learn users' pronunciation habits.
[0022] Preferably, triggering the incremental parameter update operation of the local acoustic model includes: Extract the acoustic feature vectors of the effective speech samples; New model parameters are calculated based on a clustering algorithm, and the Gaussian component parameters in the local acoustic model are updated using a moving average method. The updated local acoustic model is used to cross-validate historical samples to calculate the recognition confidence. When the recognition confidence exceeds the set threshold, the updated model parameters will be fixed and stored.
[0023] The above scheme ensures the effectiveness of model parameter updates through cross-validation and confidence level verification.
[0024] The second aspect of this application provides a computer-readable storage medium storing a computer program that, when executed, implements the voice interaction method as described in any one of the first aspects. Attached Figure Description
[0025] The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Throughout the drawings, the same reference numerals denote the same components. Obviously, the drawings described below are merely some embodiments described in this application, and those skilled in the art can obtain other drawings based on these drawings.
[0026] Figure 1 This is a flowchart illustrating a voice interaction method for a microcontroller robot provided in an embodiment of this application.
[0027] Figure 2 This is a partial flowchart illustrating a voice interaction method for a microcontroller robot provided in an embodiment of this application. Detailed Implementation
[0028] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. It should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application. Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in this application.
[0029] First, the concepts and some application scenarios involved in this application will be explained: A microcontroller robot refers to a robot that uses a microcontroller as the main control chip to drive peripherals such as motors, sensors, and voice modules. Examples include companion robots for the elderly that can sing, walk, and engage in voice conversations, all of which require human-computer language interaction. Taking the technical solution disclosed in CN206805766U as an example, the remote control device includes a voice drive module integrated into the robot body. The voice drive module is electrically connected to the robot's main control chip and receives voice commands corresponding to the functions of the digital buttons transmitted by the robot's main control chip. It then generates voice drive signals based on the voice commands and outputs them through a speaker.
[0030] In existing technologies, speech recognition and semantic understanding solutions for general-purpose smart terminals (such as smartphones and smart speakers) typically rely on cloud servers for acoustic model decoding and natural language processing, or are deployed locally based on deep neural networks. However, these solutions require a large amount of memory and computing resources. For example, end-to-end deep learning-based speech recognition models typically require tens or even hundreds of megabytes of storage space, and require hundreds of megabytes of RAM during operation. Taking Chinese patent application CN110751953A as an example, a smart voice interaction system is disclosed. This solution runs on an industrial control computer platform, and its hardware resource configuration differs by orders of magnitude from that of a microcontroller. The DFSMN (Deep Feedforward Sequential Memory Network) acoustic model it uses, as a deep learning model, has a large number of parameters, and the inference process involves a large number of matrix multiplication operations, requiring the support of a GPU or high-performance CPU. The semantic understanding of this solution uses a simple database comparison method, that is, matching the recognized text with the operation information in an access database using keywords. This approach is essentially a variant of fixed template matching, lacks the ability to generalize to polysemous words, and does not consider how to achieve fast matching of large-scale instruction dictionaries in resource-constrained environments.
[0031] The single-chip microcomputer robot protected in this application refers to a care robot for the elderly in home / institutional elderly care scenarios with walking interaction functions. Since the target users of this type of robot are the elderly, the language habits, pronunciation characteristics and dialogue logic of users in their voice interaction scenarios are significantly different from those of young and middle-aged people (e.g., heavy dialect accent, slow speech speed, simplified or non-standardized commonly used vocabulary, and voiceprint characteristics that change greatly with age). When the single-chip microcomputer is used as the main controller, it usually only has a few hundred KB to a few MB of RAM / Flash and a main frequency of tens to hundreds of MHz. That is, the extremely limited storage and computing power resources of the single-chip microcomputer are difficult to support the large cloud models or complex edge adaptive learning frameworks mentioned above.
[0032] Furthermore, using traditional local keyword recognition or standard trie for semantic parsing presents challenges. The discrete node storage, high pointer overhead, and reliance on dynamic memory allocation during trie construction can exceed the limited SRAM / Flash capacity of a microcontroller (ranging from a few hundred KB to several MB), leading to memory fragmentation risks. For example, the semantic recognition method, device, terminal, and storage medium disclosed in CN112102840A are used in terminals such as speakers and mobile phones. These devices typically have significantly larger RAM / Flash and high-performance application processors to support the discrete node storage, pointer overhead, and dynamic memory management of the standard trie. Conversely, if the standard trie from CN112102840A is directly ported to a microcontroller robot, not only will the storage overhead of discrete nodes and pointers quickly exhaust the microcontroller's extremely limited memory resources, but the online dynamic construction and expansion process of the trie will also generate severe memory fragmentation problems, ultimately causing the microcontroller system to crash or malfunction.
[0033] Meanwhile, existing solutions often fail to consider the physical delay between the completion of voice command parsing and the actual action of the robot's motors and other actuators, resulting in overshooting or incomplete action execution and a poor user experience.
[0034] Therefore, how to achieve efficient and accurate local voice command recognition and semantic parsing under the constraints of extremely low computing power and storage resources of a microcontroller, and how to solve the time delay synchronization problem between command issuance and physical action, has become the further problem to be solved in this application. The method will be described first, followed by the device.
[0035] Example 1.
[0036] like Figure 1 As shown, this embodiment provides a voice interaction method for microcontroller-based robots. This method runs on a resource-constrained microcontroller platform and aims to solve the problem of traditional voice interaction solutions being difficult to run efficiently in low-computing-power, low-memory environments. The method specifically includes the following steps: Step S101: Acquire the speech signal, preprocess the speech signal, and extract the acoustic feature vector.
[0037] Specifically, the microcontroller acquires the user's voice signal through a connected microphone array. Since the raw voice signal contains a large amount of redundant information and is easily affected by environmental noise, its recognition performance is poor when used directly; therefore, preprocessing is required. The preprocessing process includes operations such as pre-emphasis, framing, and windowing, ultimately extracting acoustic feature vectors that characterize the essential features of the voice. This step transforms the simulated sound waveform into a machine-processable digital feature sequence, laying the foundation for subsequent acoustic decoding.
[0038] Step S102: Input the acoustic feature vector into the local acoustic model for decoding to obtain the text sequence.
[0039] Specifically, the local acoustic model is pre-stored in the microcontroller's Flash memory. The microcontroller inputs the extracted acoustic feature vectors into the model, and through internal probability calculations and path searching, maps the acoustic features to corresponding phonemes or words, ultimately outputting the recognition result in text form. Because the entire process is completed locally, without relying on a cloud server, real-time interaction and privacy security are guaranteed.
[0040] Meanwhile, acoustic model decoding is used. Acoustic models (such as HMM-GMM) are based on statistical probability and naturally have a certain generalization ability, which is more tolerant of accents and speech rates than fixed templates.
[0041] Step S103: Perform word segmentation on the text sequence to obtain word slot information including several slot values.
[0042] Specifically, the decoded text sequence is typically a continuous string, such as "take three steps forward". To accurately understand the user's intent, this string needs to be segmented into semantic units. After segmentation, key slot values are extracted, such as "forward", "walk", and "three steps". These slot values constitute the key input information for subsequent intent recognition. In practice, the segmentation process uses a forward maximum matching method based on a pre-set instruction dictionary: the entries in the instruction dictionary match the slot set stored in the double-array trie, requiring no additional storage space; segmentation starts from the first character of the text sequence, matching the longest entry in the instruction dictionary as a slot value each time, until the end of the text sequence; unmatched continuous character segments are discarded as invalid segments and do not participate in subsequent intent matching, thus avoiding interference from recognition noise on semantic parsing.
[0043] Step S104: The slot information is used as query input, and prefix matching is performed in the double-array dictionary tree pre-stored in the microcontroller's local storage medium to determine the user intent. The user intent is used to generate the corresponding action instruction.
[0044] The core idea of a traditional double-array trie is to compress the pointer-type tree structure of a traditional trie into a continuous linear array index relationship by using two parallel arrays, thereby significantly reducing memory usage while maintaining O(1) query complexity. For example, in input method applications, it is used to store hundreds of thousands or even millions of entries, utilizing its backtracking-free prefix matching feature to achieve fast retrieval of candidate words; in text retrieval engines, it is used as an auxiliary structure for inverted indexes to accelerate the keyword location process.
[0045] However, the aforementioned applications all run on general-purpose computers or high-performance server platforms, whose hardware resources are sufficient to support their offline build process and runtime overhead. Their build process involves complex conflict resolution and array compaction operations, typically requiring offline completion in a resource-rich host computer environment before the generated constant array is embedded into the target system. In the embedded field, especially in scenarios with limited microcontroller resources, there is a lack of in-depth application of this approach. This is because it is generally believed that its high build complexity, the need for offline pre-compilation, and the difficulty in dynamically expanding the array size after it is fixed make it unsuitable for resource-constrained embedded environments. Particularly for the large instruction dictionary in the Chinese context, this structure generates significant pointer overhead, and the scattered node distribution easily leads to memory fragmentation, resulting in the ineffective utilization of the microcontroller's limited RAM resources.
[0046] In this embodiment, the dual-array trie consists of a first array and a second array. The first array records the base address offset for state transitions, and the second array records the parent node verification information for the target state. The first and second arrays work together to form a continuous linear storage structure, compressing and encoding the tree-like node relationships of the trie into array index relationships. Specifically, the first and second arrays are the BASE linear array and the CHECK linear array, respectively. Furthermore, using prefix matching of the dual-array trie instead of a fixed template in the semantic understanding stage provides greater flexibility.
[0047] As an example, the described double-array trie consists of two integer arrays, BASE and CHECK. The construction method for a double-array trie is as follows: The construction process is based on a pre-defined set of instructions for the elderly (e.g., set S = {"Walk forward", "Play a song", "Turn on the light"}), and its construction steps include three core steps: initialization, insertion of instructions, and conflict resolution. 1. Initialize the arrays. Create initial BASE and CHECK arrays, and initialize all elements of the CHECK array to -1, indicating that the state is idle.
[0048] 2. Insert entries according to hierarchy.
[0049] Treat the terms as strings and start building from the root node (state s=0, initial condition BASE set to 1).
[0050] For each character to be inserted (converted to its character encoding c), a state transition position t needs to be found such that CHECK[t] == -1 (idle) and the consistency check is satisfied: if BASE[s] + c == t, then directly mark CHECK[t] = s.
[0051] If a conflict occurs (i.e., the position t pointed to by BASE[s]+c is occupied, and CHECK[t] != -1), then the conflict resolution steps are triggered: the entire child node group of node s needs to be relocated. The value of BASE[s] is adjusted (e.g., BASE[s] is incremented) until s and all its existing child nodes can be mapped to the free position ti through the formula BASE[s]+char_code (satisfying that for all child node characters char_code_i, CHECK[BASE[s]+char_code_i] == -1). Then the data at the original position is migrated to the new position.
[0052] 3. Optimization and Consolidation. After all entries have been inserted from set S, a compaction operation is performed on the BASE and CHECK arrays to remove any unused gaps, resulting in the most compact double-array form. These two final BASE and CHECK arrays, along with the instruction set, can be generated offline on the host computer, compiled into constant arrays, and directly embedded into the Flash storage area of the robot control program.
[0053] During execution and state transition, given the current state s and the encoding of the input character c, the next state next_s is quickly calculated using next_s = BASE[s] + c. The transition is considered valid only if and only if CHECK[next_s] == s. This process is entirely performed within the microcontroller using index operations, without the need for pointer addressing or dynamic memory access.
[0054] Compared to the traditional double-array trie, the double-array trie structure used in this embodiment compresses the tree structure into two parallel linear arrays: a first array and a second array. The first array records the base address (base address offset) for state transitions, and the second array records the parent node verification information (parent node pointer) for the current state. State transitions can be achieved through arithmetic operations on array indices. For example, to transition from the current state to the next state, it is only necessary to calculate the index position of the next state in the array and verify whether the value at the corresponding position in the second array is equal to the index of the current state to determine whether the transition is valid. This mechanism eliminates pointer storage overhead, maps the originally discrete tree nodes to continuous array elements, compresses storage space, and achieves a query efficiency of O(1) complexity (constant time complexity), making it very suitable for running on resource-constrained microcontrollers.
[0055] Therefore, it can be understood that the dual-array Trie is not a universally efficient structure. In this application, it is designed to solve the problem of "both implementing local instruction set lookup optimized for the elderly and rigidly squeezing it into the microcontroller's SRAM." Specifically, since the instruction set used by the elderly is relatively fixed, the dual-array Trie can be constructed offline and embedded as a fixed constant in the microcontroller's Flash (program memory), loaded at startup. Because dynamic construction at runtime is eliminated, operational stability and determinism are guaranteed, making it suitable for elderly care products with extremely high system reliability requirements.
[0056] Meanwhile, the elderly's interactive context is relatively fixed but requires strong robustness, but hardware resources are limited. In this case, if a cloud-based solution is used, the large computational load, network latency, and concerns about the elderly's privacy will affect product promotion. As mentioned above, the standard Trie local solution has high memory requirements and is prone to fragmentation. Although static hash tables have the possibility of O(1) time complexity, they do not support fuzzy matching or prefix matching, and the elderly's speech is ambiguous, such as mispronouncing words, making the function not robust enough. In this case, the above-mentioned dual-array Trie has controllable memory usage, no fragmentation, and supports prefix matching.
[0057] This embodiment employs a dual-array trie for semantic parsing. By utilizing the collaborative mechanism of the first and second arrays, the tree-like node relationships of the trie are compressed and encoded into continuous linear array index relationships. This not only eliminates the significant pointer overhead of traditional tree structures and effectively avoids memory fragmentation, but also achieves constant-level optimization of query complexity. This design enables the storage of a larger instruction dictionary within the limited memory resources of a microcontroller while maintaining extremely high query response speed, thus solving the problem of efficient semantic understanding and intent recognition under microcontroller resource constraints.
[0058] In practical applications, once the user's intent is determined, the intent label is converted into machine-executable control instructions based on a preset mapping relationship. For example, if the identified intent is "move forward," an action instruction containing parameters such as motor speed and rotation direction is generated to drive the motor to perform the corresponding action.
[0059] In one exemplary embodiment, the dual-array trie is pre-built offline by a host computer and stored in the Flash memory of the microcontroller, and loaded into the SRAM of the microcontroller at runtime; The prefix matching includes: calculating a candidate index value based on the current state and the encoded value of the input character; when the value of the second array corresponding to the candidate index value is equal to the current state, the state transition is deemed valid, and matching continues with the updated state; when the value of the second array corresponding to the candidate index value is not equal to the current state, the matching is deemed to have failed. The state transition is accomplished through array indexing operations and does not involve dynamic memory allocation or pointer addressing.
[0060] In one exemplary embodiment, the preprocessing of the speech signal and the extraction of acoustic features are described in detail. Due to the limited resources of a microcontroller, directly processing the entire continuous audio stream would consume a significant amount of computing power; therefore, it is necessary to accurately locate effective speech segments and extract key features.
[0061] Specifically, the speech signal is preprocessed to extract acoustic feature vectors, including: Speech activity detection is performed on the speech signal to segment the effective speech signal segments; frequency domain transformation is performed on the effective speech signal segments to extract acoustic feature vectors.
[0062] The Voice Activity Detection (VAD) method employs a dual-threshold segmentation approach. Specifically, it calculates the short-time energy and zero-crossing rate of audio frames in real time. The short-time energy reflects the amplitude of the signal, while the zero-crossing rate reflects the frequency characteristics of the signal.
[0063] A higher energy threshold is preset as the speech start criterion, and a lower energy threshold is preset as the speech end criterion. When the short-term energy of an audio frame first exceeds the higher threshold, it is marked as the speech start point; when the short-term energy remains below the lower threshold for a preset duration (e.g., 300 milliseconds), it is marked as the speech end point. This dual-threshold logic effectively eliminates silent segments and background noise segments, retaining only the valid speech signal segments containing user commands. This preprocessing method reduces the data processing workload of subsequent feature extraction and acoustic decoding, which is crucial for microcontrollers with limited computing power, significantly reducing power consumption and improving response speed.
[0064] Furthermore, frequency domain transformation is performed on the effective speech signal segment to extract acoustic feature vectors, including: applying a window function to the effective speech signal segment and then performing a fast Fourier transform to extract the Mel frequency cepstral coefficient feature vector or the perceptual linear prediction feature vector.
[0065] Specifically, the segmented effective speech signal segments are first processed into frames, each typically lasting 20 to 30 milliseconds with an overlap of about 10 milliseconds between frames to ensure the continuity of feature information. Then, a window function is applied to each frame; in this embodiment, a Hamming window is preferred. Its function is to reduce spectral leakage, making the spectrum smoother after frequency domain transformation and avoiding high-frequency interference caused by the Gibbs effect. Next, a Fast Fourier Transform (FFT) is performed on the windowed signal to convert the time-domain signal into a frequency-domain signal, obtaining a linear spectrum. Considering that the human ear's perception of different frequencies is non-linear, the linear spectrum is further filtered using a Mel filter bank to simulate the auditory perception characteristics of the human ear. Finally, the logarithm of the filtered energy spectrum is taken and a Discrete Cosine Transform (DCT) is performed to obtain the Mel Frequency Cepstral Coefficients (MFCC) eigenvector. The MFCC eigenvector has good noise resistance and discriminative ability, and its computational complexity is moderate, making it very suitable for fixed-point arithmetic on a microcontroller.
[0066] It should be understood that in other embodiments, perceptual linear prediction (PLP) feature vectors can also be used as an alternative, which can also simulate the characteristics of human hearing and is suitable for specific noisy environments. Through the above processing, the original speech waveform is transformed into a compact and representative sequence of acoustic feature vectors, providing high-quality input data for subsequent acoustic model decoding.
[0067] In an exemplary embodiment, the acoustic feature vector is input into a local acoustic model for decoding to obtain a text sequence, including: The acoustic feature vectors are input into the Hidden Markov Model-Gaussian Mixture Model acoustic model. The optimal state sequence is searched using the Viterbi algorithm, the phoneme probability distribution is output, and the text sequence is converted based on the phoneme probability distribution.
[0068] This embodiment selects a Hidden Markov Model-Gaussian Mixture Model (HMM-GMM) as the local acoustic model, taking into account the special hardware environment of limited microcontroller resources. Compared to end-to-end models such as Deep Neural Networks (DNNs) or Recurrent Neural Networks (RNNs), the HMM-GMM model has extremely low computational complexity and storage overhead. DNN models typically require millions of floating-point matrix multiplications, and the number of model parameters often reaches tens of megabytes, which is an unbearable burden for microcontrollers with only a few hundred KB of memory and limited clock speed. In contrast, the HMM-GMM model mainly consists of a state transition probability matrix and Gaussian mixture model parameters. Its operation process mainly involves simple table lookups and probability accumulation operations, making it very suitable for fixed-point arithmetic optimization on a microcontroller, enabling speech recognition functionality while ensuring real-time performance.
[0069] The core of the decoding process lies in the application of the Viterbi algorithm. The Viterbi algorithm is a dynamic programming algorithm for finding the most probable hidden state sequence (i.e., phoneme state sequence) that generates a given observation sequence (i.e., acoustic feature vector sequence). Specifically, the microcontroller inputs the extracted MFCC feature vector sequence frame by frame into the HMM-GMM model. For each frame of feature vector, the Gaussian mixture model output probability (i.e., emission probability) corresponding to each phoneme state is calculated, and the cumulative probability is recursively calculated through the Viterbi algorithm in combination with the state transition probability. During the recursion process, the algorithm maintains a path record table that records the optimal path to reach each state. After all frames are processed, the path record table is backtracked to find the state sequence with the maximum probability as the optimal state sequence.
[0070] This optimal state sequence corresponds to a set of phoneme sequences. The phoneme sequence is further converted into a text sequence according to a preset dictionary or pronunciation lexicon. For example, if the phoneme sequence corresponding to the optimal state sequence is "x i a n g q i a n z o u", it is mapped to the text "move forward". Through the above process, the conversion from acoustic features to text is completed locally on the microcontroller without relying on a cloud server, which effectively solves the problems of network delay and privacy leakage, while ensuring the real-time performance and accuracy of recognition.
[0071] In an exemplary embodiment, determining the user intent includes: looking up the intent set corresponding to each slot value; and taking the intersection of the intent sets corresponding to all slot values as the finally determined user intent.
[0072] In actual voice interaction scenarios, user instructions are often composed of multiple words, such as "move forward three steps". After word segmentation processing, the extracted slot values may include "forward", "move", and "three steps". In the pre-stored instruction mapping relationship, a single slot value often corresponds to multiple possible intents. For example, the slot value "forward" may correspond to the intent set A={move forward, look forward, roll forward}, and the slot value "move" may correspond to the intent set B={move forward, move backward, march in place}. If matching is performed only based on a single slot value, misjudgment is very likely to occur, resulting in the robot performing wrong actions.
[0073] To address the ambiguity issue arising from this multi-slot combination (polysemous word disambiguation), this embodiment employs the intersection verification method. During the state transition process of the double-array trie, not only is the existence of the path checked, but the intent set corresponding to each slot value is also maintained in real time. When the slot value "forward" is successfully matched in the trie, the node is located using the index operation of the first and second arrays, and the intent set A attached to that node is extracted. Subsequently, the next slot value "go" is matched, and its corresponding intent set B is extracted as well. At this point, the intersection operation is performed on sets A and B to obtain the intersection result {move forward}. This intersection result is the final intent after disambiguation.
[0074] It should be understood that the core logic of the intersection verification method lies in the fact that a correct user intent must simultaneously satisfy the semantic constraints of all slot values. By taking the intersection, interfering intents that only partially satisfy the semantics of slots are effectively eliminated, thus significantly improving the accuracy and robustness of intent recognition. For long instructions containing three or more slot values, the intersection of each intent set is calculated sequentially, ultimately yielding the unique and most accurate user intent. This mechanism is particularly important in environments with limited microcontroller resources because it does not require the introduction of complex deep learning semantic understanding models; it achieves efficient disambiguation through simple set operations, reducing computational overhead.
[0075] See Figure 2 In one exemplary embodiment, the method of this embodiment further includes: Step S105: Store the action command in the command execution queue and monitor the queue depth of the command execution queue in real time; Step S106: When the queue depth drops to a preset value, the interrupt service routine is triggered; Step S107: In the interrupt service routine, a reverse braking signal is generated based on the current operating state of the motor.
[0076] In the control of microcontroller-based robots, there are multiple levels of delay from the completion of voice command parsing to the complete cessation of the motor's physical movement. At the software level, this includes the time for command parsing and logical judgment; at the hardware level, it includes the response time of the motor drive circuit and the mechanical inertia time of the motor rotor. Traditional control schemes often apply reverse braking force only after detecting that the motor has stopped rotating. This is a post-compensation measure, which often struggles to accurately control the stopping position, leading to nodding or sliding phenomena in the robot. This embodiment employs a predictive compensation mechanism based on command queue prediction. Just before the action command is about to be executed, a reverse braking signal is predicted and injected in advance, thereby physically offsetting inertia and achieving precise time delay compensation.
[0077] Furthermore, the method also includes: The queue depth of the instruction execution queue is monitored in real time; when the queue depth drops to a preset value, an interrupt service routine is triggered; in the interrupt service routine, a reverse braking signal is generated based on the current operating state of the motor.
[0078] The microcontroller maintains a first-in, first-out (FIFO) instruction execution queue to buffer pending action instructions. The queue depth refers to the number of instructions currently in the queue that have not been completed. This queue depth is monitored in real time. The default value is typically set to 1 or 2, indicating that the action is about to end when it is about to become the currently executing instruction or the second-to-last instruction. At this point, a hardware timer generates an interrupt signal, triggering the interrupt service routine. This queue depth-based predictive mechanism allows compensation logic to be initiated within milliseconds before the physical end of the action (e.g., 50ms to 300ms before the action ends), providing a valuable time window for subsequent reverse braking.
[0079] Furthermore, a reverse braking signal is generated based on the current operating state of the motor, including: obtaining the current motor speed and load inertia; querying a preset compensation mapping table to determine the corresponding compensation parameters; generating a reverse PWM pulse based on the compensation parameters, and injecting the reverse PWM pulse into the motor drive circuit of the microcontroller robot.
[0080] The specific logic for generating the reverse braking signal is the core of this embodiment. The microcontroller obtains the real-time speed of the motor by reading the feedback signal from the motor driver chip or through the encoder, and estimates the load inertia based on the robot's load conditions (such as whether it is carrying a heavy load). The compensation mapping table is pre-stored in the microcontroller's Flash memory, recording the optimal compensation parameters required for different combinations of speed and load inertia, including the duty cycle and duration of the reverse PWM pulse.
[0081] For example, when the motor speed is high and the load inertia is large, the compensation mapping table will indicate a longer reverse pulse duration; conversely, a shorter duration. The interrupt service routine dynamically generates a reverse PWM pulse based on the retrieved compensation parameters and immediately injects it into the motor drive circuit. This reverse PWM pulse generates an electromagnetic torque opposite to the motor's current rotation direction. This torque precisely counteracts the remaining kinetic energy of the motor shaft, causing the motor to physically stop rotating synchronously at the moment the software instruction ends. It should be understood that the timing and parameters of the reverse PWM pulse injection are experimentally calibrated based on the specific motor model and robot characteristics; different hardware platforms may have different compensation mapping tables.
[0082] Through this hardware and software collaborative prediction and compensation mechanism, this embodiment effectively eliminates the overshoot phenomenon caused by motor inertia, making voice control and robot actions highly synchronized, and significantly improving the user's interactive experience.
[0083] As an example, considering the need for real-time interaction and immediate feedback, synchronous reverse dynamics compensation and predictive interruption mechanisms are required.
[0084] For elderly users whose reactions may be slower, lag or overshoot in robot movements can significantly reduce trust and user experience. Therefore, instead of simply executing open-loop motion commands, the robot predicts the imminent completion of a movement by monitoring the command execution queue and applies pre-emptive, rather than post-event, reverse braking based on real-time feedback (motor speed, load inertia). This precise prediction and control logic of movement timing ensures, at the mechanical level, the immediate response in the user's psychological perception (regarding the elderly person's expectations), rather than absolute physical zero delay; it differs from the path planning of general-purpose robots.
[0085] In one exemplary embodiment, because different users have different pronunciation habits, accents, and even environmental noise, a fixed acoustic model can hardly maintain a high recognition rate in all scenarios. Therefore, this embodiment introduces local learning capabilities, enabling the robot to understand users better with repeated use.
[0086] Specifically, the method in this embodiment further includes: calculating the number of valid voice samples corresponding to the same user intent that have passed verification; When the number of valid speech samples reaches a preset threshold, an incremental update operation on the parameters of the local acoustic model is triggered.
[0087] In this context, valid voice samples refer to those voice command samples that have been successfully recognized and confirmed as correctly executed. The verification mechanism can include various methods: for example, when a user issues a command, the robot executes the corresponding action. If the user does not issue a negative or corrective command (such as "incorrect" or "cancel"), the sample is considered valid. Furthermore, a valid sample is only deemed valid if the recognition confidence score output by the acoustic model exceeds a preset high confidence threshold (such as 0.9). This screening mechanism helps ensure the accuracy of the data source used for model updates and reduces the contamination of model parameters by erroneous samples.
[0088] The microcontroller maintains a sample counter in its Flash memory to count the number of valid speech samples accumulated for each specific instruction (such as "go forward"). Considering the microcontroller's computational limitations, real-time model updates would consume significant resources and disrupt normal interaction; therefore, this embodiment employs a batch triggering mechanism. A preset threshold can be set based on hardware performance, for example, 42 samples. When 42 valid samples are accumulated for the "go forward" instruction, sufficient data is considered, triggering a background incremental update task. This threshold-triggered mechanism balances the real-time nature of model updates with operational efficiency, avoiding the computational burden of frequent updates.
[0089] As an example, during the accumulation of valid speech samples, when the number of valid samples has not reached a preset threshold, the microcontroller performs online adaptation of the Gaussian component parameters of the local acoustic model based on the accumulated valid samples. The adapted parameters are immediately used for recognition and decoding but are not written to Flash. When the number of valid samples reaches the preset threshold, an incremental update operation of the local acoustic model parameters is triggered. After cross-validation, the parameters are written to Flash for permanent storage, replacing the parameters used during online adaptation. Thus, the recognition accuracy gradually improves with online adaptation during sample accumulation and is determined by permanent update after reaching the preset threshold.
[0090] Furthermore, the incremental update operation of the local acoustic model is triggered, including: extracting the acoustic feature vectors of valid speech samples; calculating new model parameters based on clustering algorithms and updating the Gaussian component parameters in the local acoustic model using the moving average method; cross-validating historical samples using the updated local acoustic model and calculating the recognition confidence; and storing the updated model parameters when the recognition confidence exceeds a set threshold.
[0091] Specifically, the update process is executed during the microcontroller's idle periods (such as at night, or in charging or standby mode). First, 42 accumulated valid speech samples are read from Flash memory, and their MFCC feature vectors are extracted. Then, a lightweight clustering algorithm (such as K-Means clustering) is called to perform cluster analysis on these feature vectors, calculating new cluster centers. During clustering, the distance between the acoustic feature vector of each valid speech sample and its corresponding cluster center is calculated, and outlier samples exceeding a preset distance threshold are removed to prevent misidentified samples from participating in the calculation of model parameters. In the HMM-GMM acoustic model, these cluster centers correspond to the mean vector in the Gaussian mixture model. To prevent drastic fluctuations in model parameters due to new data, this embodiment uses a moving average method to smoothly update the Gaussian component parameters. In this way, the model parameters are fine-tuned to reflect the user's personalized pronunciation features while retaining existing knowledge. Since the hidden Markov model states corresponding to different instructions share the underlying Gaussian mixture components, the update effect of the effective samples accumulated for a single user intent after clustering and updating can be transmitted to other instructions containing the same phonemes through the shared Gaussian mixture components, thereby improving the overall recognition accuracy with limited samples.
[0092] To address the issue of non-standard pronunciation and dialectal adaptation among elderly users, a local incremental learning acoustic model (HMM-GMM, incremental parameter update) is required.
[0093] To facilitate understanding, an example is provided. Considering the heavy regional accents of elderly people, the recognition rate of general GMM parameters will significantly decrease. To address this issue, this example designs a minimalist yet effective incremental learning framework locally: During charging or standby intervals, the personalized GMM mean parameters of successfully validated voice command samples are updated using lightweight K-Means clustering. This process is performed entirely locally, as a typical engineering adaptation to overcome situations where computing power is limited (microcontrollers cannot run deep neural networks) but user characteristics deviate from the standard model (elderly pronunciation).
[0094] To ensure the effectiveness of the update, this example also introduces a verification mechanism. The updated model parameters are cross-validated against samples in the historical sample library. If the verification results show that the average recognition confidence has improved compared to before the update and exceeds a set threshold, the update is considered successful, and the new model parameters are permanently written to the model area of the Flash memory, replacing the old parameters. Conversely, if the confidence decreases or fails to meet the threshold, the update is abandoned, and the original model parameters are retained. This closed-loop verification logic effectively prevents model performance degradation caused by noisy data or abnormal samples, ensuring stability during long-term use. Through this mechanism, the robot can autonomously adapt to the user's personalized pronunciation habits without cloud intervention, improving recognition accuracy in specific user scenarios.
[0095] As another example, a voice interaction method for microcontroller-based robots is provided, including: Acquire a speech signal, perform speech activity detection on the speech signal, and segment the speech signal into effective speech signal segments; apply a window function to the effective speech signal segments and then perform a fast Fourier transform to extract the Mel frequency cepstral coefficient feature vector or the perceptual linear prediction feature vector. The acoustic feature vector is input into the Hidden Markov Model-Gaussian Mixture Model acoustic model, the optimal state sequence is searched through the Viterbi algorithm, the phoneme probability distribution is output, and the text sequence is converted based on the phoneme probability distribution. The text sequence is segmented to obtain slot information including several slot values; Using the slot information as query input, prefix matching is performed in the double-array trie pre-stored in the microcontroller's local storage medium to find the intent set corresponding to each slot value; the intersection of all intent sets corresponding to slot values is taken as the final determined user intent, which is used to generate the corresponding action instruction; The action instructions are stored in the instruction execution queue, and the queue depth of the instruction execution queue is monitored in real time; When the queue depth drops to a preset value, an interrupt service routine is triggered. In the interrupt service routine, the current motor speed and load inertia are obtained; the preset compensation mapping table is queried to determine the corresponding compensation parameters; A reverse PWM pulse is generated based on the compensation parameters, and the reverse PWM pulse is injected into the motor drive circuit of the microcontroller robot.
[0096] The method further includes: calculating the number of valid voice samples corresponding to the same user intent that has passed verification; When the number of valid speech samples reaches a preset threshold, the acoustic feature vector of the valid speech samples is extracted. New model parameters are calculated based on a clustering algorithm, and the Gaussian component parameters in the local acoustic model are updated using a moving average method. The updated local acoustic model is used to cross-validate historical samples to calculate the recognition confidence. When the recognition confidence exceeds the set threshold, the updated model parameters will be fixed and stored.
[0097] The dual-array trie consists of a first array and a second array. The first array is used to record the base address offset of the state transition, and the second array is used to record the parent node verification information of the target state of the transition. The first array and the second array work together to form a continuous linear storage structure to compress and encode the tree node relationship of the trie into an array index relationship.
[0098] Based on the above examples, the beneficial effects of the technical solution provided in this embodiment will be explained: Compared to related technologies, the underlying solutions are designed for "smart terminals, such as speakers and mobile phones." These devices typically have several gigabytes of memory and high-performance multi-core application processors, which can easily handle the dynamic memory allocation, pointer overhead, and resulting memory fragmentation issues brought about by the "standard Trie tree." This application considers the application of the standard Trie tree in microcontroller robots, for example, taking the typical instruction set of an elderly care robot (approximately 3000 core words / phrases, considering synonyms and colloquial expressions) as an example, and constructs a standard Trie tree. Its memory overhead is analyzed: In terms of node structure, each node needs to store at least: an array of pointers to multiple child nodes, current character information, status flags, etc.
[0099] In terms of pointer overhead, in the 32-bit architecture of microcontrollers (such as the Cortex-M series), a pointer typically occupies 4 bytes.
[0100] In a practical estimation, assuming the Trie consisting of these 3,000 words has approximately 10,000 nodes, the overhead of pointers alone could reach tens or even hundreds of KB. This does not include the memory fragmentation caused by uneven pointer allocation among a large number of intermediate nodes.
[0101] The robot described in this application uses a microcontroller platform, whose static random access memory (SRAM) is typically only a few hundred KB. This not only needs to store the Trie structure but also simultaneously run a real-time operating system (RTOS), perform speech decoding (HMM-GMM algorithm), and maintain the instruction queue. The memory footprint of a standard Trie and its unpredictable fragmentation risk can easily lead to system crashes due to insufficient memory during deployment or access errors caused by memory fragmentation during runtime.
[0102] The technical solution provided in this application compresses the tree structure of a standard Trie into two static arrays (BASE and CHECK). The BASE array records the base address offset for state transitions, and the CHECK array records the parent node pointer. Furthermore, the lengths of BASE and CHECK are equal. This is because, in embedded systems using microcontrollers, memory management needs to be as simple and predictable as possible. With the two arrays of equal length, both arrays can be copied simultaneously using the same loop.
[0103] Meanwhile, the above structure completely abandons dynamic node pointers, storing the data structure as a continuous, linear, read-only static array. This not only reduces storage overhead (each node only needs to store two integer indices, typically 2-4 bytes each), but more importantly, it can be pre-compiled and stored on the microcontroller's Flash (which stores code and data), and accessed directly at runtime through constant array indices, avoiding the fragmentation problem of SRAM.
[0104] In terms of query efficiency matching scenarios, its query time complexity is still O(m) (where m is the word length), and it is a pure array operation, which is suitable for serial processing and cache optimization of microcontrollers.
[0105] Therefore, the above improvement is an extreme resource-optimized structure that can both meet the semantic recognition function and adapt to the hardware under the dual constraints of a specific hardware platform (a microcontroller with a few hundred KB of SRAM) and a specific application scenario (such as localized voice interaction for the elderly). Standard Trie is physically unsuitable for deployment.
[0106] The following set of experimental data further illustrates the beneficial effects of this embodiment.
[0107] Experimental conditions include: The hardware platform is an STM32F407ZGT6 (168MHz Cortex-M4, 192KB SRAM, 1MB Flash); the microphone is an INMP441 MEMS; the motor is an MG513P30 geared DC motor and encoder.
[0108] Regarding the test subjects, the vocabulary sizes were 500 / 1500 / 3000 instructions (covering high-frequency instructions in elderly care scenarios, including synonyms and colloquial expressions; the following comparisons are all averages of the three categories); the number of test subjects was 50 (25 in the Mandarin group and 25 in the group with regional accents, aged 60-80).
[0109] Regarding noise levels, the quiet environment (<40dB) and 60dB background noise (simulated TV sound, kitchen environment) are acceptable.
[0110] The benchmarks for comparison are the standard Trie tree, the cloud-based ASR solution (a mainstream cloud voice SDK), and the solution without compensation.
[0111] The data source is actual measurement data. Each test group was repeated 10 times and the average value was taken. The fluctuation range is within ±5%.
[0112] Refer to Table 1 below. First, compare the memory usage of a double-array trie and a standard Trie: Table 1 Memory Usage Comparison Table
[0113] As can be seen, the standard Trie, including pointer overhead (4B per node × number of child nodes) and memory fragmentation reservation (approximately 15%), and the dual-array Trie, containing only two int16_t arrays (BASE / CHECK), have no dynamic allocation. With a vocabulary of 3000 entries, the standard Trie is close to the STM32F407 SRAM limit (192KB), posing a runtime OOM risk; the remaining SRAM of the dual-array Trie can simultaneously support RTOS, acoustic decoding, and HMM inference.
[0114] Refer to Table 2 below for the test of the change in recognition accuracy before and after incremental learning using the technical solution of Example 1: Table 2 Comparison of Recognition Accuracy
[0115] Accumulating 42 samples takes approximately 2-3 weeks under typical usage frequency (3-5 instructions per day). After the update, the accuracy rate for accented users improved by 15.5 percentage points, validating the effectiveness of local incremental learning.
[0116] See Table 3 below for a comparison of end-to-end response delays: Table 3 End-to-end response delay comparison table
[0117] As shown in Table 3, even without VAD (Voice Activity Detection) optimization, this solution, due to its lightweight architecture of local HMM decoding and dual-array trie, still has a significantly lower end-to-end latency (312ms) than the cloud-based ASR solution (842ms), demonstrating a fundamental advantage in real-time performance. With further VAD optimization, the end-to-end latency is drastically reduced to below 200ms, exceeding the psychological expectation threshold for elderly interaction (<300ms).
[0118] See Table 4 below for a comparison of motor reverse compensation accuracy: Table 4 Comparison of Motor Control Accuracy
[0119] The compensation parameters were calibrated experimentally. The PWM reverse pulse duty cycle is adjustable from 20% to 60%, and the duration is 15-80ms. After compensation, the stop position deviation is <6mm, which meets the motion accuracy requirements (<10mm) of the elderly care robot.
[0120] The technical solution provided in this embodiment uses the moving average method to update the Gaussian component parameters in the local acoustic model (see Table 5 below) to verify the influence of the moving average coefficient α on the model convergence: Table 5. Convergence Stability Comparison Table
[0121] It can be seen that α=0.05 achieves the best balance between convergence speed and stability, and is therefore chosen as the default parameter.
[0122] The cross-validation threshold (i.e. the set threshold corresponding to the recognition confidence) can be set to 0.82. If it is lower than this value, the solidification update will be abandoned.
[0123] In summary, the voice interaction method for microcontroller robots provided in this application leaves crucial computational and memory margins for other modules through the O(1) query efficiency of the double-array trie. Given the limited SRAM and Flash resources of the microcontroller, the semantic parsing module uses a double-array trie instead of a traditional trie, reducing memory usage. This memory saving provides necessary runtime space for storing parameters of the local acoustic model, caching samples during incremental learning, and interrupt service routines related to motor control. Simultaneously, the constant-time query complexity of the double-array trie compresses the time consumed in the semantic parsing stage, leaving sufficient computational margins for subsequent motor control responses. If a traditional trie or other highly complex semantic parsing scheme is used, its memory overhead and computational latency will directly consume resources of other modules, leading to a decline in overall system performance or even system failure. The incremental update mechanism of the local acoustic model indirectly reduces the risk of motor malfunction by improving recognition accuracy.
[0124] For example, in scenarios involving elderly care, the user's accent, speech rate variations, and voiceprint feature variations are the main factors leading to speech recognition errors. Recognition errors directly generate incorrect action commands, causing the robot to perform physical actions inconsistent with the user's intentions. This not only affects the interactive experience but may also threaten the personal safety of elderly users. This application utilizes a local incremental learning mechanism to enable the acoustic model to adapt to the specific pronunciation characteristics of users, improving the recognition accuracy for users with accents. Improved recognition accuracy means a significant reduction in the probability of issuing erroneous commands, thereby reducing the occurrence of motor malfunctions at the source. Incremental updates reduce actions that should not be performed, and braking compensation optimizes the accuracy of the actions that should be performed; both work together to ensure the safety and reliability of the microcontroller-based robot motion control.
[0125] Example 2.
[0126] This embodiment provides a computer-readable storage medium storing a computer program that, when executed, implements the voice interaction method as described in any of the above embodiments.
[0127] Specifically, a computer-readable storage medium is a key carrier in a microcontroller system for persistently storing program code and data. In this embodiment, the medium is specifically a non-volatile memory on the robot's main control board. It should be understood that, depending on the microcontroller hardware architecture, the medium can have various specific physical forms. As one implementation, the medium can be the internal Flash memory of the microcontroller. Flash memory has the characteristics of moderate capacity, fast read speed, and no data loss when power is off, making it very suitable for storing the voice interaction firmware described in this invention, including the operating system kernel, acoustic model parameters, the first and second arrays of the dual-array dictionary data, and the compensation mapping table, etc. When the system powers on, the processor directly reads instructions from the internal Flash and executes them, realizing the entire process of voice signal acquisition, preprocessing, acoustic decoding, semantic parsing, and motion control. As another implementation, the medium can also be an external memory card, such as an SD card or a TF card. In this architecture, the microcontroller connects to the memory card through an SPI interface or an SDIO interface. This design allows the system to store larger-scale acoustic models or richer voice command libraries, suitable for application scenarios with high vocabulary requirements. In addition, the medium can also be other forms of memory, such as EEPROM or NOR Flash, used to store user-customized configuration data or incrementally updated model parameters.
[0128] The computer program in this embodiment contains several instructions that, when executed by the processor, can specifically implement the various steps described in the preceding embodiments. For example, the program includes drive instructions for controlling the ADC to acquire audio data; mathematical operation instructions for performing FFT transform and MFCC feature extraction; search instructions for implementing Viterbi algorithm decoding; and interrupt service instructions for maintaining the instruction execution queue and generating PWM control signals. These instructions are stored in the medium in the form of binary machine code or intermediate code, forming the software foundation of the entire voice interaction system. By solidifying the above method logic into a computer program and storing it in a computer-readable storage medium, this embodiment realizes the materialization and distributability of the technical solution, enabling any single-chip microcomputer robot with corresponding hardware capabilities to obtain efficient, low-latency, and personalized learning-capable voice interaction functions by loading and running the program on the medium.
[0129] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments 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; and these 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. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application.
Claims
1. A voice interaction method for microcontroller-based robots, characterized in that, include: Acquire speech signals, preprocess the speech signals, and extract acoustic feature vectors; The acoustic feature vectors are input into the local acoustic model for decoding to obtain the text sequence. The text sequence is segmented to obtain slot information including several slot values; The slot information is used as query input, and prefix matching is performed in the double-array dictionary tree pre-stored in the local storage medium of the microcontroller to determine the user intent, which is used to generate the corresponding action instruction. The dual-array trie consists of a first array and a second array. The first array is used to record the base address offset of the state transition, and the second array is used to record the parent node verification information of the target state of the transition. The first array and the second array work together to form a continuous linear storage structure to compress and encode the tree node relationship of the trie into an array index relationship.
2. The voice interaction method according to claim 1, characterized in that, The preprocessing of the speech signal to extract acoustic feature vectors includes: The speech signal is subjected to speech activity detection, and the effective speech signal segments are segmented. The effective speech signal segment is subjected to frequency domain transformation to extract acoustic feature vectors.
3. The voice interaction method according to claim 2, characterized in that, The step of performing frequency domain transformation on the effective speech signal segment to extract acoustic feature vectors includes: After applying a window function to the effective speech signal segment, a fast Fourier transform is performed to extract the Mel frequency cepstral coefficient feature vector or the perceptual linear prediction feature vector.
4. The voice interaction method according to claim 1, characterized in that, The step of inputting the acoustic feature vector into the local acoustic model for decoding to obtain the text sequence includes: The acoustic feature vector is input into the Hidden Markov Model-Gaussian Mixture Model acoustic model, the optimal state sequence is searched through the Viterbi algorithm, the phoneme probability distribution is output, and the phoneme probability distribution is converted into a text sequence.
5. The voice interaction method according to claim 1, characterized in that, Determining the user's intent includes: Find the intent set corresponding to each slot value; take the intersection of all intent sets corresponding to slot values as the final determined user intent.
6. The voice interaction method according to claim 1, characterized in that, The method further includes: The action instructions are stored in the instruction execution queue, and the queue depth of the instruction execution queue is monitored in real time; When the queue depth drops to a preset value, an interrupt service routine is triggered. In the interrupt service routine, a reverse braking signal is generated based on the current operating state of the motor.
7. The voice interaction method according to claim 6, characterized in that, The step of generating a reverse braking signal based on the current operating state of the motor includes: Obtain the current motor speed and load inertia; query the preset compensation mapping table to determine the corresponding compensation parameters; A reverse PWM pulse is generated based on the compensation parameters, and the reverse PWM pulse is injected into the motor drive circuit of the microcontroller robot.
8. The voice interaction method according to claim 1, characterized in that, The method further includes: Calculate the number of valid voice samples corresponding to the same user intent that have passed verification; When the number of valid speech samples reaches a preset threshold, an incremental update operation on the parameters of the local acoustic model is triggered.
9. The voice interaction method according to claim 8, characterized in that, The triggering of the incremental parameter update operation for the local acoustic model includes: Extract the acoustic feature vectors of the effective speech samples; New model parameters are calculated based on a clustering algorithm, and the Gaussian component parameters in the local acoustic model are updated using a moving average method. The updated local acoustic model is used to cross-validate historical samples to calculate the recognition confidence. When the recognition confidence exceeds the set threshold, the updated model parameters will be fixed and stored.
10. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed, implements the voice interaction method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Intelligent voice interaction system used for die-cutting machine
CN110751953A
Semantic recognition method and device, terminal and storage medium
CN112102840A
A remote control unit for singlechip robot
CN206805766U