Speech recognition model training method and device, speech recognition method and device and electronic equipment
By combining the output of the encoder and decoder in speech recognition model training to calculate the total loss value and adjust the model parameters, the problem of insufficient contextual semantic modeling capabilities of the Transformer model is solved and the accuracy of speech recognition is improved.
Patent Information
- Application Number
- CN202410034887.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-09
- Publication Date
- 2024-09-17
AI Technical Summary
In speech recognition, the Transformer model has weak contextual semantic modeling capabilities due to the independent multi-head attention mechanism, resulting in low recognition accuracy.
During speech recognition model training, the output of the encoder and decoder is combined to calculate the total loss value and adjust the model parameters to enhance the semantic modeling ability of the encoder and improve the semantic recognition accuracy of the speech recognition model.
The speech recognition accuracy of the speech recognition model is improved, the model parameters are optimized by fusing the output of the encoder and the decoder, and the semantic information modeling capability is enhanced.
Smart Images

Figure CN118658463A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology and provides a speech recognition model training, a speech recognition method, a device and an electronic device. Background Art
[0002] Using artificial intelligence (AI) technology for speech recognition is an important research direction. The speech recognition model can adopt an encoder-decoder architecture. The encoder is responsible for mapping the acoustic features of speech, and the decoder is responsible for modeling semantic information. The mainstream model using the encoder-decoder architecture is the Transformer model, which is a model based on the self-attention mechanism proposed by Google in 2017.
[0003] Both the encoder and decoder in the Transformer model include a multi-head attention mechanism, which expands the model's ability to focus on different locations. However, since the multiple heads are independent of each other, the Transformer model's contextual semantic modeling capability is weaker, which makes the speech recognition accuracy using the model low. Summary of the invention
[0004] The embodiments of the present application provide a speech recognition model training, a speech recognition method, an apparatus and an electronic device for improving the accuracy of speech recognition by the speech recognition model.
[0005] In a first aspect, an embodiment of the present application provides a speech recognition model training method, the method comprising: processing sample speech data through an encoder of a first speech recognition model to obtain acoustic feature data; processing the acoustic feature data through a decoder of the first speech recognition model to obtain predicted text data; determining a total loss value based on first fusion data, the first fusion data being obtained by fusing the acoustic feature data and the predicted text data; and adjusting model parameters of the first speech recognition model based on the total loss value to obtain a second speech recognition model.
[0006] In the embodiment of the present application, since the fused data is taken into account when calculating the total loss value, and the fused data is obtained based on the output of the encoder and the output of the decoder, adjusting the parameters of the speech recognition model based on the total loss value is equivalent to training the speech recognition model in combination with the output of the encoder and the output of the decoder. The decoder has the ability to process semantic modeling, and the fused data is taken into account when optimizing the model parameters of the encoder based on the total loss value, which enables the encoder to have certain semantic modeling capabilities, thereby optimizing the semantic information modeling capabilities of the encoder, which enables the speech recognition model to perform semantic recognition more accurately, and thus improves the accuracy of speech recognition by the trained speech recognition model.
[0007] In a second aspect, an embodiment of the present application provides a speech recognition method, comprising: obtaining target speech data to be recognized; inputting the target speech data into a second speech recognition model to obtain text data, wherein the second speech recognition model is trained by the speech recognition model training method provided in an embodiment of the present application.
[0008] In a third aspect, an embodiment of the present application provides a speech recognition model training device, the device comprising: a data acquisition module, used to process sample speech data through an encoder of a first speech recognition model to obtain acoustic feature data; process the acoustic feature data through a decoder of the first speech recognition model to obtain predicted text data; a loss value determination module, used to determine a total loss value based on first fusion data, wherein the first fusion data is obtained by fusing the acoustic feature data and the predicted text data; a model training module, used to adjust the model parameters of the first speech recognition model based on the total loss value to obtain a second speech recognition model.
[0009] In a fourth aspect, an embodiment of the present application provides a speech recognition device, comprising: a speech data acquisition module, used to acquire target speech data to be recognized; and a speech data processing module, inputting the target speech data into a second speech recognition model to obtain text data, wherein the second speech recognition model is trained by the speech recognition model training method in the above-mentioned first aspect.
[0010] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements a method as described in any one of the first and second aspects by executing the instructions stored in the memory.
[0011] In a sixth aspect, an embodiment of the present application provides a computer program product, comprising computer instructions, which, when executed on a computer, enables the above-mentioned method as described in any one of the first aspect and the second aspect to be implemented.
[0012] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed on a computer, the computer executes a method as described in any one of the first aspect and the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 A schematic diagram of an application environment of the speech recognition method provided in an embodiment of the present application;
[0014] Figure 2A A schematic diagram of a speech recognition scenario provided in an embodiment of the present application;
[0015] Figure 2B A data flow diagram of a voice response provided in an embodiment of the present application;
[0016] Figure 3 A flowchart of a speech recognition model training method provided in an embodiment of the present application;
[0017] Figure 4 A schematic diagram of the structure of a first speech recognition model provided in an embodiment of the present application;
[0018] Figure 5 A schematic diagram of a method for obtaining a total loss value provided in an embodiment of the present application;
[0019] Figure 6 A flow chart of a speech recognition method provided in an embodiment of the present application;
[0020] Figure 7 An example diagram of the speech-to-text process of a terminal during the translation process provided in an embodiment of the present application;
[0021] Figure 8 A schematic diagram of the structure of a speech recognition model training device provided in an embodiment of the present application;
[0022] Fig. 9 A schematic diagram of the structure of a speech recognition device provided in an embodiment of the present application;
[0023] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to better understand the technical solution provided by the embodiments of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0025] The following first describes an application environment applicable to the embodiments of the present application.
[0026] See also Figure 1 , which illustrates a schematic diagram of an application environment of the speech recognition method provided in an embodiment of the present application. Figure 1 The server 110 is connected to the terminal device 120 via a network, wherein the network is used to provide a medium for a communication link between the server 110 and the terminal device 120. The server 110 may be a virtual server or a physical server, etc., the virtual server is such as a cloud server, and the terminal device 120 may be a wearable device, a television, a mobile phone or a computer, etc.
[0027] The solutions provided in the embodiments of the present application (such as the speech recognition model training method and the speech recognition method) can be applied to the same electronic device, which can be Figure 1 The server 110 shown in .
[0028] In some embodiments, the terminal device 120 can record the user's voice to obtain the user's voice data, and the terminal device 120 sends the user's voice data to the server 110 through the network. After the server 110 receives the user's audio data, the voice data can be used to train a voice recognition model, and the trained model can also be used to recognize and output text data. The process of training the voice recognition model and the process of voice recognition will be described below.
[0029] The following is an example introduction to the scenarios in which the solution provided in the embodiments of the present application can be applied.
[0030] Figure 2A A schematic diagram of a scenario provided by an embodiment of the present application is illustrated. The scenario includes a user sending audio to a speech recognition system, and the speech recognition system receives and analyzes the audio to obtain an analysis result (such as text data).
[0031] This method can meet different needs of converting audio into text, such as social chat, subtitle generation or meeting minutes, etc. For example, in social chat, in order to facilitate users to view when it is inconvenient to listen to the voice, the voice uploaded by the user needs to be converted into text. The user transmits the audio to the software with voice recognition function through the terminal device, and the software converts the audio into text and displays it on the user's terminal device.
[0032] The solution involved in the embodiment of the present application can also be applied to the scenario of voice response. Figure 2B A data flow diagram illustrating a voice response. Figure 2B The speech recognition module, intent understanding module, text synthesis module and speech synthesis module are illustrated. Figure 2B Each module shown can be regarded as a module or device or equipment that can perform corresponding functions. For example, the speech recognition module can be a virtual function module or device or equipment that can perform speech recognition functions. The speech recognition module can be regarded as a device that implements or executes the speech recognition model training method and speech recognition method in the embodiment of the present application, such as a first device. The first device can be such as Figure 1 The server, intent understanding module, text synthesis module, speech synthesis module, etc. shown in can all run on the first device.
[0033] The first device receives voice data transmitted by the user device in real time, and then inputs the voice data into the voice recognition module. After rapid decoding, the voice recognition module inputs the output result into the intention understanding module. Based on the intention understanding judgment, the judgment logic is matched to the reply to be answered. The text synthesis module generates the text to be synthesized, and the synthesized text is input into the voice synthesis module. The voice synthesis module generates a response voice and responds, completing a round of voice response.
[0034] In conjunction with the accompanying drawings, a speech recognition model training method involved in an embodiment of the present application is described below. The method can be performed by a speech recognition model training device, which can be implemented by a device with a processing function, such as one or more servers, for example. Figure 1 The server involved in the speech recognition model training device can also be implemented by a hardware module or software module installed in a server or other electronic device. The software module is such as an application program. The specific implementation form of the speech recognition model training device is not specifically limited in this document. For example, the speech recognition model training device can be composed of Figure 1 The speech processing system involved, Figure 2A The speech processing system shown or Figure 2B The speech recognition module involved is implemented.
[0035] Please refer to Figure 3 , which is a flow chart of a speech recognition model training method provided in an embodiment of the present application.
[0036] S301, the speech recognition model training device processes sample speech data through the encoder of the first speech recognition model to obtain acoustic feature data.
[0037] The number of sample voice data may be one or more. For example, the number of sample voice data involved in the embodiment of the present application may be hundreds, thousands or more. The embodiment of the present application does not limit the number of sample voice data. One of the sample voice data may include multiple frames of sample voice data.
[0038] The speech recognition model training device may obtain sample speech data from other devices (e.g., a user's terminal device). Alternatively, the speech recognition model training device may preprocess the collected speech to obtain sample speech data. The following is an example of how to preprocess the collected speech.
[0039] Exemplarily, the speech recognition model training device can collect multiple voices, or obtain multiple voices from other devices, etc. Optionally, the sampling frequencies of the multiple voices can be the same. The speech recognition model training device can perform feature extraction on the multiple voices respectively to obtain the voice features of the multiple voices, and so on to obtain multiple voice features. For example, Fbank processing can be used to extract features from multiple voices. Fbank processing extracts important features by analyzing the spectral features of the voices. For example, the dimension of the spectral features of each of the multiple voice features can be 80 dimensions. Optionally, the speech recognition model training device can also perform length padding on the multiple voice features respectively to obtain multiple sample voice data of the first length. The first length can be pre-stored in the speech recognition model training device. In this way, multiple sample voice data of the first length can be obtained.
[0040] In a possible implementation, the speech recognition model training device may also perform index processing on the multiple speech sounds, obtain a text index applied to each of the multiple speech sounds, and associate and save the multiple speech sounds and the text index applied to each of the multiple speech sounds to obtain an index file. In other words, the index file includes the position of each of the multiple speech sounds and the text information corresponding to each speech sound, that is, the text data manually annotated for the sample speech data.
[0041] After obtaining the sample speech data, the speech recognition model training device processes the sample speech data through the encoder of the first speech recognition model to obtain acoustic feature data, which represents the statistical results of the sample speech data in the spectral feature space. The first speech recognition model can be an end-to-end deep learning neural network, and the first speech recognition model includes an encoder and a decoder, such as a Transformer model. In addition to the encoder in the Transformer model, the encoder of the Conformer model can also be used.
[0042] The following is an example of how to obtain acoustic feature data.
[0043] Exemplarily, the speech recognition model training device may process multiple frames of sample speech data through an encoder of the first speech recognition model to obtain multiple first matrices. The speech recognition model training device may fuse multiple first matrices through an encoder of the first speech recognition model to obtain a fused matrix, determine multiple second matrices based on the features of the multiple frames of sample speech data and the fused matrix, and perform nonlinear transformation and mapping processing on each element in the multiple second matrices to obtain acoustic feature data.
[0044] Among them, multiple first matrices correspond one-to-one to multiple frames of sample voice data, the first matrix i is used to represent the correlation between the sample voice data j corresponding to the first matrix i and the multiple frames of sample voice data, the first matrix i is any one of the multiple first matrices, and the sample voice data j is any one of the multiple frames of sample voice data. Among them, multiple second matrices correspond one-to-one to the features of the multiple frames of sample voice data, the second matrix k is used to represent the key feature m in the fused matrix, the key feature m corresponds to the sample voice data corresponding to the second matrix k, and the second matrix k is any one of the multiple second matrices.
[0045] In a possible implementation, the first speech recognition model may refer to Figure 4 A schematic diagram of the structure of a first speech recognition model is provided. Figure 4 As shown, the encoder includes n encoding layers. Each encoding layer includes a multi-head attention mechanism, a first normalization layer and a feedforward neural network. The multi-head attention mechanism includes a second normalization (SoftMax) layer, a first weighted summation layer (MatMul) layer, a second weighted summation layer (MatMul) layer and a normalization (Scale) layer. Optionally, a first convolution (Conv1d) layer is provided between the normalization layer and the second weighted summation layer. The addition of the first convolution layer enables information interaction between multiple heads of the multi-head attention mechanism, thereby enhancing the contextual information capture capability of the multiple heads, improving the semantic information extraction capability of the encoding layer, and improving the speech recognition effect of the speech recognition model.
[0046] Specifically, the sample speech data may be processed in n coding layers in sequence to obtain acoustic feature data. The processing process involved in one coding layer among the n coding layers is introduced below.
[0047] Exemplarily, the Q vector, K vector, and V vector are initialized. The Q vector, K vector, and V vector are all trainable parameter vectors. The first weighted summation layer performs similarity calculation on multiple frames of sample speech data based on the Q vector and the K vector, and outputs a self-attention score. The normalization layer normalizes the self-attention score. The second normalization layer normalizes the scaled result to obtain multiple first matrices, wherein the content of the first matrix has been shown in the previous text and will not be repeated here. The first convolution layer calculates one-dimensional convolution of multiple first matrices to obtain a fused matrix. The second weighted summation layer performs weighted addition based on the V vector and the fused matrix to obtain multiple second matrices, wherein the specific content of the second matrix has been shown in the previous text and will not be repeated here.
[0048] The speech recognition model training device weights the second matrix corresponding to the same output position and the elements of the sample speech data to obtain the first weighted result at each output position. Through the normalization layer, the first weighted result at each output position is normalized to obtain the first normalized result at each output position. Through the feedforward network, the first normalized result at each output position is nonlinearly transformed and mapped; the feedforward processing result and the first normalized result at the same output position are weighted to obtain the second weighted result at each output position; through the normalization layer, the second weighted result at each output position is normalized to obtain the second normalized result corresponding to each output position.
[0049] By analogy, after processing through n coding layers, acoustic feature data can be obtained.
[0050] S302, the speech recognition model training device processes the acoustic feature data through the decoder of the first speech recognition model to obtain predicted text data. The predicted text data can be understood as the text vector data predicted by the decoder this time.
[0051] The speech recognition model training device performs predictive mapping processing of language information on the acoustic feature data through the decoder of the first speech recognition model to obtain predicted text data.
[0052] Please continue to refer to 4, the first speech recognition model also includes a decoder. Figure 4 As shown, the decoder includes m decoding layers, where m is a positive integer. Each of the m decoding layers may include: a self-attention layer, a normalization layer, and a feedforward neural network. In addition to the decoder in the transformer model, the decoder can also use the decoder in the LSTM model.
[0053] Exemplarily, the speech recognition model training device sequentially passes the acoustic feature data through m decoding layers to obtain the predicted text data. The specific method of obtaining the predicted text data is described below.
[0054] The attention representation of each output position is obtained through the self-attention layer; the attention representation corresponding to the same output position and the elements of the acoustic feature data are weighted to obtain the third weighted result at each output position; the first weighted result at each output position is normalized through the normalization layer to obtain the third normalized result at each output position. The third normalized result at each output position is feedforward processed through the feedforward network; the feedforward processing result and the third normalized result at the same output position are weighted to obtain the fourth weighted result at each output position; the fourth weighted result at each output position is normalized through the normalization layer to obtain the fourth normalized processing result corresponding to each output position. After being processed through m decoding layers, the normalization module is used to obtain the probability combination at each output position to obtain the predicted text data.
[0055] In a possible implementation, the predicted text data indicates the probability distribution of each speech in the speech corresponding to the sample speech data in the dictionary, that is, the predicted text data describes the probability that each word in the speech sample is a preset word in the dictionary. The dictionary pre-stores multiple preset words and the index corresponding to each preset word. Furthermore, the speech recognition model training device can obtain the sample recognition text according to the predicted text data.
[0056] In a possible implementation, the predicted text data determines each word in the voice sample as a preset word with the highest corresponding probability in the dictionary, and sequentially combines the words determined for each word in the voice sample to obtain a sample recognition text.
[0057] For example, the dictionary includes n words. For each word in the speech sample, the first text recognition result records the probability of the word among the n words in the dictionary. If the probability of the word being the mth word in the pronunciation dictionary is the largest, the recognition result of the word is determined as the mth word in the pronunciation dictionary.
[0058] S303, the speech recognition model training device determines the total loss value based on the first fusion data.
[0059] In an optional implementation, the first speech recognition model further includes at least one linear layer, such as the at least one linear layer includes a first linear layer.
[0060] The first fused data is obtained by fusing the acoustic feature data and the predicted text data, such as performing weighted averaging of the acoustic feature data and the predicted text data to obtain the first fused data. The total loss value represents the error between the data predicted by the speech recognition model and the true value corresponding to the data. The total loss value can be a specific value, such as a specific loss value calculated based on a loss function.
[0061] There are multiple ways for the speech recognition model training device to determine the total loss value, which are introduced below.
[0062] Method 1: The speech recognition model training device can calculate the total loss value based on the first loss value and the second loss value.
[0063] The first loss value may be a specific value, which is used to represent the error between the first text data and the first preset text data, wherein the first preset text data is the real text data corresponding to the sample speech data, and may be text data manually annotated for the sample speech data.
[0064] For example, a method for determining the first loss value is as follows:
[0065] The first fused data is processed to obtain first text data; and a first loss value is determined based on the first text data and the first preset text data.
[0066] Specifically, the first fused data is input into the first linear layer, the first linear layer is used to perform nonlinear mapping on the first fused data, the first linear layer outputs text data corresponding to the first fused data, that is, the first text data, and the connectionist temporal classification (CTC) loss of the first text data and the first preset text data is calculated to obtain a first loss value.
[0067] For example, a calculation formula for the first loss value is as follows:
[0068]
[0069] Wherein, X is the first text data, Y is the first preset text data, and P CTC (Y|X) is the posterior probability of Y given X.
[0070] The second loss value may be a specific value, which is used to represent the error between the second text data and the first preset text data. The second text data is obtained by processing the acoustic feature data, and the first preset text data has been described above and will not be repeated here.
[0071] For example, a method for determining the second loss value is as follows:
[0072] The acoustic feature data is processed to obtain second text data; and a second loss value is determined based on the second text data and the first preset text data.
[0073] Specifically, the acoustic feature data is input into the second linear layer, the second linear layer is used to perform nonlinear mapping on the acoustic feature data, and the second linear layer outputs the second text data; based on the CTC loss of the second text data and the first preset text data, the second loss value is determined.
[0074] The speech recognition model training device can perform weighted summation of the first loss value and the second loss value to obtain a total loss value. The first fusion data is considered when optimizing the model parameters of the encoder based on the total loss value, which enables the encoder to have a certain semantic modeling capability, thereby optimizing the semantic information modeling capability of the encoder.
[0075] In the second method, the total loss value is calculated by the speech recognition model training device based on the first loss value, the second loss value and the third loss value. The contents of the first loss value and the second loss value can refer to the contents of the first loss value and the second loss value in the first method respectively, and will not be repeated here.
[0076] The third loss value may be a specific value, which is used to represent the error between the first text data and the second text data. The first text data and the second text data have been described above and will not be described again here.
[0077] For example, a method for determining the third loss value is as follows:
[0078] A third loss value is determined based on the first text data and the second text data.
[0079] Specifically, the KL divergence between the first text data and the second text data, that is, the third loss value, is calculated.
[0080] For example, the formula for calculating the third loss value is as follows:
[0081]
[0082] in represents the third loss value, P is the first text data, P i represents the probability of the first text data being a possible value, Q represents the second text data, and Q i Indicates the probability of the second text data being a possible value. KL divergence is used in training to measure the first text data and the second text data, narrowing the distance between the acoustic feature data and the first fusion data, so as to achieve better results in text decoding.
[0083] The total loss value may be obtained by weighted summing the first loss value, the second loss value, and the third loss value.
[0084] Method 3: The total loss value is calculated by the speech recognition model training device based on the first loss value, the second loss value, the third loss value and the fourth loss value. The contents of the first loss value, the second loss value and the third loss value can refer to the contents of the first loss value, the second loss value and the third loss value in method 1 respectively, and will not be repeated here.
[0085] Optionally, the fifth loss value is determined based on the first loss value, the second loss value and the third loss value, and the total loss value is determined based on the fourth loss value and the fifth loss. Specifically, the total loss value is determined as the sum of the product of the fifth loss value and the first coefficient and the product of the fourth loss value and the second coefficient.
[0086] The fourth loss value may be a specific value, which is used to represent the error between the third text data and the first preset text data. The first preset text data has been described above and will not be described again here.
[0087] A method for calculating a fourth loss value is as follows: processing predicted text data to obtain third text data; and determining a fourth loss value based on the third text data and first preset text data.
[0088] Specifically, the predicted text data is input into the third linear layer to obtain third text data; and a fourth loss value is determined based on the attention loss of the third text data and the first preset text data. The fourth loss value represents the semantic loss of the predicted text data, which is conducive to enhancing the semantic recognition ability of the speech recognition model.
[0089] For example, a calculation formula for calculating the fourth loss value is as follows:
[0090] L ATT =logP ATT (Y|X) (3)
[0091] Wherein, X is the third text data, Y is the first preset text data, P ATT (Y|X) is the posterior probability of Y given X.
[0092] Please refer to Figure 5 , Figure 5 This is a schematic diagram of the principle of obtaining the total loss value. Figure 5 The calculation of the total loss value is introduced in detail.
[0093] The following is an example of a calculation formula for determining the total loss value.
[0094]
[0095] L total is the total loss value, is the first loss value, L ctc is the second loss value, is the third loss value, L ATT is the fourth loss value. m may represent the first coefficient corresponding to the fifth loss value, which may be 0.3, (1-m) may represent the second coefficient corresponding to the fourth loss value, q may represent the third coefficient corresponding to the third loss value, k may represent the fourth coefficient corresponding to the second loss value, which may be 0.8, (1-kq) may represent the fifth coefficient corresponding to the first loss value, and the value ranges of m, k and q may be between 0 and 1.
[0096] Among them, the weighted sum of the first loss value, the second loss value and the third loss value is the fifth loss value. When the total loss value is calculated based on the fifth loss value and the fourth loss value, the first coefficient corresponding to the fifth loss value is negatively correlated with the second coefficient corresponding to the fourth loss value, and the sum of the first coefficient and the second coefficient is the first value, which can be 1. The total loss value is calculated based on the weighted sum of multiple loss values, so that the speech recognition model training device can flexibly calculate the total loss value according to different tasks, give priority to different losses, and thus balance the influence of different loss values to obtain better training results.
[0097] S304, the speech recognition model training device adjusts the model parameters of the first speech recognition model based on the total loss value to obtain a second speech recognition model.
[0098] The model parameters of the first speech recognition model include parameters of an encoder and parameters of a decoder. Accordingly, adjusting the model parameters of the first speech recognition model may be adjusting parameters of an encoder and parameters of a decoder of the first speech recognition model.
[0099] Exemplarily, based on the total loss value, the model parameters of the first speech recognition model are adjusted, and when the preset training conditions are met, the second speech recognition model is obtained. The preset training conditions may be, for example: the number of training times reaches the preset number of times, the total loss value corresponding to the sample speech data and the total loss value corresponding to the verification speech data are both in convergence, or the total loss value corresponding to the sample speech data and the total loss value corresponding to the verification speech data are both in a decreasing and convergence state, etc.
[0100] The content of the verification voice data can refer to the content of the sample voice data, except that the sample voice data is used in the training phase of the voice recognition model training device, and the verification voice data is used to determine the parameters of the voice recognition model training device. Accordingly, the calculation method of the total loss value corresponding to the verification voice data refers to the calculation method of the total loss value corresponding to the sample voice data, which is not listed here.
[0101] Exemplarily, under the preset training condition that the total loss values corresponding to the sample voice data and the total loss values corresponding to the verification voice data are both in convergence, the model parameters of the first voice recognition model can be adjusted until the total loss values corresponding to the sample voice data and the total loss values corresponding to the verification voice data are both in a state of decreasing and converging, and the model parameters of the first voice recognition model are no longer adjusted. At this time, the adjusted first voice recognition model obtained is the trained second voice recognition model. The structure of the second voice recognition model is the same as that of the first voice recognition model, or the second voice recognition model includes part of the structure of the first voice recognition model, such as an encoder and a decoder. Compared with the first voice recognition model, the second voice recognition model lacks a linear layer.
[0102] Based on the same inventive concept, the embodiment of the present application provides a speech recognition method. The method can be performed by a speech recognition device, which can be implemented by a device with a processing function, such as one or more servers, for example. Figure 1 The server involved in the speech recognition device can also be implemented by a hardware module or software module installed in a server or other electronic device. The software module is such as an application program. The specific implementation form of the speech recognition device is not specifically limited in this document. For example, the speech recognition device can be Figure 1 The speech processing system involved, Figure 2A The speech processing system shown or Figure 2B The speech recognition module involved is implemented.
[0103] It should be understood that the speech recognition device and the speech recognition model device mentioned above can be the same device or independent devices, and there is no limitation on this.
[0104] Please refer to Figure 6 , is a flow chart of a speech recognition method provided by an embodiment of the present application. The steps of the speech recognition method are as follows.
[0105] S601: The speech recognition device obtains target speech data to be recognized.
[0106] The speech recognition device may obtain the target speech data to be recognized from other devices (such as the user's terminal device), or the user may directly input the target speech data into the speech recognition device, and there is no limitation on this.
[0107] Please refer to Figure 7 , which is an example diagram of the speech-to-text process of a terminal device during the translation process provided in an embodiment of the present application. Figure 7 In the example, a speech recognition device is used as a server. Figure 7 As shown, the user long presses the message 701, and the message 701 is specifically Figure 7The duration of the voice shown in (1) is 6 seconds, and the terminal device displays Figure 7 The control list shown in (1) includes a text conversion control 702. When the user clicks the text conversion control 702, it is equivalent to performing a speech-to-text operation. The terminal device responds to the speech-to-text operation, thereby generating a speech-to-text request. The speech-to-text request carries the message 701. The speech recognition device receives the message 701 as the target speech data.
[0108] S602, the speech recognition device inputs the target speech data into the second speech recognition model to obtain target text data.
[0109] The second speech recognition model can be Figure 3 The second speech model is trained by the method mentioned above. The content of the second speech model can be found in the previous article. Figure 3 The processing of the target speech data by the second speech recognition model can refer to the processing of the sample speech data by the speech recognition model training device through the encoder of the first speech recognition model, which will not be listed here.
[0110] Continue to refer to Figure 7 , message 701 is used as the target voice data, and the server performs voice recognition on the target voice data, obtains the target text data and sends it to the terminal. The terminal device displays as follows Figure 7 The target text data 703 shown in (2) is specifically "Hello, world, I am AI".
[0111] Based on the same inventive concept, the present application embodiment provides a speech recognition model training device. Figure 8 , the present application embodiment provides a speech recognition model training device. The speech recognition model training device is, for example, Figure 2A Speech processing systems in Figure 2B The speech recognition module involved in the above may realize the speech recognition model training device mentioned above.
[0112] like Figure 8 As shown, the speech recognition model training device 800 includes a data acquisition module 801, a loss value determination module 802 and a model training module 803.
[0113] Exemplarily, the data acquisition module 801 is used to process the sample speech data through the encoder of the first speech recognition model to obtain acoustic feature data; the acoustic feature data is processed through the decoder of the first speech recognition model to obtain predicted text data; the loss value determination module 802 determines the total loss value based on the first fusion data, and the first fusion data is obtained by fusing the acoustic feature data and the predicted text data; the model training module 803 is used to adjust the model parameters of the first speech recognition model based on the total loss value to obtain the second speech recognition model.
[0114] Optionally, the first speech recognition model also includes a first linear layer and a second linear layer; a loss value determination module 802 is specifically used to: process the first fusion data to obtain first text data; process the acoustic feature data to obtain second text data; determine a first loss value based on the first text data and the first preset text data; and determine a second loss value based on the second text data and the first preset text data; wherein the first preset text data is the real text data corresponding to the sample speech data, the first loss value represents the error between the first text data and the first preset text data, and the second loss value represents the error between the second text data and the first preset text data; based on the first loss value and the second loss value, determine the total loss value.
[0115] Optionally, the loss value determination module 802 is also used to: determine a third loss value based on the first text data and the second text data, wherein the third loss value represents the error between the first text data and the second text data; and determine the total loss value based on the first loss value, the second loss value and the third loss value.
[0116] Optionally, the loss value determination module 802 is also used to: process the predicted text data to obtain third text data; determine a fourth loss value based on the third text data and the first preset text data, the fourth loss value representing the error between the third text data and the first preset text data; determine a total loss value based on the fifth loss value and the fourth loss value, the fifth loss value being determined based on the first loss value, the second loss value and the third loss value.
[0117] Optionally, the loss value determination module 802 is specifically used to determine the total loss value by summing the product of the fifth loss value and the first coefficient and the product of the fourth loss value and the second coefficient, wherein the sum of the first coefficient and the second coefficient is the first value.
[0118] Optionally, the sample speech data includes multiple frames of sample speech data; the data acquisition module 801 is specifically used to process the multiple frames of sample speech data to obtain multiple first matrices; the multiple first matrices correspond one-to-one to the multiple frames of sample speech data, and the first matrix i is used to represent the correlation between the sample speech data j corresponding to the first matrix i and the multiple frames of sample speech data, the first matrix i is any one of the multiple first matrices, and the sample speech data j is any one of the multiple frames of sample speech data; the multiple first matrices are fused to obtain a fused matrix; based on the characteristics of the multiple frames of sample speech data and the fused matrix, multiple second matrices are determined, the multiple second matrices correspond one-to-one to the characteristics of the multiple frames of sample speech data, the second matrix k is used to represent the key feature m in the fused matrix, the key feature m corresponds to the sample speech data corresponding to the second matrix k, and the second matrix k is any one of the multiple second matrices; each element in the multiple second matrices is nonlinearly transformed and mapped to obtain the acoustic feature data.
[0119] The steps performed by the data acquisition module 801, the loss value determination module 802 and the model training module 803 can be referred to in the previous text. Figure 3 The content of the discussion will not be repeated here.
[0120] Based on the same inventive concept, the present application embodiment provides a speech recognition device. Fig. 9 , the present application embodiment provides a speech recognition device. The speech recognition device 900 can be applied to a speech recognition system. The speech recognition model training device is, for example, Figure 2A Speech processing systems in Figure 2B The speech recognition module involved in the above may realize the speech recognition model training device mentioned above.
[0121] like Fig. 9 As shown, the speech recognition device 900 includes a speech data acquisition module 901 and a speech data processing module 902 .
[0122] A speech data acquisition module is used to acquire speech information to be recognized; a speech data processing module is used to input the speech information into a preset acoustic neural network model to obtain text data, wherein the second speech recognition model is trained by the speech recognition model training method provided in the embodiment of the present application.
[0123] Based on the same inventive concept, the present application embodiment provides an electronic device. Fig.10, an embodiment of the present application provides an electronic device, the electronic device 1000 includes: at least one processor 1001, and a memory 1002 that is communicatively connected to the at least one processor 1001; wherein the memory 1002 stores instructions that can be executed by the at least one processor 1001, and the at least one processor 1001 implements the following by executing the instructions stored in the memory 1002 Figure 3 The speech recognition model training method shown in Figure 6 The speech recognition method shown.
[0124] Among them, the processor 1001 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.
[0125] The memory 1002 may include a volatile memory, such as a random access memory (RAM). The memory may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0126] Based on the same inventive concept, the embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the following Figure 3 The speech recognition model training method shown in Figure 6 The speech recognition method shown.
[0127] Based on the same inventive concept, the embodiment of the present application provides a computer program product, which includes computer instructions, and when it is run on a computer, the computer executes the following Figure 3 The speech recognition model training method shown in Figure 6 The speech recognition method shown.
[0128] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0129] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0131] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0132] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A speech recognition model training method, characterized in that: The method comprises: Processing the sample speech data through an encoder of the first speech recognition model to obtain acoustic feature data; Processing the acoustic feature data through a decoder of the first speech recognition model to obtain predicted text data; determining a total loss value based on first fused data, where the first fused data is obtained by fusing the acoustic feature data and the predicted text data; Based on the total loss value, the model parameters of the first speech recognition model are adjusted to obtain a second speech recognition model.
2. The method according to claim 1, wherein The determining of the total loss value based on the first fused data includes: Processing the first fusion data to obtain first text data; processing the acoustic feature data to obtain second text data; Determine a first loss value based on the first text data and the first preset text data; and determine a second loss value based on the second text data and the first preset text data; wherein the first preset text data is the real text data corresponding to the sample speech data, the first loss value represents the error between the first text data and the first preset text data, and the second loss value represents the error between the second text data and the first preset text data; The total loss value is determined based on the first loss value and the second loss value.
3. The method according to claim 2, wherein Determining the total loss value based on the first loss value and the second loss value includes: determining a third loss value based on the first text data and the second text data, wherein the third loss value represents an error between the first text data and the second text data; The total loss value is determined based on the first loss value, the second loss value, and the third loss value.
4. The method according to claim 3, wherein The determining the total loss value based on the first loss value, the second loss value, and the third loss value includes: Processing the predicted text data to obtain third text data; determining a fourth loss value based on the third text data and the first preset text data, the fourth loss value representing an error between the third text data and the first preset text data; The total loss value is determined based on a fifth loss value and the fourth loss value, the fifth loss value being determined based on the first loss value, the second loss value, and the third loss value.
5. The method according to claim 4, wherein Determining the total loss value based on the fifth loss value and the fourth loss value includes: The total loss value is determined as the sum of the product of the fifth loss value and the first coefficient and the product of the fourth loss value and the second coefficient, wherein the sum of the first coefficient and the second coefficient is a first value.
6. The method according to any one of claims 1 to 5, wherein: The sample voice data includes multiple frames of sample voice data; The processing of the sample speech data to obtain acoustic feature data includes: Processing the multiple frames of sample speech data to obtain multiple first matrices; the multiple first matrices correspond one-to-one to the multiple frames of sample speech data, a first matrix i is used to represent the correlation between the sample speech data j corresponding to the first matrix i and the multiple frames of sample speech data, the first matrix i is any one of the multiple first matrices, and the sample speech data j is any one of the multiple frames of sample speech data; fusing the multiple first matrices to obtain a fused matrix; Determining, based on the features of the multiple frames of sample speech data and the fused matrix, a plurality of second matrices, wherein the plurality of second matrices correspond one-to-one to the features of the multiple frames of sample speech data, a second matrix k is used to represent a key feature m in the fused matrix, the key feature m corresponds to the sample speech data corresponding to the second matrix k, and the second matrix k is any one of the plurality of second matrices; Nonlinear transformation and mapping processing are performed on each element in the plurality of second matrices to obtain the acoustic feature data.
7. A speech recognition method, characterized in that: include: Obtain target speech data to be recognized; The target speech data is input into a second speech recognition model to obtain target text data, wherein the second speech recognition model is trained by the method according to any one of claims 1 to 6.
8. A speech recognition model training device, characterized in that: The device comprises: A data acquisition module, configured to process the sample speech data through an encoder of the first speech recognition model to obtain acoustic feature data; and process the acoustic feature data through a decoder of the first speech recognition model to obtain predicted text data; a loss value determining module, configured to determine a total loss value based on first fused data, where the first fused data is obtained by fusing the acoustic feature data and the predicted text data; A model training module is used to adjust the model parameters of the first speech recognition model based on the total loss value to obtain a second speech recognition model.
9. An electronic device, characterized in that: include: at least one processor, and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the method according to any one of claims 1 to 7 by executing the instructions stored in the memory.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the computer is caused to perform the method according to any one of claims 1 to 7.
