Speech recognition method, device and equipment for reducing misrecognition of command words and medium
By training the CTC speech recognition model and filtering candidate paths using a path search algorithm, and combining the weighted sum of CTC loss and contrast loss, the command word recognition model for embedded devices was optimized. This solved the misrecognition problem of the CTC algorithm in short command words and colloquial command words, and improved the recognition accuracy.
Patent Information
- Application Number
- CN202511304429.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-12
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-09-12
AI Technical Summary
In embedded devices, the CTC algorithm has a high false recognition rate when recognizing short command words and colloquial command words, which cannot meet users' requirements for recognition accuracy.
The initial CTC speech recognition model is trained until it converges. A path search algorithm is used to filter candidate paths, and the inverse of the CTC loss is calculated as the reference path score. The candidate path scores are compared with the reference path scores. Finally, the CTC loss and the comparison loss are weighted and summed. The model parameters are iteratively adjusted to optimize the model.
It improves the model's ability to distinguish short command words and colloquial command words, reduces the probability of false recognition, meets users' needs for recognition accuracy, and is suitable for command word recognition in embedded device scenarios.
Smart Images

Figure CN120808762B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of speech recognition, in particular to a speech recognition method and device for reducing misrecognition of command words, equipment and medium. BACKGROUND
[0002] Wake-up word and command word recognition is an important branch of the field of speech recognition, and is widely used in voice control of intelligent devices in scenarios such as smart home and smart terminals. In actual applications, some command words are prone to misrecognition because they are short (such as "turn on the light" and "I'm back" with only 2-3 characters) or tend to be colloquial.
[0003] The speech recognition algorithm of the current embedded device mostly uses the CTC (Connectionist Temporal Classification) algorithm. This algorithm does not require alignment for sequence tasks, operates quickly and saves memory, but only aims to maximize the correct path and does not constrain the error path. When recognizing short command words, the model has weak ability to distinguish between correct and error paths, and the probability of misrecognition is significantly increased, making it difficult to meet the user's demand for command word recognition accuracy. SUMMARY
[0004] The main purpose of the present application is to provide a speech recognition method for reducing misrecognition of command words, aiming to solve the technical problem that the embedded device uses the CTC algorithm to recognize short command words and colloquial command words, and cannot meet the user's demand for recognition accuracy due to high misrecognition probability.
[0005] The first aspect of the present application provides a speech recognition method for reducing misrecognition of command words, comprising:
[0006] Training an initial CTC speech recognition model until the model converges on a validation set to obtain a converged model;
[0007] Based on the original output value output by the converged model, a path search algorithm is used to filter candidate paths to obtain multiple candidate paths;
[0008] CTC loss calculation is performed on the reference path, and the reciprocal of the CTC loss is taken as the reference path score;
[0009] Comparing the path score of each candidate path with the reference path score to obtain a comparison loss;
[0010] Weighted sum of the CTC loss and the comparison loss to obtain a total loss, and iterative adjustment of the parameters of the converged model using the total loss to obtain a target speech recognition model.
[0011] Further, the step of training the initial CTC speech recognition model until the model converges on a validation set to obtain a converged model includes:
[0012] Obtaining a speech training data set and a speech validation data set;
[0013] Training the initial CTC speech recognition model based on the speech training data set, calculating a model loss value through a CTC loss function, updating model parameters based on the loss value, and obtaining an intermediate model;
[0014] Inputting the speech validation data set into the intermediate model to obtain a validation set word error rate and a model loss value;
[0015] Determining whether the validation set word error rate no longer decreases or whether the model loss value no longer decreases continuously for multiple rounds, and if the conditions are met, determining the intermediate model as a converged model, and if the conditions are not met, returning to continue training and updating parameters.
[0016] Further, the step of obtaining multiple candidate paths based on the original output value output by the converged model using a path search algorithm includes:
[0017] Obtaining a first original output value output by the converged model that has not been normalized;
[0018] Performing path search on the first original output value based on the path search algorithm to obtain a search result;
[0019] Based on the search result, selecting multiple predicted paths with high probability ranking;
[0020] Extracting the path structure of the multiple predicted paths to obtain multiple candidate paths.
[0021] Further, the step of performing CTC loss calculation on the reference path and taking the reciprocal of the CTC loss as the reference path score includes:
[0022] Obtaining a second original output value output by the converged model that has not been normalized;
[0023] Determining a target phoneme sequence corresponding to the reference path, the target phoneme sequence being a sequence formed by concatenating all sample phoneme identification sequences in a training batch;
[0024] Obtaining the actual duration of the input audio after being calculated by the converged model as the input length of the second original output value;
[0025] Obtaining the actual length of the phoneme sequence corresponding to each sample in the training batch as the target length of the target phoneme sequence;
[0026] inputting the second original output value, the target phoneme sequence, the input length and the target length into a CTC loss calculation function to obtain a loss value;
[0027] taking an inverse of the loss value to obtain a reference path score.
[0028] Further, the step of comparing the path score of each candidate path with the reference path score to obtain a comparison loss comprises:
[0029] obtaining a reference path score corresponding to the reference path;
[0030] obtaining a candidate path score corresponding to each candidate path;
[0031] performing difference calculation on the candidate path score and the reference path score, and performing accumulation operation in combination with a preset threshold to obtain an operation result;
[0032] performing truncation processing on the operation result to retain a value not less than zero;
[0033] determining the operation result after the truncation processing as the comparison loss of the corresponding candidate path.
[0034] Further, the step of obtaining the candidate path score corresponding to each candidate path comprises:
[0035] obtaining a candidate phoneme sequence corresponding to each candidate path and length information of the candidate phoneme sequence;
[0036] obtaining a feature sequence output by the converged model and actual length information of the feature sequence;
[0037] inputting the candidate phoneme sequence, the length information thereof, the feature sequence and the actual length information thereof into a CTC loss function to obtain a candidate CTC loss value corresponding to the candidate path;
[0038] taking an inverse of the candidate CTC loss value to obtain a candidate path score corresponding to the candidate path.
[0039] Further, the step of performing weighted summation on the CTC loss and the comparison loss to obtain a total loss, and using the total loss to iteratively adjust parameters of the converged model to obtain a target speech recognition model comprises:
[0040] obtaining a CTC loss corresponding to the reference path and comparison losses corresponding to each candidate path;
[0041] setting a weight parameter corresponding to the comparison loss, performing multiplication operation on the comparison loss and the weight parameter to obtain a weighted comparison loss;
[0042] sum the CTC loss and the weighted contrast loss to obtain a total loss;
[0043] Based on the total loss, the parameters of the converged model are iteratively adjusted by a back propagation method to obtain a target speech recognition model.
[0044] The second aspect of the present application also proposes a speech recognition device for reducing command word misrecognition, comprising:
[0045] A convergence module is configured to train an initial CTC speech recognition model until the model converges on a validation set to obtain a converged model.
[0046] A screening module is configured to perform candidate path screening on the original output value output by the converged model based on a path search algorithm to obtain a plurality of candidate paths.
[0047] A calculation module is configured to calculate a CTC loss for a reference path and take the reciprocal of the CTC loss as a reference path score.
[0048] A contrast operation module is configured to perform contrast operation on the path score of each candidate path and the reference path score to obtain a contrast loss.
[0049] An iterative adjustment module is configured to sum the CTC loss and the contrast loss by weighting to obtain a total loss, and iteratively adjust the parameters of the converged model using the total loss to obtain a target speech recognition model.
[0050] The third aspect of the present application proposes a speech recognition device for reducing command word misrecognition, comprising:
[0051] A processor;
[0052] A memory for storing a computer program;
[0053] When the processor executes the computer program, the speech recognition method for reducing command word misrecognition in any of the above embodiments is implemented.
[0054] The fourth aspect of the present application proposes a computer readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the speech recognition method for reducing command word misrecognition in any of the above embodiments.
[0055] The first aspect of the present application brings the following beneficial effects:
[0056] The application first establishes a foundation by training a convergent model through CTC, and then locks a potential error path by screening a candidate path through path search; then, a reference derived from CTC loss is used to score the candidate path, the loss is compared to enhance the distinction between correct and error paths, and the defect that the original algorithm does not constrain error paths is made up; finally, the model is iteratively optimized by weighting the total loss, the discrimination ability of the model for short / colloquial command words is improved, the misrecognition probability is reduced, the demand of users for recognition accuracy is met, and the command word recognition demand in the embedded device scene is adapted. BRIEF DESCRIPTION OF DRAWINGS
[0057] Figure 1 is a flowchart of a speech recognition method for reducing command word misrecognition according to an embodiment of the application;
[0058] Figure 2 is a structural diagram of a speech recognition device for reducing command word misrecognition according to an embodiment of the application;
[0059] Figure 3 is a structural diagram of a computer device according to an embodiment of the application;
[0060] The object, functional features and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0061] In order to make the object, technical solutions and advantages of the application more clear, the application will be further described in detail below with reference to the embodiments and the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the application and not to limit the application.
[0062] Those skilled in the art can understand that, unless specifically stated, the singular forms "a", "an" and "the" used herein also include the plural forms. It should be further understood that the phrase "comprising" used in the specification of the application means that a feature, integer, step, operation, element, module and / or component exists, but does not exclude the existence or addition of one or more other features, integers, steps, operations, elements, modules, components and / or their combinations. It should be understood that when an element is "connected" or "coupled" to another element, it can be directly connected or coupled to the other element, or there can be an intermediate element. In addition, "connected" or "coupled" used herein can include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any module and all combinations of the associated listed items.
[0063] Those skilled in the art can understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as such herein.
[0064] With reference to Figure 1 The embodiments of the present application provide a speech recognition method for reducing misrecognition of command words, comprising:
[0065] S1: training an initial CTC speech recognition model until the model converges on a validation set, obtaining a converged model;
[0066] S2: based on the original output value output by the converged model, using a path search algorithm to screen candidate paths, obtaining a plurality of candidate paths;
[0067] S3: performing CTC loss calculation on the reference path, and taking the reciprocal of the CTC loss as the reference path score;
[0068] S4: comparing the path score of each candidate path with the reference path score to obtain a comparison loss;
[0069] S5: performing weighted summation of the CTC loss and the comparison loss to obtain a total loss, and using the total loss to iteratively adjust the parameters of the converged model to obtain a target speech recognition model.
[0070] In step S1, first of all, 100,000 pieces of training data are constructed, covering 2-4 word short command words, containing pronunciation of different ages, genders and accents, and also adding household noise such as television and refrigerator operation to fit the real environment; 10,000 pieces of training data are randomly selected as validation data set, keeping the command word distribution and noise type consistent to avoid data bias affecting convergence judgment; the model training adopts a "convolutional neural network + long short-term memory network" architecture: the convolutional neural network layer extracts local spectral features through 3 layers of convolution, the long short-term memory network layer is set to 2 layers of bidirectional structure to capture time sequence dependence, and the output layer is a full connection layer (dimension 40, containing blank label phoneme categories). Based on the Pytorch framework, 32 pieces of input training data are trained per batch, the loss value is calculated by using the connectionist temporal classification loss function of the framework (according to the difference between the original predicted value and the real phoneme sequence), the weights are updated through the adaptive momentum estimation algorithm optimizer (learning rate 0.001) reverse propagation, and an intermediate model is generated every time the training data is traversed once;
[0071] In the convergence judgment, the verification data is input into the intermediate model, the word error rate of the verification set (formula: (substitution + insertion + deletion error number) / total word number) and the loss average are calculated. If the word error rate or the loss value does not decrease for 3 rounds in succession (such as 7.8% for 15-17 rounds), the model of the 17th round is determined as the converged model; if not, the existing parameters are iteratively trained until the standard is met. This step provides a stable and reliable basic model for subsequent optimization through systematic data set construction, model training and convergence judgment. On the one hand, the diversified training data set makes the model adapt to the pronunciation differences and noise interference in the real scene, avoiding the insufficient generalization ability of the initial model; on the other hand, the strict convergence standard ensures that the model has mastered the basic command word recognition ability, avoiding the deviation of the subsequent comparative loss optimization direction due to the non-convergence of the model.
[0072] In step S2, the original output value of the converged model is first obtained. The speech verification data set (containing short command word samples such as "turn on the light") constructed in step S1 is input into the converged model in batches (32 samples per batch), and the original output value (i.e. the original prediction value, shape: [time step, batch size, category number], such as a "turn on the light" sample with 100 time steps and 40 category numbers) of the output layer of the model without normalization processing is extracted, which directly reflects the model's prediction tendency for each time step phoneme category and is the core basis for path search; then the prefix beam search algorithm is used for path search. Based on the open-source prefix beam search algorithm logic, the original output value is input, the empty prefix path set is initialized, and then the original output value is traversed by time step. The phoneme category prediction probability of each time step is sorted, and the candidate prefix paths with higher probability (such as the top 20 paths per step) are retained to avoid excessive path quantity leading to redundant calculation; after the traversal is completed, the paths with the same semantics are merged (such as repeated paths containing blank labels), and all the prediction path search results of the batch of samples are obtained.
[0073] Finally, a plurality of candidate paths are screened. According to the probability values of each predicted path in the search result, the top N paths (N is set to 5, taking into account covering key error paths and computational efficiency) are selected, for example, in the search result of a certain "turn on the light" sample, the top 5 paths are "turn on the light" (correct path), "turn on the door", "turn on the light", "turn on the light", and "turn on the door" (all are easily confused error paths); only the phoneme sequence identification list (i.e. path structure) of these paths is extracted, which is used for subsequent comparative loss calculation, and finally 5 candidate paths corresponding to each sample in this batch are obtained, and the candidate path screening is completed. In this step, the candidate paths are accurately screened by prefix beam search. On the one hand, based on the original output value of the converged model, it is ensured that the paths screened are high-probability paths that the model actually tends to, which can cover typical error paths of short command words such as "turn on the light"; on the other hand, the number of candidate paths (such as N = 5) is controlled, which can cover key error paths while avoiding excessive computational load, providing accurate and efficient objects for subsequent comparative loss calculation, and helping to improve the model's suppression effect on error paths.
[0074] In step S3, taking the converged model obtained in step S1 and the candidate paths of the "turn on the light" sample in step S2 as an example, first, the reference path is determined as the true phoneme sequence path corresponding to the audio in the training data "turn on the light" (the phoneme identification sequence is [5, 12], 5 corresponds to "turn on" and 12 corresponds to "light"). Then, the input parameters for calculating the CTC loss are prepared: the original prediction value output by the converged model (shape [100, 32, 40], corresponding to 100 time steps, 32 samples / batch, and 40 classes of phonemes); the target phoneme sequence is a list obtained by concatenating the true phoneme identifiers of all samples in the batch (for example, the "turn on the light" sample corresponds to [5, 12], and the other samples are concatenated in turn); the input length is the actual time step of each sample in the batch (for example, the "turn on the light" sample is 100); and the target length is the true phoneme sequence length of each sample (for example, the "turn on the light" sample is 2).
[0075] Then the CTC loss function of the Pytorch framework is called to input the above parameters for calculation to obtain the CTC loss value of the batch of samples (such as the loss value of the "turn on the light" sample is 1.2). Since the CTC loss is essentially a "negative log-likelihood probability" (i.e. CTC loss = -logP, where P is the likelihood probability of the "correct path" of the model), the CTC loss itself is a positive value (because logP≤0, -logP≥0 after taking the negative); in order to quantify the prediction confidence of the model on the "correct path", the "log-likelihood probability of the correct path logP" can be taken as the reference path score, that is: reference path score = logP = -CTC. Taking the "turn on the light" sample as an example, if the CTC loss is 1.2, the reference path score is -1.2, which quantifies the prediction confidence of the model on the correct path, serving as a benchmark for subsequent comparison with candidate path scores. Step S3 converts the abstract correct path into a quantifiable numerical benchmark by calculating the reference path score through the CTC loss, which not only continues the training logic of step S1, but also provides a unified scale for comparing error paths in step S4, ensuring the accuracy and operability of subsequent loss calculation.
[0076] In step S4, first, the scores of the reference path and all candidate paths are obtained. The reference path is the true phoneme sequence "turn on the light" of the "turn on the light" sample (phoneme identifier [5, 12]), which has a score of -1.2 after taking the negative in step S3. This score represents the prediction confidence of the model on the correct path. The candidate path score needs to be calculated based on the phoneme sequence of each path: taking the confusing error path "turn on the light" (phoneme identifier [5, 13], "turn on the light" is similar in pronunciation) as an example, first extract its corresponding candidate phoneme sequence [5, 13] and sequence length 2, then call the original prediction value output by the converged model in step S1 (shape [100, 32, 40], where 100 is the time step of the "turn on the light" sample, 32 is the batch size, and 40 is the number of phoneme categories) and the input length (100, which is the actual audio duration of the sample), input these parameters into the CTC loss function of the Pytorch framework to calculate the candidate CTC loss value of the "turn on the light" path, which is 1.5. Since the path score is the opposite of the CTC loss value, the candidate path score of "turn on the light" is -1.5; similarly, the candidate CTC loss value of "turn on the light" (phoneme identifier [6, 12], "turn on the light" is similar in pronunciation) is 1.4, and the score is -1.4; the candidate CTC loss value of "turn on the light" (phoneme identifier [5, 14], "turn on the light" is similar in pronunciation) is 1.3, and the score is -1.3; the candidate CTC loss value of "turn on the light" (phoneme identifier [6, 13], both bigrams are easily confused, with the highest risk of misidentification) is 1.6, and the score is -1.6; and the correct path "turn on the light" contained in the candidate path has the same score as the reference path, which is still -1.2.
[0077] Secondly, set the key parameters of the contrast loss calculation. According to the requirement of the patent scheme that the preset threshold value gamma is 0.1-0.5, combined with the characteristics of the short command word such as “turn on the light” being easily disturbed by similar pronunciation, the value of gamma is set to 0.3 to balance the punishment intensity and the model stability. At the same time, the calculation formula of the contrast loss is defined as contrast loss = torch.clamp(gamma + candidate path score - reference path score, min = 0.0), wherein “torch.clamp” is a clipping function, which is to ensure that the loss value is non-negative, only the path with “candidate path score higher than reference path score by a certain degree” is punished to avoid meaningless negative loss affecting model optimization.
[0078] Finally, the contrast loss is calculated path by path. For the five candidate paths, “turn on the light” (correct path) is calculated as 0.3 + 1.2 - 1.2 = 0.3, and the loss after clipping is 0.3 (low punishment, consistent with the logic that the correct path does not need to be excessively constrained); “turn on the log” is calculated as 0.3 + 1.5 - 1.2 = 0.6, and the loss is 0.6 (moderate punishment, matching its higher risk of misrecognition); “turn on the light” is calculated as 0.3 + 1.4 - 1.2 = 0.5, and the loss is 0.5 (low-moderate punishment, misrecognition risk slightly lower than “turn on the log”); “turn on the light” is calculated as 0.3 + 1.3 - 1.2 = 0.4, and the loss is 0.4 (low punishment, lowest misrecognition risk); “turn on the log” is calculated as 0.3 + 1.6 - 1.2 = 0.7, and the loss is 0.7 (highest punishment, corresponding to its highest misrecognition risk). Finally, the contrast loss of the five candidate paths of the “turn on the light” sample is obtained, which provides accurate error suppression basis for the total loss construction in step S5. Step S4 quantifies the score difference between the candidate path and the reference path, applies higher loss to the high-probability error path (such as “turn on the log”), and accurately suppresses the error path score; at the same time, relying on the clipping process to avoid excessive punishment, it provides reasonable error suppression signal for subsequent total loss optimization, helping to improve the model discrimination ability.
[0079] In step S5, first, the path score is obtained, and the score of the reference path "open-light" (phoneme identifier [5, 12]) has been determined as -1.2 in step S3, which is a quantitative embodiment of the model's prediction confidence for the correct path, and the candidate path score needs to be calculated for each path: taking the easily confused error path "open-light" (phoneme identifier [5, 13], "light" is similar in pronunciation, and is easily misheard and misrecognized in daily scenarios) as an example, first extract its corresponding candidate phoneme sequence [5, 13] and sequence length 2, and then call the original prediction value (shape [100, 32, 40], where 100 represents the voice time step of the "open-light" sample, 32 is the training batch size, and 40 is the number of phoneme categories including blank labels) output by the converged model in step S1 and the input length (100, which is the actual audio duration of the sample after removing padding), input these parameters into the CTC loss function of the Pytorch framework, and calculate the candidate CTC loss value of the "open-light" path as 1.5; since the path score is the opposite of the CTC loss value (CTC loss is essentially a negative log likelihood probability), the candidate path score of "open-light" is -1.5. Similarly, for "kai-light" (phoneme identifier [6, 12], "kai" and "open" initial consonants are similar), the candidate CTC loss value is 1.4, and the score is -1.4; for "open-equal" (phoneme identifier [5, 14], "equal" and "light" final consonants are similar), the candidate CTC loss value is 1.3, and the score is -1.3; for "kai-light" (phoneme identifier [6, 13], both bigrams have pronunciation confusion points, and the risk of misrecognition is the highest), the candidate CTC loss value is 1.6, and the score is -1.6; and the correct path "open-light" contained in the candidate path has the same score as the reference path, which is still -1.2.
[0080] Secondly, the calculation parameters of the contrast loss are set. According to the constraint of "the preset threshold value gamma is 0.1-0.5" in the patent scheme, combined with the characteristics of "open-light" such as short 2-word command word dimension and easy to be disturbed by similar pronunciation, in order to find a balance between "effectively punishing error paths" and "avoiding excessive constraints on the model", the value of gamma is set to 0.3; at the same time, the core calculation formula of the contrast loss is defined as: contrast loss = torch.clamp (gamma + candidate path score - reference path score, min = 0.0), where "torch.clamp" is a truncation function in the Pytorch framework, which ensures that the loss value is non-negative: only when the candidate path score is significantly higher than the reference path, a penalty loss is generated, avoiding meaningless negative loss interfering with the model optimization direction.
[0081] The contrast loss is calculated again for each path. For the 5 candidate paths, the formula is calculated in turn: "on-light" (correct path) gives 0.3+1.2-1.2=0.3, and after truncation, the loss is 0.3 (low penalty strength, consistent with the logic that the correct path does not need to be overly constrained); "on-log" gives 0.3+1.5-1.2=0.6, and the loss is 0.6 (moderate penalty, matching its higher misrecognition probability); "key-light" gives 0.3+1.4-1.2=0.5, and the loss is 0.5 (moderate-low penalty, with a slightly lower misrecognition risk than "on-log"); "on-wait" gives 0.3+1.3-1.2=0.4, and the loss is 0.4 (low penalty, with the lowest misrecognition risk); "key-log" gives 0.3+1.6-1.2=0.7, and the loss is 0.7 (highest penalty strength, corresponding to its high misrecognition risk due to the confusion of the two phonemes). The contrast loss for the 5 candidate paths of the "on-light" sample is obtained, which provides key data support for constructing the total loss and achieving accurate suppression of the error path in step S5. Step S5 fuses the two types of losses by weighting, which not only retains the optimization of the correct path by the CTC loss but also strengthens the suppression of the error path by the contrast loss; the parameter is updated by back propagation to accurately improve the model discrimination, effectively reduce the misrecognition rate of the short command word, and adapt to the needs of the embedded device scenario.
[0082] In one embodiment, the step of training the initial CTC speech recognition model until the model converges on the validation set to obtain a converged model includes:
[0083] S10, obtaining a speech training data set and a speech validation data set;
[0084] S11, training the initial CTC speech recognition model based on the speech training data set, calculating the model loss value by the CTC loss function, updating the model parameters based on the loss value, and obtaining an intermediate model;
[0085] S12, inputting the speech validation data set into the intermediate model to obtain the word error rate of the validation set and the model loss value;
[0086] S13, determining whether the word error rate of the validation set no longer decreases or the model loss value continuously decreases for multiple rounds, if the condition is met, the intermediate model is determined as the converged model, if the condition is not met, the parameter is returned to continue training and updating.
[0087] In this embodiment, first, a training dataset containing 100,000 speech samples is constructed, covering 2-4 high-frequency short command words such as "turn on the light", "turn off the light", "turn on the air conditioner", and "I'm back". Not only does it include different age groups such as young, middle-aged, and old, different genders such as male and female, and different accents such as northern and southern accents, but it also intentionally adds noise samples such as TV background noise, refrigerator running noise, and family conversation noise that are commonly found in home environments to ensure that the dataset can simulate real-world usage environments. At the same time, 10,000 samples are randomly selected from the training dataset as a validation dataset, strictly maintaining consistency with the training dataset in terms of command word distribution ratio, noise type, and intensity to avoid affecting the accuracy of subsequent convergence judgments due to differences in data distribution.
[0088] Next, the intermediate model is trained. The initial model uses a "convolutional neural network + long short-term memory network" architecture. The convolutional neural network layer extracts local spectral features through 3 layers of convolution operations, and the long short-term memory network layer has 2 layers of bidirectional structure to capture temporal dependencies. The output layer is a fully connected layer (including 40 classes of blank labels). Based on the Pytorch framework, the training dataset is input into the model in batches of 32, and the loss value is calculated using the connectionist temporal classification loss function (for example, the loss value of a batch of "turn on the light" samples is 1.8). This function quantifies the prediction bias by comparing the original predicted value with the true phoneme sequence. Then, the adaptive momentum estimation algorithm optimizer (initial learning rate 0.001) is used to update the convolution kernel weights of the convolutional neural network, the hidden layer weights of the long short-term memory network, and the fully connected weights of the output layer based on the loss value through backpropagation. After completing a complete traversal of the training dataset (i.e., one training period), an intermediate model is generated.
[0089] Then, the model performance is verified. The speech validation dataset is input into the intermediate model in batches, and two key indicators are calculated: one is the word error rate of the validation set, which is calculated using the formula "(substitution errors + insertion errors + deletion errors) / total word count", for example, the word error rate of the 10th intermediate model is 9.2%; the other is the model loss value, which is the average connectionist temporal classification loss of the validation dataset on the intermediate model, for example, the 10th is 1.5.
[0090] Finally, the convergence is judged, and the convergence criteria are set as "the word error rate of the verification set does not decrease continuously for 3-5 rounds" or "the model loss value does not decrease continuously for 3-5 rounds". For example, when the training is to the 12th round, the word error rate of the verification set is 7.5%, and the 13th round and the 14th round still maintain 7.5%, which meets the condition of "not decreasing continuously for 3 rounds", and at this time, the intermediate model generated in the 14th round is determined as the converged model; if the criteria are not met, the iteration training with the current parameter configuration is returned to continue, until the convergence condition is met. Through the construction of the data set fitting the real scene and the standard convergence judgment mechanism, the step ensures that the model has stable basic performance, improves the adaptability of the model to complex environments, and avoids overfitting through multiple rounds of verification, thereby providing a reliable benchmark model for subsequent optimization.
[0091] In one embodiment, the step of obtaining multiple candidate paths by adopting a path search algorithm to screen candidate paths based on the original output value output by the converged model comprises:
[0092] S20, obtaining a first original output value output by the converged model and not subjected to normalization processing;
[0093] S21, performing path search on the first original output value based on the path search algorithm to obtain a search result;
[0094] S22, selecting multiple predicted paths in the front of the probability ranking based on the search result;
[0095] S23, extracting the path structure of the multiple predicted paths to obtain multiple candidate paths.
[0096] In the embodiment, first, the first original output value of the converged model is obtained. The speech verification data set (containing "turn on the light" and "come back" samples) constructed in step S1 is input into the converged model in a scale of 32 per batch, and the first original output value of the output layer of the model, which is not subjected to normalization processing, is extracted, that is, the original prediction value of the model for each time step phoneme category of the speech signal, which has a shape of [time step (T), batch size (B), category number (C)]. Taking the "turn on the light" sample as an example, the time step T=100 (representing that the speech signal is divided into 100 time segments) after the model processing, the batch size B=32 (the current training batch contains 32 samples), and the category number C=40 (containing 40 phonemes including a blank label), so the specific shape of the original output value is [100, 32, 40], each numerical value corresponds to the prediction tendency of the model for a certain phoneme at a certain time step, and is the core data basis for path search.
[0097] Then, path search is performed based on a path search algorithm. In this embodiment, a prefix beam search algorithm (which meets the efficiency and accuracy requirements of short command word path search) is used to perform search with the first original output value as input: first, an empty prefix path set is initialized to store high-probability paths filtered at each step; then, the original output value is traversed by time step, and the probabilities of 40 phonemes predicted by the model at each time step are sorted, and only the paths corresponding to the top 20 phonemes in the probability ranking are retained to avoid excessive number of paths causing redundant calculation; during the traversal process, if duplicate paths containing a blank label appear (for example, the phonemes of "on" are predicted at two time steps, with a blank label in between), the duplicate paths are merged and removed, and finally the complete path search results of the batch of 32 samples are obtained, and the search results of the "turn on the light" sample include dozens of predicted paths of different phoneme sequence combinations.
[0098] Then, multiple predicted paths with high probability are selected. For the search results of the "turn on the light" sample, the predicted paths are sorted in descending order of overall probability value (the path probability is calculated by multiplying the phoneme prediction probabilities at each time step), and in combination with the calculation efficiency and the need to cover error paths, the top 5 predicted paths are selected, which are "on-light" (correct path, probability 0.82), "on-deng" (error path, probability 0.75), "kai-light" (error path, probability 0.71), "on-deng" (error path, probability 0.68), and "kai-deng" (error path, probability 0.65), to ensure that the selected paths include the correct path and cover typical error paths that are easily confused with "turn on the light".
[0099] Finally, the path structure of the predicted path is extracted to obtain a candidate path. The path structure is a phoneme sequence identifier list corresponding to each predicted path (ignoring the original probability value to avoid affecting subsequent training due to the inability to backpropagate the probability value), for example, the phoneme sequence identifier list corresponding to "on-light" is [5, 12] (5 represents the phoneme identifier of "on", and 12 represents the phoneme identifier of "light"), "on-deng" is [5, 13], "kai-light" is [6, 12], "on-deng" is [5, 14], and "kai-deng" is [6, 13]. Finally, 5 candidate paths of the "turn on the light" sample are obtained, and the candidate path selection process is completed. This step accurately obtains the original output value and the prefix beam search, which not only ensures that the selected candidate paths are high-probability paths that the model is actually inclined to, but also considers the calculation efficiency while covering key error paths, thereby providing accurate objects for subsequent contrast loss calculation.
[0100] In one embodiment, the step of performing CTC loss calculation on the reference path and taking the inverse of the CTC loss as the reference path score comprises:
[0101] S30, acquire the second original output value output by the converged model without normalization processing;
[0102] S31, determine the target phoneme sequence corresponding to the reference path, the target phoneme sequence being a sequence formed by splicing all sample phoneme label sequences in a training batch;
[0103] S32, acquire the actual length of the input audio calculated by the converged model as the input length of the second original output value;
[0104] S33, acquire the actual length of the phoneme sequence corresponding to each sample in the training batch as the target length of the target phoneme sequence;
[0105] S34, input the second original output value, the target phoneme sequence, the input length, and the target length into a CTC loss calculation function to calculate a loss value;
[0106] S35, take the reciprocal of the loss value to obtain a reference path score.
[0107] In the embodiment, first, the second original output value of the converged model is acquired. The second original output value is completely consistent with the data used in step S2 for screening the candidate paths, i.e., the original prediction value (shape [100, 32, 40], 100 is the time step, 32 is the batch size, and 40 is the number of phoneme categories) of the output layer of the converged model without normalization. Taking the "turn on the light" sample in the batch as an example, the second original output value records the prediction tendency of the model on 40 phonemes at 100 time steps, which is the core input data for subsequent loss calculation, and ensures the data consistency of the previous and subsequent steps to avoid errors. Secondly, the target phoneme sequence corresponding to the reference path is determined. The reference path is the real command word phoneme sequence matched with the input audio in the training data, and the "real phoneme label sequence" of the 32 samples in the current training batch needs to be spliced into the target phoneme sequence. For example, the real phoneme label of the "turn on the light" sample in the batch is [5, 12] (5 corresponds to "on" and 12 corresponds to "light"), the real phoneme label of the "I have come back" sample is [8, 15, 21], and the real phoneme labels of other samples are spliced in turn according to the actual phoneme labels. Finally, a target phoneme sequence list with a length equal to the sum of the lengths of the phoneme sequences of all samples in the batch is formed to ensure the correct path information of all samples in the batch.
[0108] Then the input length and the target length are obtained. The input length refers to the actual duration of the input audio after being calculated by the convergence model, that is, the effective time step corresponding to each sample in the second original output value (excluding the padding part), such as the actual duration of the "turn on the light" sample is 100, and the durations of other samples in the batch are 95, 102, etc. according to the audio length, forming an input length list with a length of 32. The target length refers to the actual length of the true phoneme sequence of each sample, such as the "turn on the light" sample is 2 and the "come back" sample is 3, and a target length list with a length of 32 is also formed, which is used to adapt the calculation requirements of different length samples for the CTC loss function. Then the CTC loss value of the reference path is calculated. The second original output value [100, 32, 40], the target phoneme sequence, the input length list, and the target length list are input into the CTC loss function (such as torch.nn.CTCLoss) of the Pytorch framework. The function aligns the model prediction and the true sequence by dynamic programming algorithm and quantifies the difference between them. For example, the CTC loss value of the "turn on the light" sample is 1.2, and the loss values of other samples in the batch are 1.1, 1.3, etc. according to the matching degree, and finally the average CTC loss value of the reference path in the batch (or the single sample loss value, which is set according to the training requirements) is output.
[0109] Finally, the loss value is taken as the opposite to obtain the reference path score. Since the CTC loss is essentially a "negative log likelihood probability", the smaller the loss value, the higher the prediction confidence of the model on the correct path, so the loss value needs to be taken as the opposite to convert it into a score. For example, the CTC loss value of the "turn on the light" sample is 1.2, and the reference path score is -1.2 after taking the opposite. The higher the score, the higher the matching degree of the path and the true command word, which provides a clear benchmark for comparing the scores of the candidate paths. This step ensures the accuracy and consistency of the loss calculation by reusing the original output value, standardizing the sequence and length parameters; converting the CTC loss into a score provides a direct benchmark for comparing losses, which helps to accurately distinguish between correct and incorrect paths in the subsequent steps and improves the model's discrimination ability.
[0110] In an embodiment, the step of comparing the path score of each candidate path with the reference path score to obtain a comparison loss comprises:
[0111] S40, obtaining a reference path score corresponding to the reference path;
[0112] S41, obtaining a candidate path score corresponding to each candidate path;
[0113] S42, calculating the difference between the candidate path score and the reference path score, and performing accumulation operation combined with a preset threshold to obtain an operation result;
[0114] S43, performing truncation processing on the operation result, and retaining a value not less than zero;
[0115] S44, determining the operation result after the truncation processing as the contrast loss of the corresponding candidate path.
[0116] In the embodiment, first, the reference path score is obtained, the reference path being the true phoneme sequence path of each sample in the batch, and the score being calculated in the previous step: taking the “turn on the light” sample as an example, the CTC loss value of the reference path “turn on the light” (phoneme identifier [5, 12]) is 1.2, and the reference path score (logp_ref) after taking the reciprocal is -1.2; the reference path scores of other samples in the batch such as “I have come back” (phoneme identifier [8, 15, 21]) are -1.1, -1.3, etc., and need to be stored one by one to ensure the sample matching of the subsequent contrast operation. Secondly, the score of each candidate path is obtained, the candidate path being the top 5 paths screened out in step S2, and the score of each path being calculated one by one: taking the 5 candidate paths of the “turn on the light” sample as an example, the score of “turn on the light” (correct path) is consistent with the reference path, which is -1.2; the score of “turn on the door” (phoneme identifier [5, 13]) after taking the reciprocal of the CTC loss (loss value 1.5) is -1.5; the score of “turn on the light” (phoneme identifier [6, 12]) is -1.4; the score of “turn on the light” (phoneme identifier [5, 14]) is -1.3; the score of “turn on the light” (phoneme identifier [6, 13]) is -1.6; and the scores of the candidate paths of other samples are also calculated according to the same logic, forming a complete candidate path score list.
[0117] Then, difference and accumulation operations are performed. According to the scheme setting, the preset threshold value γ is in the range of 0.1-0.5, and combined with the characteristics that the “turn on the light” short command word is easily disturbed by pronunciation, γ is set to 0.3. Taking the “turn on the light” sample “key-lamp” candidate path as an example, the basic operation result is first calculated according to the formula “contrastive_loss = torch.clamp(gamma + log_p_cand-logp_ref, min = 0.0)”: 0.3 + 1.6-1.2 = 0.7; similarly, “key-lamp” is 0.3 + 1.4-1.2 = 0.5, “key-lamp” is 0.3 + 1.2-1.2 = 0.3, and the basic operation is completed. Then, the operation results are truncated, and the torch.clamp function of the Pytorch framework is called to truncate all basic operation results less than 0.0 to 0.0, so as to ensure that the loss value is non-negative. In this embodiment, the basic operation results of the 5 candidate paths of the “turn on the light” sample are all greater than 0.0, and do not need to be truncated; if the candidate path score of a sample is lower than the reference path score (for example, the basic operation result is-0.1), the loss value after truncation is 0.0, which avoids meaningless negative loss interference with model optimization.
[0118] Finally, the contrastive loss of the candidate path is determined, and the truncated operation result is directly taken as the contrastive loss of the corresponding candidate path: in the “turn on the light” sample, the contrastive loss of the “key-lamp” path is 0.7, the contrastive loss of the “key-lamp” path is 0.6, the contrastive loss of the “key-lamp” path is 0.5, the contrastive loss of the “key-lamp” path is 0.4, and the contrastive loss of the “key-lamp” path is 0.3; other samples in the batch are calculated according to the same process, and finally a contrastive loss matrix of 32 samples in each batch and 5 candidate paths of each sample is obtained, which provides key data for the total loss calculation of step S5. This step ensures the consistency of the operation by reusing the previous data, and realizes the hierarchical punishment of the wrong path by combining the preset threshold value and the truncation processing, which not only accurately suppresses the high-risk wrong path, but also avoids excessive constraint, provides reasonable signals for total loss optimization, and helps to improve the model discrimination ability.
[0119] In one embodiment, the step of obtaining a candidate path score corresponding to each candidate path comprises:
[0120] S410, obtaining a candidate phoneme sequence corresponding to each candidate path, and length information of the candidate phoneme sequence;
[0121] S411, obtaining a feature sequence output by the converged model, and actual length information of the feature sequence;
[0122] S412, input the candidate phoneme sequence, the length information thereof, and the feature sequence, the actual length information thereof into a CTC loss function to obtain a candidate CTC loss value corresponding to the candidate path;
[0123] S413, take the opposite of the candidate CTC loss value to obtain a candidate path score corresponding to the candidate path.
[0124] In the embodiment, first, the candidate phoneme sequence and the length information are obtained, the candidate path is the top 5 paths screened in step S2, and the candidate phoneme sequence and the length information corresponding to each path need to be extracted. Taking the “turn on the light” sample as an example, the phoneme sequences of the 5 candidate paths are “turn on the light” ([5, 12]), “turn on the light” ([5, 13]), “turn on the light” ([6, 12]), “turn on the light” ([5, 14]), and “turn on the light” ([6, 13]), respectively. The length information corresponding to each path is 2 (each path contains 2 valid phonemes), forming a candidate phoneme sequence list and a length list to ensure one-to-one correspondence with the path. Second, the feature sequence and the actual length information are obtained. The feature sequence is the original output value (logits value) of the output layer of the converged model, which is completely consistent with the data used in steps S2 and S3, and has a shape of [100, 32, 40] (100 is the time step, 32 is the batch size, and 40 is the number of phoneme categories). The predicted features of 32 samples including the “turn on the light” sample are included. The actual length information refers to the effective time step (padding part is removed) of each sample after being processed by the model. For example, the actual length of the “turn on the light” sample is 100, and the actual lengths of other samples in the batch are 95, 102, etc. according to the audio length, forming an actual length list with a length of 32 to ensure that the loss calculation is adapted to the true length of different samples.
[0125] Then the candidate CTC loss value is calculated, and the candidate phoneme sequence, its length information, and the feature sequence, its actual length information, are input into the CTC loss function (such as torch.nn.CTCLoss) of the Pytorch framework: taking the "on-light" path of the "on-light" sample as an example, the input data includes the candidate phoneme sequence [5, 13], the length 2, and the [100, 1, 40] sub-matrix corresponding to the sample in the feature sequence (extracting the features of the "on-light" sample in the batch), and the actual length 100; the function aligns the predicted features and the candidate phoneme sequence through the dynamic programming algorithm, and calculates the candidate CTC loss value of the "on-light" path as 1.5; similarly, the "key-light" path loss value is 1.4, the "on-equal" is 1.3, the "key-light" is 1.6, and the "on-light" (correct path) loss value is 1.2, and the loss calculation of all candidate paths is completed. Finally, the candidate CTC loss value is taken as the opposite to obtain the candidate path score, since the smaller the CTC loss value represents the higher the matching degree of the path and the model prediction, the loss value needs to be converted into a score by taking the opposite: the "on-light" path score is -1.5, the "key-light" is -1.4, the "on-equal" is -1.3, the "key-light" is -1.6, and the "on-light" is -1.2; the candidate path scores of other samples in the batch are calculated according to the same logic, and finally a score matrix of 5 candidate paths for each sample is formed, providing a quantitative basis for subsequent comparison operations. This step ensures the accuracy and consistency of candidate path score calculation by reusing the previous feature data and standardized phoneme sequence processing; converting the loss value into a score directly reflects the path matching degree, provides reliable data for comparison loss calculation, and helps to accurately distinguish correct and incorrect paths.
[0126] In one embodiment, the step of weighting and summing the CTC loss and the comparison loss to obtain a total loss, and iteratively adjusting the parameters of the converged model using the total loss to obtain a target speech recognition model, comprises:
[0127] S50, obtaining the CTC loss corresponding to the reference path and the comparison loss corresponding to each candidate path;
[0128] S51, setting a weight parameter corresponding to the comparison loss, multiplying the comparison loss and the weight parameter to obtain a weighted comparison loss;
[0129] S52, summing the CTC loss and the weighted comparison loss to obtain a total loss;
[0130] S53, based on the total loss, iteratively adjusting the parameters of the converged model through back propagation to obtain a target speech recognition model.
[0131] In this embodiment, first, the core loss data is obtained, the CTC loss of the reference path is the single sample or batch average loss calculated in the previous step, taking the "turn on the light" sample as an example, the CTC loss value (loss_ctc) corresponding to the reference path "turn on the light" is 1.2; the contrast loss of each candidate path has been determined in step S4, the contrast loss of the 5 candidate paths of the "turn on the light" sample is 0.3 ("turn on the light"), 0.6 ("turn on the door"), 0.5 ("turn on the light"), 0.4 ("turn on the light"), 0.7 ("turn on the door"), and the contrast loss of all candidate paths of the sample needs to be calculated first: 0.3+0.6+0.5+0.4+0.7=2.5 (if batch calculation, take the average of all sample contrast losses), ensure that the loss data corresponds to the sample one by one. Secondly, the weight parameter is set and the weighted contrast loss is calculated, according to the scheme requirement, the weight parameter (λ) of the contrast loss needs to be taken in the interval of "0.1-1.0", combined with the characteristics of the "turn on the light" short command word which needs to focus on suppressing the wrong path, λ is set to 0.8 (considering the error suppression strength and model stability). According to the formula "weighted_contrastive_loss=contrast loss sum x λ", the weighted contrast loss of the "turn on the light" sample is 2.5 x 0.8 = 2.0; the weighted contrast loss of other samples in the batch such as "came back" (contrast loss sum 2.3) is 2.3 x 0.8 = 1.84, forming a batch weighted contrast loss list, ensuring that the loss weight adapts to the scene requirement.
[0132] Then the total loss is calculated, according to the formula "loss_total=loss_ctc+weighted_contrastive_loss", the CTC loss and weighted contrast loss of the "turn on the light" sample are substituted into the formula to get the total loss: 1.2+2.0=3.2; other samples in the batch are calculated according to the same logic, such as the "came back" sample (CTC loss 1.1, weighted contrast loss 1.84), the total loss is 1.1+1.84=2.94, the final output of the total loss average of the training batch (or single sample total loss, according to the training strategy setting) provides a quantitative basis for model parameter adjustment. Then, based on the total loss, the back propagation and parameter iteration are carried out, the total loss is input into the optimizer of the Pytorch framework (the adaptive momentum estimation algorithm optimizer of the previous step is used, the learning rate is 0.001), the gradient of the total loss to each parameter of the model is calculated through the back propagation mechanism: for example, the phoneme prediction weight related to the "turn on the door" wrong path (such as the output weight of phoneme 6 corresponding to "turn on the light" and phoneme 13 corresponding to "turn on the door"), the gradient calculation result is positive, the optimizer will lower the weight in the gradient direction; for the phoneme weight related to the "turn on the light" correct path (phonemes 5 and 12), the gradient is negative, the optimizer will increase the weight, and the prediction tendency of the correct path will be strengthened.
[0133] Finally, iterate training until the model converges, and calculate the total loss and update the parameters after each batch is completed, i.e. complete a local iteration; after traversing the complete training data set (100,000 samples), input the validation data set into the model, and calculate the word error rate of the validation set (e.g. the initial error rate is 7.8%, and after the first iteration, it decreases to 6.5%). Repeat the "total loss calculation-back propagation-parameter update" process until the word error rate of the validation set does not decrease for 3 consecutive rounds (e.g. the 8th-10th round is stable at 3.2%), at which point the iteration is stopped, and the current model is determined as the target speech recognition model. The misrecognition rate of the model for short command words such as "turn on the light" is significantly reduced, and the model is adapted to the needs of the smart home scene. This step combines the two types of losses by weighting, which not only preserves the optimization ability of the CTC loss for the correct path, but also strengthens the error path suppression through the contrast loss; precise adjustment of parameters through back propagation effectively improves the model's ability to distinguish similar pronunciation command words, and finally obtains a target model with high recognition accuracy.
[0134] Reference Figure 2 A speech recognition device for reducing command word misrecognition, comprising:
[0135] A convergence module 100 for training an initial CTC speech recognition model until the model converges on a validation set, obtaining a converged model;
[0136] A screening module 200 for performing candidate path screening using a path search algorithm based on the original output value output by the converged model, obtaining multiple candidate paths;
[0137] A calculation module 300 for performing CTC loss calculation on the reference path, and taking the inverse of the CTC loss as the reference path score;
[0138] A comparison operation module 400 for comparing the path score of each candidate path with the reference path score to obtain a contrast loss;
[0139] An iterative adjustment module 500 for weighting and summing the CTC loss and the contrast loss to obtain a total loss, and using the total loss to iteratively adjust the parameters of the converged model to obtain a target speech recognition model.
[0140] Further, the above-mentioned convergence module 100 comprises:
[0141] A speech data set acquisition unit for acquiring a speech training data set and a speech validation data set;
[0142] An intermediate model training unit for training the initial CTC speech recognition model based on the speech training data set, calculating the model loss value through the CTC loss function, updating the model parameters based on the loss value, and obtaining an intermediate model;
[0143] The verification index acquisition unit inputs the voice verification data set into the intermediate model, and acquires a verification set word error rate and a model loss value.
[0144] The convergence judgment and model determination unit judges whether the verification set word error rate no longer decreases or whether the model loss value no longer decreases continuously for multiple rounds. If the judgment is met, the intermediate model is determined as a converged model. If the judgment is not met, the training and parameter updating are continued.
[0145] Further, the screening module 200 includes:
[0146] The original output value acquisition unit acquires original output values output by the converged model without normalization processing.
[0147] The path search execution unit performs path search on the original output values based on the path search algorithm, and obtains a search result.
[0148] The predicted path selection unit selects multiple predicted paths in the front of a probability ranking based on the search result.
[0149] The candidate path generation unit extracts path structures of the multiple predicted paths, and obtains multiple candidate paths.
[0150] Further, the calculation module 300 includes:
[0151] The original output value acquisition unit acquires original output values output by the converged model without normalization processing.
[0152] The target phoneme sequence determination unit determines a target phoneme sequence corresponding to the reference path. The target phoneme sequence is a sequence formed by splicing all sample phoneme identification sequences in a training batch.
[0153] The input length acquisition unit acquires an actual duration of input audio after calculation by the converged model as an input length of the original output value.
[0154] The target length acquisition unit acquires an actual length of a phoneme sequence corresponding to each sample in a training batch as a target length of the target phoneme sequence.
[0155] The CTC loss calculation unit inputs the original output value, the target phoneme sequence, the input length, and the target length into a CTC loss calculation function, and calculates a loss value.
[0156] The reference path score generation unit takes the opposite of the loss value to obtain a reference path score.
[0157] Further, the comparison operation module 400 described above comprises:
[0158] The reference path score acquisition unit is configured to acquire a reference path score corresponding to the reference path.
[0159] The candidate path score acquisition unit is configured to acquire a candidate path score corresponding to each of the candidate paths.
[0160] The difference and accumulation operation unit is configured to perform difference calculation on the candidate path score and the reference path score, and perform accumulation operation in combination with a preset threshold to obtain an operation result.
[0161] The operation result truncation unit is configured to perform truncation processing on the operation result to retain a value not less than zero.
[0162] The comparison loss determination unit is configured to determine the operation result after the truncation processing as a comparison loss corresponding to the candidate path.
[0163] Further, the candidate path score acquisition unit described above comprises:
[0164] The candidate phoneme sequence and length acquisition subunit is configured to acquire a candidate phoneme sequence corresponding to each of the candidate paths and length information of the candidate phoneme sequence.
[0165] The feature sequence and length acquisition subunit is configured to acquire a feature sequence output by the converged model and actual length information of the feature sequence.
[0166] The candidate CTC loss calculation subunit is configured to input the candidate phoneme sequence, the length information thereof, the feature sequence, and the actual length information thereof into a CTC loss function to obtain a candidate CTC loss value corresponding to the candidate path.
[0167] The candidate path score generation subunit is configured to take the negative of the candidate CTC loss value to obtain the candidate path score corresponding to the candidate path.
[0168] Further, the iterative adjustment module 500 described above comprises:
[0169] The core loss acquisition unit is configured to acquire a CTC loss corresponding to the reference path and comparison losses corresponding to the candidate paths.
[0170] The weighted comparison loss calculation unit is configured to set a weight parameter corresponding to the comparison loss, multiply the comparison loss by the weight parameter to obtain a weighted comparison loss.
[0171] The total loss calculation unit is configured to perform summation operation on the CTC loss and the weighted comparison loss to obtain a total loss.
[0172] a model parameter iterative adjustment unit configured to iteratively adjust parameters of the converged model based on the total loss by means of back propagation to obtain a target speech recognition model.
[0173] Reference Figure 3 In the embodiments of the present application, a computer device is also provided, which can be a server, and the internal structure thereof can be as shown in Figure 3 The computer device includes a processor, a memory, a network interface and a database connected through a bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores operations, a computer program and a database. The internal memory provides an environment for the operations and the computer program in the non-volatile storage medium to run. The database of the computer device is configured to store data of the speech recognition method for reducing command word misrecognition. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a speech recognition method for reducing command word misrecognition, including the steps of: training an initial CTC speech recognition model until the model converges on a validation set to obtain a converged model; based on original output values output by the converged model, performing candidate path screening using a path search algorithm to obtain a plurality of candidate paths; performing CTC loss calculation on a reference path, and taking the inverse of the CTC loss as a reference path score; comparing and operating path scores of each of the candidate paths with the reference path score to obtain a comparison loss; performing weighted summation of the CTC loss and the comparison loss to obtain a total loss, and iteratively adjusting parameters of the converged model using the total loss to obtain a target speech recognition model.
[0174] An embodiment of the present application also provides a computer readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement a speech recognition method for reducing command word misrecognition, including the steps of: training an initial CTC speech recognition model until the model converges on a validation set to obtain a converged model; based on original output values output by the converged model, performing candidate path screening using a path search algorithm to obtain a plurality of candidate paths; performing CTC loss calculation on a reference path, and taking the inverse of the CTC loss as a reference path score; comparing and operating path scores of each of the candidate paths with the reference path score to obtain a comparison loss; performing weighted summation of the CTC loss and the comparison loss to obtain a total loss, and iteratively adjusting parameters of the converged model using the total loss to obtain a target speech recognition model.
[0175] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database or other medium provided by the present application and used in the embodiments can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0176] The above only describes the preferred embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation using the content of the present application specification and drawings, or direct or indirect application in other related technical fields, is also included in the patent protection scope of the present application.
Claims
1. A voice recognition method of reducing misrecognition of a command word, characterized by, The application relates to a method for training a target speech recognition model, comprising the following steps: training an initial CTC speech recognition model until the model converges on a validation set to obtain a converged model; based on original output values output by the converged model, performing candidate path screening by using a path search algorithm to obtain multiple candidate paths; performing CTC loss calculation on a reference path, and taking the inverse of the CTC loss as a reference path score; comparing path scores of each candidate path with the reference path score to obtain a comparison loss; performing weighted summation of the CTC loss and the comparison loss to obtain a total loss, and iteratively adjusting parameters of the converged model by using the total loss to obtain a target speech recognition model; the step of performing CTC loss calculation on a reference path and taking the inverse of the CTC loss as a reference path score comprises the following steps: obtaining second original output values output by the converged model without normalization processing; determining a target phoneme sequence corresponding to the reference path, wherein the target phoneme sequence is a sequence formed by splicing all sample phoneme label sequences in a training batch; obtaining an actual length of input audio calculated by the converged model as an input length of the second original output values; obtaining an actual length of a phoneme sequence corresponding to each sample in the training batch as a target length of the target phoneme sequence; inputting the second original output values, the target phoneme sequence, the input length and the target length into a CTC loss calculation function to obtain a loss value; taking the inverse of the loss value to obtain a reference path score; the step of performing weighted summation of the CTC loss and the comparison loss to obtain a total loss, and iteratively adjusting parameters of the converged model by using the total loss to obtain a target speech recognition model comprises the following steps: obtaining a CTC loss corresponding to the reference path and a comparison loss corresponding to each candidate path; setting a weight parameter corresponding to the comparison loss, and performing multiplication operation of the comparison loss and the weight parameter to obtain a weighted comparison loss; performing summation operation of the CTC loss and the weighted comparison loss to obtain a total loss; iteratively adjusting parameters of the converged model by using the total loss in a back propagation mode to obtain a target speech recognition model. 2.The voice recognition method of reducing misrecognition of a command word according to claim 1, characterized in that, the step of training an initial CTC speech recognition model until the model converges on a validation set to obtain a converged model comprises the following steps: obtaining a speech training data set and a speech validation data set; training the initial CTC speech recognition model based on the speech training data set, calculating a model loss value by using a CTC loss function, updating model parameters based on the loss value to obtain an intermediate model; inputting the speech validation data set into the intermediate model to obtain a word error rate of a validation set and a model loss value; determining whether the word error rate of the validation set no longer decreases or whether the model loss value continuously decreases for multiple rounds, if yes, determining the intermediate model as the converged model, and if no, returning to continue training and updating parameters. 3.The voice recognition method of reducing misrecognition of a command word according to claim 1, characterized in that, the step of obtaining multiple candidate paths by using a path search algorithm based on original output values output by the converged model comprises the following steps: obtain a first original output value of the convergent model output without normalization processing; perform path searching on the first original output value based on the path searching algorithm to obtain a search result; select a plurality of predicted paths in a probability order based on the search result; extract path structures of the plurality of predicted paths to obtain a plurality of candidate paths. 4.The voice recognition method of reducing misrecognition of a command word according to claim 1, characterized in that, The step of comparing the path score of each candidate path with the reference path score to obtain a comparison loss comprises: obtaining a reference path score corresponding to the reference path; obtaining a candidate path score corresponding to each candidate path; performing difference calculation on the candidate path score and the reference path score, and performing accumulation operation combined with a preset threshold to obtain an operation result; performing truncation processing on the operation result to retain a value not less than zero; determining the operation result after the truncation processing as the comparison loss of the corresponding candidate path. 5.The voice recognition method of reducing misrecognition of a command word according to claim 4, characterized in that, The step of obtaining the candidate path score corresponding to each candidate path comprises: obtaining a candidate phoneme sequence corresponding to each candidate path and length information of the candidate phoneme sequence; obtaining a feature sequence output by the convergent model and actual length information of the feature sequence; inputting the candidate phoneme sequence, the length information thereof, the feature sequence, and the actual length information thereof into a CTC loss function to obtain a candidate CTC loss value corresponding to the candidate path; taking the inverse of the candidate CTC loss value to obtain the candidate path score corresponding to the candidate path.
6. Speech recognition apparatus for reducing misrecognition of command words, for implementing the method according to any one of claims 1 to 5, characterized in that comprise: a convergent module configured to train an initial CTC speech recognition model until the model converges on a validation set to obtain a convergent model; a screening module configured to perform candidate path screening based on an original output value output by the convergent model using a path searching algorithm to obtain a plurality of candidate paths; a calculation module configured to perform CTC loss calculation on a reference path and take the inverse of the CTC loss as a reference path score; a comparison operation module configured to compare the path score of each candidate path with the reference path score to obtain a comparison loss; an iterative adjustment module configured to perform weighted summation of the CTC loss and the comparison loss to obtain a total loss, perform iterative adjustment on parameters of the convergent model using the total loss, and obtain a target speech recognition model. 7.A speech recognition device that reduces misrecognition of a command word, characterized by, comprise: a processor; a memory configured to store a computer program; wherein the processor implements the speech recognition method for reducing misrecognition of a command word in any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the speech recognition method for reducing misrecognition of a command word in any one of claims 1 to 5.
Citation Information
Patent Citations
Acoustic model training method and device, computer equipment and storage medium
CN111128137A
Model determination method and related device
CN117828353A