Speech intent recognition method and system based on state constraint and pinyin fault tolerance
Patent Information
- Application Number
- CN202611389959.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-09
- Publication Date
- 2026-10-09
AI Technical Summary
[0007]本发明提出了一种基于状态约束与拼音容错的语音意图识别方法和系统,以解决现有技术语音意图识别方法缺乏业务状态约束、对同音字和近音字误识别的容错能力不足,以及语言模型输出范围不受约束的技术问题
[0018]与现有技术相比,本发明的优点和积极效果是:
Smart Images

Figure CN122886593A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent voice interaction and command and dispatch technology. Specifically, it relates to a voice intent recognition method and system based on state constraints and pinyin error tolerance. Background Technology
[0002] With the development of intelligent voice interaction technology, voice intent recognition has been widely applied in scenarios such as intelligent customer service, in-vehicle systems, smart homes, and command and dispatch. Existing intent recognition solutions mainly include keyword rule matching, language model inference, and hybrid recognition methods that combine the two.
[0003] Keyword rule matching has a fast response time, but errors such as homophone substitution and near-homophone confusion are prone to occur in speech recognition text, causing standard keywords to fail to be accurately matched. Some solutions use edit distance or general fuzzy matching for error tolerance, but it is difficult to accurately locate and quantify local pinyin differences, and it is easily affected by identical parts or irrelevant content in the text.
[0004] Language models possess strong semantic understanding capabilities, but suffer from high inference latency and may output intentions that are not executable under the current business state when constraints are lacking. Some existing solutions only perform business legality verification after the recognition result is generated, failing to narrow down the candidate intentions for rule matching and model inference in advance based on the current business state, and also lacking unified constraints on model input prompts and output results.
[0005] Therefore, there is a need for a speech intent recognition method that can constrain rule matching and language model inference throughout the entire process based on the current business status, and can locate core pinyin differences and achieve tolerance for homophones and near-homophones.
[0006] The information disclosed in this background section is only intended to enhance the understanding of the background technology of this application, and therefore may include prior art that is not known to those skilled in the art. Summary of the Invention
[0007] This invention proposes a speech intent recognition method and system based on state constraints and pinyin error tolerance to solve the technical problems of existing speech intent recognition methods, such as lack of business state constraints, insufficient error tolerance for misidentification of homophones and near-homophones, and unconstrained output range of language models.
[0008] To achieve the above-mentioned invention / design objectives, the present invention adopts the following technical solution: A speech intent recognition method based on state constraints and pinyin error tolerance, the method comprising: State constraints and intent whitelist acquisition: Receive speech recognition text and current service state identifier, query a preset state transition mapping table to obtain the intent whitelist corresponding to the current service state identifier; the state transition mapping table includes the correspondence between service state identifiers and the set of intents allowed to be executed under that service state; Rule matching stage: The speech recognition text is precisely matched with each standard intent keyword in the intent whitelist using Chinese characters. When a match is found and the keyword combination condition corresponding to the intent is met, the intent recognition result is output. Otherwise, the speech recognition text is traversed using the length of each standard intent keyword as the window size to obtain equal-length subsequences. Each subsequence and its corresponding standard intent keyword are subjected to double-ended iterative pruning to locate the core difference sequence. The length difference and letter difference of the pinyin strings of the corresponding characters in the core difference sequence are quantified to obtain the intent matching degree. If the intent matching degree reaches a preset matching threshold, the intent recognition result is output; otherwise, the language model inference stage begins. Language model inference stage: The intent whitelist is written into the prompt words, the speech recognition text and the prompt words are input into the language model, and the intent recognition result returned by the language model is obtained; the whitelist is reviewed and the business parameters are verified on the result, and the intent recognition result is output after the verification is passed.
[0009] In the voice intent recognition method based on state constraints and pinyin error tolerance as described above, in the state constraint and intent whitelist acquisition step, when the current business state identifier does not have a corresponding entry in the state transition mapping table, a preset default intent whitelist is returned or an exception handling process is triggered.
[0010] The speech intent recognition method based on state constraints and pinyin error tolerance, as described above, includes methods for obtaining equal-length subsequences, such as: The length of the standard intent keyword B is L, the length of the speech recognition text is N, the preset pruning threshold is E, and the preset minimum core difference sequence length is D; when N≥L, subsequences of length L are sequentially truncated from the starting position of the speech recognition text with a step size of 1, resulting in a total of N-L+1 subsequences. Methods for locating core differential sequences include: For each subsequence A and standard intent keyword B, perform iterative pruning at both ends: convert subsequence A and standard intent keyword B into pinyin sequences respectively, and initialize one-end boundary pointer i and the other-end boundary pointer j; when the pinyin sequences corresponding to subsequence A and standard intent keyword B are completely identical, it is determined that the pinyin is a perfect match; otherwise, within the current boundary range [i,j], count the number of consecutive pinyin identical at one end starting from i and the number of consecutive pinyin identical at the other end starting from j respectively; when the number of consecutive pinyin identical at one end reaches the preset pruning threshold E, update the boundary pointer at that end to prune the consecutive identical part at that end; pruning stops when the number of consecutive pinyin identical at both ends is less than the preset pruning threshold E, or the length of the current sequence to be compared is equal to the preset minimum core difference sequence length D; take the pruned subsequence A and standard intent keyword B as the core difference sequence.
[0011] The speech intent recognition method based on state constraints and pinyin error tolerance, as described above, includes a method for quantifying the length and letter differences of the pinyin strings of corresponding characters in the core difference sequence, comprising: Convert each character in the core difference sequence into its corresponding pinyin string; For each pair of characters at a corresponding position in the core difference sequence, calculate the difference in their pinyin strings. The difference includes the length difference between the two pinyin strings and the letter difference at the same position. The length difference is the absolute value of the length difference between the two pinyin strings, and the letter difference is the number of different letters in the two pinyin strings at the same position. Calculate the pinyin matching score for each pair of characters at that position based on the difference and a preset unit deduction coefficient. The pinyin matching score is the difference between 1 and the difference multiplied by the preset unit deduction coefficient, and is set to 0 when the result is less than 0. Take the average of the pinyin matching scores for each pair of characters at all positions in the core difference sequence to obtain the intent matching degree.
[0012] As described above, in the speech intent recognition method based on state constraints and pinyin error tolerance, during the rule matching stage, the sliding traversal and intent matching degree calculation are performed on each standard intent keyword in the intent whitelist, and the standard intent keywords whose intent matching degree reaches the preset matching threshold are determined as candidate keywords; when there are multiple candidate keywords, a target keyword is determined according to at least one of the intent matching degree, keyword length or preset intent order, and the intent corresponding to the target keyword is output as the recognition result.
[0013] As described above, the speech intent recognition method based on state constraints and pinyin error tolerance replaces the text interval corresponding to the subsequence in the speech recognition text with the standard keyword when the intent matching degree reaches a preset matching threshold and the subsequence is not completely consistent with the standard keyword characters, thus obtaining the corrected text.
[0014] The speech intent recognition method based on state constraints and pinyin error tolerance described above includes writing the intent whitelist into the prompt words, which includes: concatenating the name of each intent in the intent whitelist and its corresponding function description into constraint text according to a preset format, and embedding the constraint text into a predefined prompt word template; The business parameter verification includes: querying the list of business parameters required for the intent based on the intent recognition result returned by the language model, extracting the corresponding business parameter values from the speech recognition text or dialogue context, and determining whether the extracted business parameter values meet the requirements of parameter integrity, format, value range and current runtime context. If the result fails the whitelist review or business parameter verification, the intent recognition is deemed to have failed, and a preset fallback response is returned or a follow-up questioning process is triggered.
[0015] The voice intent recognition method based on state constraints and pinyin error tolerance, as described above, obtains the data state of the current business state during operation, determines whether the execution data conditions required for each intent in the intent whitelist are met based on the data state, and removes the intents whose execution data conditions are not met from the intent whitelist.
[0016] As described above, in the voice intent recognition method based on state constraints and pinyin error tolerance, the service status identifier is set to a preset initial state during system initialization; when the intent recognition result passes the whitelist review and service parameter verification and is successfully executed, the service status identifier is updated according to the executed intent; when intent recognition fails, service parameter verification fails, or intent execution fails, the original service status identifier is maintained; when executing the system exit intent, the service status identifier is reset to a preset wake-up state.
[0017] A speech intent recognition system based on state constraints and pinyin error tolerance, the system comprising: State constraint module: used to receive speech recognition text and current service state identifier, query a preset state transition mapping table, and obtain the intent whitelist corresponding to the current service state identifier; the state transition mapping table includes the correspondence between service state identifiers and the set of intents allowed to be executed under that service state; The rule matching module is used to perform precise Chinese character matching between the speech recognition text and each standard intent keyword in the intent whitelist. When a match is found and the keyword combination condition corresponding to the intent is met, the intent recognition result is output. Otherwise, the speech recognition text is traversed using the length of each standard intent keyword as the window size to obtain equal-length subsequences. Double-end iterative pruning is performed on each subsequence and its corresponding standard intent keyword to locate the core difference sequence. The length difference and letter difference of the pinyin strings of the corresponding characters in the core difference sequence are quantitatively calculated to obtain the intent matching degree. If the intent matching degree reaches the preset matching threshold, the intent recognition result is output; otherwise, the language model inference module is entered. Language model inference module: This module is used to write the intent whitelist into the prompt words, input the speech recognition text and the prompt words into the language model, obtain the intent recognition result returned by the language model, perform whitelist verification and business parameter validation on the result, and output the intent recognition result after the validation is passed.
[0018] Compared with the prior art, the advantages and positive effects of the present invention are: (1) Determine the intent whitelist based on the current business status and the preset state transition mapping table, so that rule matching and language model inference are only performed within the whitelist, reducing the invalid calculations caused by non-executable intents participating in the identification; (2) The core difference sequence is located by double-ended iterative pruning, and the intention matching degree is calculated based on the length difference and letter difference of the pinyin string to improve the fault tolerance of homophone replacement and near-homophone confusion; (3) Constrain the output range of the model by using an intent whitelist, and perform whitelist verification and business parameter validation on the model's returned results to reduce the risk of outputting unexecutable intents or invalid parameters.
[0019] Other features and advantages of the present invention will become clearer after reading the detailed embodiments of the invention in conjunction with the accompanying drawings. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a specific embodiment of the present invention.
[0022] Figure 2 This is a flowchart of the rule matching stage in a specific embodiment of the present invention.
[0023] Figure 3 This is a principle block diagram of a specific embodiment of the present invention. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0026] In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0027] A speech intent recognition method based on state constraints and pinyin error tolerance includes the following steps: State constraints and intent whitelist acquisition: The system receives the speech recognition text and the current business status identifier, queries the preset state transition mapping table, and obtains the intent whitelist corresponding to the current business status identifier based on the current business status identifier and the preset state transition mapping table. This is the whitelist of intents that are allowed to be executed under the current business status, so that the subsequent rule matching stage and language model inference stage can only be executed within the intent whitelist.
[0028] The state transition mapping table includes the correspondence between the business state identifier and the set of intents that are allowed to be executed under that business state.
[0029] In some embodiments, when the service status is identified as an awake state, the set of allowed execution intents includes at least one of wake-up, mode switching, route generation, video source retrieval, and system exit; when the service status is identified as a task mode state, the execution intent of scheme generation is allowed; when the service status is identified as a video source retrieval state, the set of allowed execution intents includes at least one of video source retrieval, page turning, zooming, mode switching, route generation, and system exit. The above correspondence is only an example, and the specific intent whitelist can be pre-configured according to the actual business process.
[0030] When the current service status is received as "video source retrieval status", the mapping table is queried to obtain the intent whitelist corresponding to this status, which includes at least one of the following: video source retrieval, page turning, zooming, mode switching, route generation, and system exit. Intents not belonging to this intent whitelist in the entire intent set are marked as non-executable intents, and their corresponding standard keywords are not included in the rule matching candidate set, nor are their corresponding intent descriptions included in the current language model prompts. In the complete intent recognition process of this embodiment, the intent whitelist is used sequentially for rule matching candidate filtering, language model candidate output range constraints, and legality verification after language model output.
[0031] When the current business status identifier does not have a corresponding entry in the state transition mapping table, the default intent whitelist is returned or an exception handling process is triggered. The default intent whitelist includes, for example, a minimal set of "wake-up" and "system exit" commands. The exception handling process is then triggered, and the user is notified of the status error.
[0032] In some embodiments, the data status of the current business state can also be obtained, and the execution data conditions required for each intent in the intent whitelist can be determined based on the data status. Intents that do not meet the execution data conditions can be removed from the intent whitelist.
[0033] For example, when the business status is identified as video source retrieval status, the runtime data status must at least include whether there is currently valid video source data; the intent whitelist obtained through the state transition mapping table includes "page turning" and "zooming in", but if the current system runtime data status has not yet loaded valid video source data, "page turning" and "zooming in" will be removed from the whitelist because there is a lack of necessary data prerequisites for executing these intents.
[0034] During system initialization, the service status identifier is set to the preset initial state. After the intent recognition result passes the whitelist review and service parameter verification and is successfully executed, the service status identifier is updated according to the executed intent. When intent recognition fails, service parameter verification fails, or intent execution fails, the original service status identifier is maintained. When the system exit intent is executed, the service status identifier is reset to the preset wake-up state.
[0035] In some embodiments, the current service status identifier is stored by the status management unit.
[0036] Rule matching phase: The system performs precise Chinese character matching between the speech recognition text and each standard intent keyword in the intent whitelist. When a match is found and the keyword combination condition corresponding to the intent is met, the corresponding intent recognition result is output. When no precise Chinese character match is found, the speech recognition text is traversed using the length of each standard intent keyword in the intent whitelist as the window size to obtain subsequences. For each subsequence and its corresponding standard intent keyword, a double-ended iterative pruning is performed to locate the core difference sequence. The length difference and letter difference of the pinyin strings of the corresponding characters in the core difference sequence are quantified to obtain the intent matching degree. If the intent matching degree reaches the preset matching threshold, the corresponding intent recognition result is output; otherwise, the system enters the language model inference stage. Language model inference stage: If no intent recognition result is output during the rule matching stage, the intent whitelist is written into the prompt words to constrain the output range of the language model. The speech recognition text and the prompt words are then input into the language model to obtain the intent recognition result returned by the language model. The whitelist is reviewed and the business parameters are verified. After the verification is passed, the final intent recognition result is output.
[0037] like Figure 1 As shown, the speech intent recognition method based on state constraints and pinyin error tolerance in this embodiment includes the following steps: S101, Begin.
[0038] S102, Receive the voice recognition text and the current service status indicator.
[0039] S103. Obtain the intent whitelist corresponding to the current business status identifier.
[0040] S104. Perform rule matching within the intent whitelist.
[0041] S105. Is the rule matching successful? If yes, proceed to step S106; otherwise, proceed to step S108.
[0042] S106. Output the intent recognition result.
[0043] S107. Update the current business status identifier.
[0044] S108. Inference based on language model constrained by intent whitelist.
[0045] S109. Result execution whitelist review and business parameter verification.
[0046] S110. Check if the verification is successful. If yes, proceed to step S106; otherwise, proceed to step S111.
[0047] S111, return to the fallback response or trigger follow-up questions.
[0048] The rule matching phase specifically includes the following sub-steps: 1. Precise Chinese character matching: First, precise substring matching at the Chinese character level is performed on the speech recognition text. All standard intent keywords in the intent whitelist are traversed. If the speech recognition text contains a substring identical to a standard intent keyword and satisfies the keyword combination conditions corresponding to that intent, the intent recognition result corresponding to that keyword is directly output, and the process ends. Each intent can be configured with one or more keyword condition sets. Multiple synonyms or near-synonyms within each keyword condition set are candidate relationships. For composite intents, multiple necessary condition sets can be configured, requiring each necessary condition set to match at least one keyword. For intents with exclusion conditions or dedicated parsing rules, the corresponding exclusion judgment or parameter parsing is further executed. For example, for the intent "retrieve video source," action keyword condition sets and object keyword condition sets can be configured. When the speech recognition text is "Please help me retrieve the footage from camera number three," the action keyword condition set matches "retrieve," and the object keyword condition set matches "camera" or "feature." Since each necessary keyword condition set matches at least one keyword, it can be determined that the keyword combination conditions for the "retrieve video source" intent are satisfied. When an intent is configured with an exclusion keyword set, if the speech recognition text also matches the exclusion keyword set, the intent recognition result is not output, and the matching of other candidate intents continues. For example, for the intent "system exit", its triggering keywords may include "exit" or "standby", and exclusion keywords may include "magnify", "meeting", "task", etc. When the speech recognition text is "exit magnify", although "exit" is matched, the exclusion keyword "magnify" is also matched. Therefore, the "system exit" intent is not output, and the matching of the "cancel magnify" intent continues.
[0049] When an exact match for a Chinese character is not found, the system switches to Pinyin error-tolerant matching.
[0050] 2. Obtain equal-length subsequences by performing a sliding traversal on the speech recognition text: The standard intent keyword B has a length of L, the speech recognition text has a length of N, the preset pruning threshold is E, and the preset minimum core difference sequence length is D. When N≥L, subsequences of length L are truncated sequentially from the starting position of the speech recognition text with a step size of 1, resulting in a total of N-L+1 subsequences. When N<L, sliding matching is not performed for the standard intent keyword. Where L and N represent the number of characters contained in the corresponding text, and each character corresponds to a pinyin unit.
[0051] For example, if the standard keyword B = "command mode" (L=4) and the speech recognition text = "please turn on only mode" (N=7), then the subsequences will be extracted in sequence as follows: "please turn on only" "turn on only" "turn on only" "turn on only mode" "only mode" "only mode", a total of 4 subsequences.
[0052] For example, the speech recognition text is "Put it on the second screen". The standard keyword B corresponding to the intent "zoom in" in the intent whitelist includes "zoom in", and the length L of the standard keyword B is 2. The speech recognition text is traversed using a window of length 2 and a step size of 1, resulting in candidate subsequences such as "put it on", "to the", "second", "two", "screen", and "screen". The candidate subsequence "put it on" is used for pinyin-tolerant matching with the standard keyword "zoom in".
[0053] 3. Dual-end iterative cropping and positioning of core difference sequences: The method for locating core difference sequences by performing two-end iterative pruning on each subsequence A and its corresponding standard intent keyword B includes: Convert subsequence A and standard intent keyword B into pinyin sequences respectively, and initialize one-end boundary pointer i and the other-end boundary pointer j, where i and j are the character position indices of subsequence A and standard intent keyword B respectively; when the pinyin sequences corresponding to subsequence A and standard intent keyword B are completely identical, it is determined that the pinyin is a perfect match; otherwise, within the current boundary range [i,j], count the number of consecutive pinyin sequences that are identical in subsequence A and standard intent keyword B starting from i at one end, and the number of consecutive pinyin sequences that are identical in subsequence A and standard intent keyword B starting from j at the other end respectively; when the number of consecutive pinyin sequences that are identical in one end reaches the preset pruning threshold E, update the boundary pointer i at that end to prune the consecutive identical sequences at one end. Partial; When the number of consecutive identical pinyin at one end does not reach the preset pruning threshold E and the number of consecutive identical pinyin at the other end reaches the preset pruning threshold E, update the boundary pointer j at the other end to prune the consecutive identical parts at the other end; when updating the boundary pointer, limit the actual pruning quantity so that the length of the updated alignment sequence is not less than the preset minimum core difference sequence length D; repeat the above statistical and pruning process until the number of consecutive identical pinyin at both ends is less than the preset pruning threshold E, or the length of the current alignment sequence is equal to the preset minimum core difference sequence length D, then stop pruning; take the pruned subsequence A[i:j] and the standard intent keyword B[i:j] as the core difference sequence.
[0054] For each subsequence A and the standard keyword B, perform a two-end iterative pruning to locate the core differential sequences. The specific process is as follows: Initialize the left pointer i = 0 and the right pointer j = len(A) - 1, where i and j are the character position indices of subsequence A and standard keyword B. In each iteration: Within the current boundary range [i, j], count the number of consecutively identical pinyin at corresponding positions of A and B starting from the left end, and count the number of consecutively identical pinyin at corresponding positions of A and B starting from the right end; When the number of consecutively identical pinyin at the right end reaches E, move the right pointer j to the left by the corresponding actual clipping quantity; when the number of consecutively identical pinyin at the right end does not reach E and the number of consecutively identical pinyin at the left end reaches E, move the left pointer i to the right by the corresponding actual clipping quantity; Wherein, when updating the left pointer or the right pointer, the actual clipping quantity is limited such that the length of the sequence to be aligned after clipping is not less than a preset minimum core difference sequence length D; the actual clipping quantity is the smaller value between the number of consecutive identical pinyin of the current clipped end and the difference obtained by subtracting the preset minimum core difference sequence length D from the length of the current sequence to be aligned; clipping of the corresponding end is performed when the actual clipping quantity is greater than 0, and clipping is stopped when the actual clipping quantity is 0; After completing one end clipping, re-count the numbers of consecutively identical pinyin at the left end and the right end within the current boundary, and repeat the above counting and clipping process until the numbers of consecutively identical pinyin at both the left end and the right end are less than the preset clipping threshold E, or the length of the current sequence to be aligned equals the preset minimum core difference sequence length D, then stop clipping.
[0055] Take the clipped subsequence A[i:j] and standard intent keyword B[i:j] as core difference sequences. In some embodiments, the preset clipping threshold E can be 2, and the preset minimum core difference sequence length D can be 2.
[0056] The first scenario is that the pinyin sequences are completely identical. Taking the subsequence "只会模式" and the standard keyword "指挥模式" as an example, their corresponding pinyin sequences are both "zhi-hui-mo-shi", so it can be determined that the pinyin sequences are completely identical before performing double-end iterative clipping. For the scenario where the Chinese characters are also completely identical, it is determined as a complete match; for the scenario where the Chinese characters are different but the pinyin sequences are completely identical, there is no need to perform double-end clipping and pinyin difference calculation, and the intent matching degree is determined as a preset high matching score that is lower than the complete matching score and not lower than the preset matching threshold, so as to trigger subsequent keyword error correction processing. In this embodiment, the complete matching score can be 1, the preset matching threshold can be 0.83, and the preset high matching score can be 0.99.
[0057] The second case is that the number of consecutively identical characters at the ends does not reach the preset clipping threshold E, but the core sequence reaches the preset matching threshold after pinyin quantification. Taking the subsequence "fang dao" and the standard keyword "fang da" as an example, the candidate subsequence "fang dao" and the standard keyword "fang da" are respectively converted into pinyin sequences to obtain "fang-dao" and "fang-da". Only one consecutive identical pinyin unit "fang" exists at the left end of the two sequences, which does not reach the preset clipping threshold E=2, and the pinyin "dao" and "da" at the right end are not completely identical. Therefore, end clipping is not performed, and the complete "fang dao" and "fang da" are taken as the core difference sequences.
[0058] The third case is that the number of consecutively identical characters at the ends does not reach the preset clipping threshold E, and the quantified matching result of the core sequence after pinyin quantification is lower than the preset matching threshold. Taking the subsequence "zhi hui mo shi" and the standard keyword "fang an sheng cheng" as an example. Initially, the left pointer i=0 and the right pointer j=3. Since there are no consecutive identical pinyin units reaching the preset clipping threshold E=2 at both the left end and the right end, end clipping is not performed. The core difference sequences are the complete "zhi hui mo shi" and "fang an sheng cheng", and pinyin quantification calculation will be performed subsequently.
[0059] The fourth case is that the number of consecutively identical characters at the ends reaches the preset clipping threshold E, and pinyin quantification is performed after end clipping. Taking the candidate subsequence "qin ru zhi hui" and the standard keyword "jin ru zhi hui" as an example. After converting the two into pinyin sequences, the pinyin sequence corresponding to subsequence A is "qin-ru-zhi-hui", and the pinyin sequence corresponding to the standard intent keyword B is "jin-ru-zhi-hui". Initialize the left boundary pointer i=0 and the right boundary pointer j=3. Within the current boundary range, count the number of consecutively identical pinyins from the right end: the pinyin of "hui" in both sequences is "hui", the pinyin of "zhi" in both sequences is "zhi", and the pinyin of "ru" in both sequences is "ru". Therefore, the number of consecutively identical pinyin units at the right end is 3, which reaches the preset clipping threshold E=2. Since the length of the current sequences to be compared is 4, and the preset minimum length D of the core difference sequence is 2, a maximum of 2 pinyin units can be clipped in this round. The right boundary pointer j is actually moved 2 positions to the left, and the consecutively identical end part "zhi hui" is clipped. After clipping, the core difference sequence of candidate subsequence A is "qin ru", and the core difference sequence of standard intent keyword B is "jin ru", whose corresponding pinyin sequences are "qin-ru" and "jin-ru" respectively. At this time, the length of the core difference sequence is already equal to the preset minimum core difference sequence length D, so clipping is stopped, and pinyin difference quantification calculation is performed on "qin ru" and "jin ru".
[0060] 4. Pinyin difference quantification calculation: Each character in the core difference sequence is converted into its corresponding pinyin string; for polyphonic characters, the pinyin string corresponding to the preset default pronunciation is taken; for non-Chinese characters, the character itself is used directly as its pinyin string.
[0061] Calculate for each pair of characters at corresponding positions: For each pair of characters at the corresponding position in the core difference sequence, calculate the difference in their pinyin strings. The difference includes the length difference between the two pinyin strings and the letter difference at the same position. The length difference is the absolute value of the length difference between the two pinyin strings, and the letter difference is the number of different letters at the same position in the two pinyin strings. Calculate the pinyin matching score for the character pair at that position based on the difference and a preset unit deduction coefficient. The pinyin matching score is the difference between 1 and the difference multiplied by the preset unit deduction coefficient, and is set to 0 when the result is less than 0. Take the average of the pinyin matching scores for all character pairs at all positions in the core difference sequence to obtain the intent matching degree. When the subsequence is completely identical to the pinyin sequence corresponding to the standard intent keyword, no pinyin normalization calculation is performed, and the two are determined to be a perfect pinyin match.
[0062] For each pair of characters at the corresponding position in the core difference sequence, their pinyin strings are denoted as p1 and p2 respectively; calculate the length difference between p1 and p2, and the letter difference at their overlapping position; the sum of the length difference and the letter difference is determined as the pinyin difference d at that position.
[0063] The position matching score is calculated as max(0, 1 - λ × d), where λ is a preset unit deduction coefficient. In this embodiment, λ can be 0.2.
[0064] The intent matching score is the average of the matching scores at each position in the core difference sequence.
[0065] When subsequence A is exactly the same as the pinyin sequence corresponding to standard intent keyword B, double-ended iterative pruning and core difference sequence difference calculation are no longer performed; when the Chinese characters of subsequence A are also exactly the same as those of standard intent keyword B, the intent matching degree is determined as the perfect match score; when the Chinese characters of subsequence A are different from those of standard intent keyword B but the pinyin sequence is exactly the same, the intent matching degree is determined as a preset high match score that is lower than the perfect match score but not lower than the preset matching threshold.
[0066] Quantitative calculation is performed by taking "Zhi Hui Mo Shi" (Only Mode) and "Fang An Sheng Cheng" (Scheme Generation) as examples. For the pinyin strings at each corresponding position, the length difference and the letter difference at overlapping positions are counted respectively, and the score of each position is calculated according to the formula: position matching score = max(0, 1-λ×d). Since there are large length differences and letter differences between "zhi" and "fang", "hui" and "an", "mo" and "sheng", and "shi" and "cheng", the matching scores of all positions are low; the intent matching degree obtained by averaging the matching scores of all positions is lower than the preset matching threshold, and it is determined that "只会模式 (Zhi Hui Mo Shi)" does not match "方案生成 (Fang An Sheng Cheng)".
[0067] For the core difference sequences "fang dao (put)" and "fang da (zoom in)", the pinyin string of the first corresponding character "放" in both sequences is "fang", so both the length difference and the letter difference are 0, and the position matching score is 1; the pinyin strings of the second corresponding characters "到" and "大" are "dao" and "da" respectively, the length difference is 1, the letter difference at overlapping positions is 0, so the pinyin difference d is 1. When the unit deduction coefficient λ is 0.2, the position matching score is 0.8. Therefore, the intent matching degree of the core difference sequence is (1+0.8) / 2=0.9, which is higher than the preset matching threshold of 0.83, so it is determined that the candidate subsequence "放到 (fang dao)" matches the standard keyword "放大 (fang da)", and "放到" in the speech recognition text is corrected to "放大". The corrected text is "放大第二个屏幕", in which "第二个屏幕" is used as the service parameter of the zoom-in intent for subsequent parsing.
[0068] For the core difference sequences "qin ru (qin ru)" and "jin ru (enter)", the pinyin strings of the first corresponding characters "亲" and "进" are "qin" and "jin" respectively, the length difference between the two is 0, and the letter difference at overlapping positions is 1, so the pinyin difference d is 1; when the unit deduction coefficient λ is 0.2, the position matching score is 0.8. The pinyin string of the second corresponding characters "如" and "入" is both "ru", and both the length difference and the letter difference are 0, so the position matching score is 1. Therefore, the intent matching degree of the core difference sequence is (0.8+1) / 2=0.9, which is higher than the preset matching threshold of 0.83, so it is determined that the candidate subsequence "亲如指挥" matches the standard intent keyword "进入指挥", and "亲如指挥" in the speech recognition text can be corrected to "进入指挥".
[0069] 5. Select the optimal among multiple keywords: When the whitelist contains multiple standard intent keywords, a sliding traversal and intent matching degree calculation are performed for each standard intent keyword in the intent whitelist. Steps 2-4 above are then performed for each standard keyword, and standard intent keywords with an intent matching degree that reaches or is not lower than a preset matching threshold are identified as candidate keywords. When multiple candidate keywords exist, the target keyword is determined based on at least one of intent matching degree, keyword length, and a preset intent order, and the intent corresponding to the target keyword is output as the recognition result. In some embodiments, candidate keywords with longer keyword lengths are preferentially selected; if keyword lengths are the same, candidate keywords with higher matching degrees are selected; if they are still the same, the target keyword is determined according to the preset intent order.
[0070] For example, if the speech recognition text is "Please turn on the only mode", assuming that the current intent whitelist includes intents such as "command mode", "meeting mode" and "video source retrieval", after calculation, the pinyin sequence of the keyword corresponding to "command mode" is completely consistent with "only mode" and is determined as the target keyword according to the candidate sorting rules. Therefore, the intent "command mode" is output.
[0071] 6. Keyword correction: When a standard keyword in the intent whitelist is matched via Pinyin, and the intent matching degree reaches the preset matching threshold but is lower than the perfect match score, and the subsequence is not completely identical to the standard keyword characters, the text interval corresponding to the target candidate subsequence in the speech recognition text is replaced with the standard keyword to obtain the corrected text. The corresponding intent recognition result is then output based on the corrected text. For example, "Please enable the only mode" is corrected to "Please enable the command mode". The corrected text can be used for subsequent business parameter extraction.
[0072] like Figure 2 As shown, the rule matching method includes the following steps: S201, Begin.
[0073] S202. Receive the current service status identifier of the speech recognition text, and obtain the intent whitelist based on the current service status identifier.
[0074] S203. If the Chinese characters are precisely matched and the keyword combination conditions are met, proceed to step S204; otherwise, proceed to step S205.
[0075] S204. Output the corresponding intent recognition result.
[0076] S205. Select the standard keyword B from the intent whitelist, and slide to extract an equal-length subsequence A from the speech recognition text according to its length L.
[0077] S206. If the pinyin sequence of subsequence A is completely consistent with that of standard keyword B, proceed to step S210; otherwise, proceed to step S207.
[0078] S207, double-ended iterative pruning to locate the core difference sequence.
[0079] S208 Quantify the difference in pinyin length and letter difference to calculate the intent matching degree.
[0080] S209. If the matching degree reaches the preset threshold, proceed to step S210; otherwise, proceed to step S211.
[0081] S210, Add candidate keywords. Proceed to step S211.
[0082] S211. All subsequences and keywords have been traversed. If yes, proceed to step S212; otherwise, proceed to step S205.
[0083] S212. If there are candidate keywords, proceed to step S214; otherwise, proceed to step S213.
[0084] S213, Rule matching failed, proceed to the language model inference stage.
[0085] S214. Select the optimal keywords based on keyword length, matching degree, and preset order.
[0086] S215. Perform keyword correction and output the intent recognition result. Language model inference stage: If no intent recognition result is output during the rule matching stage, the language model inference stage will proceed.
[0087] If no intent recognition result is output during the rule matching stage, the intent whitelist is written into the prompt words to constrain the output range of the language model. The speech recognition text and the prompt words are then input into the language model to obtain the intent recognition result returned by the language model. The whitelist is reviewed and the business parameters are verified. After the verification is passed, the final intent recognition result is output.
[0088] 1. Construct constraint hint words: The names, function descriptions, and corresponding output field requirements of each intent in the intent whitelist are concatenated into constraint text according to a preset format, and then embedded into a predefined prompt word template. An example of a prompt word template is shown below: You are an intent recognition assistant. Based on user input, please select the most matching intent from the following list and output it.
[0089] List of optional intents: (1) Page turning: Switch the currently displayed video source page; (2) Zoom in: Zooms in on the specified screen. (3) Cancel zoom: Cancels the screen zoom-in state; (4) Video source retrieval: Retrieve the video source with the specified number; (5) Mode Exit: Exit the current business mode; (6) System Exit: Exit the entire system.
[0090] Requirements: Select only from the list above; do not output any intents outside the list.
[0091] User input: {text recognized by speech}.
[0092] Output format: {"intent":"intent name","params":{parameters}}.
[0093] 2. Model Inference and Result Verification: Input the prompt words containing intent whitelist constraints and the speech recognition text into the language model and obtain the return results. Perform format parsing and double validation on the return results: First, check whether the model's return results conform to the preset structured format and whether they contain valid intent identifiers; after the format validation passes, perform the following double validation: (1) Whitelist verification: Check whether the intent identifier returned by the model exists in the intent whitelist. If it does not exist, it is determined to be an illegal intent.
[0094] (2) Business parameter verification: Based on the intent recognition result returned by the language model, query the list of business parameters required for the intent, extract the corresponding business parameter values from the speech recognition text or dialogue context, and determine whether the extracted business parameter values meet the requirements of parameter integrity, format, value range and current runtime context.
[0095] For example, the "page turning" intent needs to verify whether the target page expression such as specified page number, first page, last page, previous page, or next page can be converted into a valid integer page number, and whether the converted page number is within a valid range; the "zoom in" intent needs to verify whether the list of screen numbers parsed from absolute screen number, row / column position, reciprocal position, or range position is empty, whether it exceeds the total number of screens on the current page, and whether the zoom level exceeds the upper limit; the "video source retrieval" intent needs to verify whether at least one of the parameters of region, camera name, category, feature word, or video source identifier is complete, and whether the parameter can be mapped to a valid video source.
[0096] If both checks pass, the final intent recognition result is output; if either check fails, the intent recognition is deemed to have failed, and a fallback response is returned or a follow-up questioning process is triggered, such as: Which screen do you want to zoom in on?
[0097] Reference Figure 3This embodiment also proposes a speech intent recognition system based on state constraints and pinyin error tolerance. The system includes a state constraint module 301, a rule matching module 302, and a language model inference module 303 connected in sequence.
[0098] The state constraint module 301 is used to receive the speech recognition text and the current service state identifier, query the preset state transition mapping table, and obtain the intent whitelist corresponding to the current service state identifier; the state transition mapping table includes the correspondence between the service state identifier and the set of intents that are allowed to be executed under the service state.
[0099] The rule matching module 302 is used to perform precise Chinese character matching between the speech recognition text and each standard intent keyword in the intent whitelist. When a match is found and the keyword combination condition corresponding to the intent is met, the intent recognition result is output. Otherwise, the speech recognition text is traversed in a sliding manner with the length of each standard intent keyword as the window size to obtain equal-length subsequences. Double-end iterative pruning is performed on each subsequence and the corresponding standard intent keyword to locate the core difference sequence. The length difference and letter difference of the pinyin strings of the corresponding characters in the core difference sequence are quantitatively calculated to obtain the intent matching degree. If the intent matching degree reaches the preset matching threshold, the intent recognition result is output. Otherwise, the language model inference module is entered.
[0100] The language model inference module 303 is used to write the intent whitelist into the prompt words, input the speech recognition text and the prompt words into the language model, obtain the intent recognition result returned by the language model, perform whitelist verification and business parameter verification on the result, and output the intent recognition result after the verification is passed.
[0101] The intent whitelist output by the state constraint module 301 serves as input constraints for both the rule matching module 302 and the language model inference module 303. The rule matching module 302 only obtains the standard keywords and pinyin sequences corresponding to the intent whitelist, while the language model inference module 303 only obtains the intent description and output field requirements corresponding to the intent whitelist.
[0102] Each module performs speech intent recognition according to the method described above.
[0103] The advantage of business state constraints in this embodiment is that it first eliminates intentions that cannot be executed in the current state, reducing false triggering caused by similar pinyin.
[0104] In speech recognition, homophone and near-homophone errors can easily make one word sound like another command word. Without business state constraints, all intents compete for pinyin similarity, potentially matching erroneous text to an intent that is "pronounced similarly but is fundamentally unexecutable in the current business context." This embodiment first queries the state transition mapping table based on the current business state to obtain an intent whitelist, and stipulates that subsequent rule matching and language model inference are only performed within the whitelist. The advantage of this approach is that pinyin correction doesn't blindly search for the most similar word in open text, but rather finds the most similar word within the "currently allowed set of intents," thus reducing the margin for error and ensuring the matching results better align with business logic.
[0105] The advantage of the keyword sliding window in this embodiment is that it can locate partially misidentified command words from the complete speech text, rather than requiring the entire sentence to be aligned.
[0106] Actual voice commands are usually not isolated keywords, but rather long sentences containing colloquial prefixes, objects, and quantifiers, such as "Put it on the second screen" or "Please enter the command mode." This embodiment uses the length of the standard intent keyword as a window, extracting equal-length subsequences from the speech recognition text segment by segment, and then comparing them with the standard keywords. The advantage of this approach is that intent triggering often relies only on local keywords within a sentence. The sliding window allows for a separate comparison of "put it on" with "enlarge," and "command mode" with "command mode," avoiding irrelevant words in the entire sentence from affecting the pinyin similarity. Compared to the overall alignment between the text to be corrected and the candidate text in existing technologies, this embodiment is more suitable for detecting ASR errors in local command words within long voice commands.
[0107] The advantage of this dual-end cropping method is that it extracts the pinyin segments that actually differ, avoiding the common parts from masking errors.
[0108] If two words are mostly similar in pronunciation, with differences only in the middle or at one end, directly calculating the similarity of the entire word may lead to two problems: first, the large number of identical parts "dilutes" the differences, causing incorrect words to be mistakenly judged as high matches; second, irrelevant identical parts are included in the calculation, making it impossible to accurately pinpoint where the error lies. This embodiment, after converting the subsequence and standard keywords into pinyin sequences, counts the number of consecutive identical pinyin at both ends and prunes identical ends when a threshold is met, finally retaining only the core difference sequence. The advantage of this approach is that the key to pinyin error correction is not proving how many words are similar, but accurately measuring whether the remaining differences still fall within the range of tolerable near-phonetic errors. This embodiment's two-end pruning more directly serves the "core pinyin difference location of the intent keyword."
[0109] Therefore, this embodiment queries the state transition mapping table by the current business state identifier to predetermine the whitelist of intents that are allowed to be executed under the current business state, so that subsequent pinyin fault-tolerant matching is only performed within the scope of legal intents, thereby reducing the risk of misidentification caused by non-executable intents participating in matching from the source.
[0110] When the exact match of Chinese characters fails, this embodiment uses the length of the standard intent keyword as a sliding window to traverse the speech recognition text character by character. It can extract candidate subsequences of the same length as the standard intent keyword from the complete speech text containing colloquial prefixes, supplementary descriptions or business parameters, thereby avoiding interference from irrelevant text content on intent keyword matching.
[0111] Furthermore, in this embodiment, after converting the candidate subsequence and standard intent keywords into pinyin sequences, a double-ended iterative pruning method is used to remove the parts with the same consecutive pinyin at both ends, retaining the core difference sequence that better reflects the differences in speech misidentification, so that subsequent matching judgments focus on the pinyin segments that are actually confused.
[0112] Therefore, this embodiment can improve the fault tolerance of speech recognition errors such as homophone substitution and near-homophone confusion while ensuring the legality of the business status, and improve the accuracy and stability of speech intent recognition results.
[0113] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions claimed by the present invention.
Claims
1. A speech intent recognition method based on state constraints and pinyin error tolerance, characterized in that, The method includes: State constraints and intent whitelist acquisition: Receive speech recognition text and current service state identifier, query a preset state transition mapping table to obtain the intent whitelist corresponding to the current service state identifier; the state transition mapping table includes the correspondence between service state identifiers and the set of intents allowed to be executed under that service state; Rule matching stage: The speech recognition text is precisely matched with each standard intent keyword in the intent whitelist using Chinese characters. When a match is found and the keyword combination condition corresponding to the intent is met, the intent recognition result is output. Otherwise, the speech recognition text is traversed using the length of each standard intent keyword as the window size to obtain equal-length subsequences. Each subsequence and its corresponding standard intent keyword are subjected to double-ended iterative pruning to locate the core difference sequence. The length difference and letter difference of the pinyin strings of the corresponding characters in the core difference sequence are quantified to obtain the intent matching degree. If the intent matching degree reaches a preset matching threshold, the intent recognition result is output; otherwise, the language model inference stage begins. Language model inference stage: The intent whitelist is written into the prompt words, the speech recognition text and the prompt words are input into the language model, and the intent recognition result returned by the language model is obtained; the whitelist is reviewed and the business parameters are verified on the result, and the intent recognition result is output after the verification is passed.
2. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 1, characterized in that, In the state constraint and intent whitelist acquisition step, if the current business state identifier does not have a corresponding entry in the state transition mapping table, a preset default intent whitelist is returned or an exception handling process is triggered.
3. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 1, characterized in that, Methods for obtaining equal-length subsequences include: The length of the standard intent keyword B is L, the length of the speech recognition text is N, the preset pruning threshold is E, and the preset minimum core difference sequence length is D; when N≥L, subsequences of length L are sequentially truncated from the starting position of the speech recognition text with a step size of 1, resulting in a total of N-L+1 subsequences. Methods for locating core differential sequences include: For each subsequence A and standard intent keyword B, perform iterative pruning at both ends: convert subsequence A and standard intent keyword B into pinyin sequences respectively, and initialize one-end boundary pointer i and the other-end boundary pointer j; when the pinyin sequences corresponding to subsequence A and standard intent keyword B are completely identical, it is determined that the pinyin is a perfect match; otherwise, within the current boundary range [i,j], count the number of consecutive pinyin identical at one end starting from i and the number of consecutive pinyin identical at the other end starting from j respectively; when the number of consecutive pinyin identical at one end reaches the preset pruning threshold E, update the boundary pointer at that end to prune the consecutive identical part at that end; pruning stops when the number of consecutive pinyin identical at both ends is less than the preset pruning threshold E, or the length of the current sequence to be compared is equal to the preset minimum core difference sequence length D; take the pruned subsequence A and standard intent keyword B as the core difference sequence.
4. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 3, characterized in that, The method for quantifying the length difference and letter difference of the pinyin strings of corresponding characters in the core difference sequence includes: Convert each character in the core difference sequence into its corresponding pinyin string; For each pair of characters at a corresponding position in the core difference sequence, calculate the difference in their pinyin strings. The difference includes the length difference between the two pinyin strings and the letter difference at the same position. The length difference is the absolute value of the length difference between the two pinyin strings, and the letter difference is the number of different letters in the two pinyin strings at the same position. Calculate the pinyin matching score for each pair of characters at that position based on the difference and a preset unit deduction coefficient. The pinyin matching score is the difference between 1 and the difference multiplied by the preset unit deduction coefficient, and is set to 0 when the result is less than 0. Take the average of the pinyin matching scores for each pair of characters at all positions in the core difference sequence to obtain the intent matching degree.
5. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 4, characterized in that, In the rule matching stage, the sliding traversal and intent matching degree calculation are performed on each standard intent keyword in the intent whitelist. The standard intent keywords whose intent matching degree reaches the preset matching threshold are determined as candidate keywords. When there are multiple candidate keywords, a target keyword is determined according to at least one of the intent matching degree, keyword length or preset intent order, and the intent corresponding to the target keyword is output as the recognition result.
6. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 4, characterized in that, When the intent matching degree reaches a preset matching threshold and the subsequence is not completely consistent with the standard keyword characters, the text interval corresponding to the subsequence in the speech recognition text is replaced with the standard keyword to obtain the corrected text.
7. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 1, characterized in that, Writing the intent whitelist into the prompt word includes: concatenating the name of each intent in the intent whitelist and its corresponding function description into constraint text according to a preset format, and embedding the constraint text into a predefined prompt word template; The business parameter verification includes: querying the list of business parameters required for the intent based on the intent recognition result returned by the language model, extracting the corresponding business parameter values from the speech recognition text or dialogue context, and determining whether the extracted business parameter values meet the requirements of parameter integrity, format, value range and current runtime context. If the result fails the whitelist review or business parameter verification, the intent recognition is deemed to have failed, and a preset fallback response or follow-up questioning process is returned.
8. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 1, characterized in that, Obtain the data status of the current business operation, determine whether the execution data conditions required for each intent in the intent whitelist are met based on the data status, and remove the intents that do not meet the execution data conditions from the intent whitelist.
9. The speech intent recognition method based on state constraints and pinyin error tolerance according to claim 1, characterized in that, During system initialization, the service status identifier is set to a preset initial state. When the intent recognition result passes the whitelist review and service parameter verification and is successfully executed, the service status identifier is updated according to the executed intent. When intent recognition fails, service parameter verification fails, or intent execution fails, the original service status identifier is maintained. When the system exit intent is executed, the service status identifier is reset to a preset wake-up state.
10. A speech intent recognition system based on state constraints and pinyin error tolerance, characterized in that, The system includes: State constraint module: used to receive speech recognition text and current service state identifier, query a preset state transition mapping table, and obtain the intent whitelist corresponding to the current service state identifier; the state transition mapping table includes the correspondence between service state identifiers and the set of intents allowed to be executed under that service state; The rule matching module is used to perform precise Chinese character matching between the speech recognition text and each standard intent keyword in the intent whitelist. When a match is found and the keyword combination condition corresponding to the intent is met, the intent recognition result is output. Otherwise, the speech recognition text is traversed using the length of each standard intent keyword as the window size to obtain equal-length subsequences. Double-end iterative pruning is performed on each subsequence and its corresponding standard intent keyword to locate the core difference sequence. The length difference and letter difference of the pinyin strings of the corresponding characters in the core difference sequence are quantitatively calculated to obtain the intent matching degree. If the intent matching degree reaches the preset matching threshold, the intent recognition result is output; otherwise, the language model inference module is entered. Language model inference module: This module is used to write the intent whitelist into the prompt words, input the speech recognition text and the prompt words into the language model, obtain the intent recognition result returned by the language model, perform whitelist verification and business parameter validation on the result, and output the intent recognition result after the validation is passed.