Language recognition model training method and device, electronic equipment and storage medium
By calculating the total loss of the language recognition model and updating the parameters, the problem of inaccurate recognition of differences between dialects and Mandarin in speech language recognition is solved, and more efficient language recognition is achieved.
Patent Information
- Application Number
- CN202410829654.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-17
AI Technical Summary
It is difficult for the existing technology to accurately identify the language differences between different dialects and Mandarin, resulting in inaccurate speech language recognition.
By obtaining multiple language speech samples of the same speaker, combining the language recognition model and the speaker recognition model, the language recognition loss, speaker recognition loss and ternary loss are calculated, and the parameters are updated according to the total loss until the total loss is less than the threshold, so as to Train a more accurate language recognition model.
It improves the accuracy and training efficiency of the language recognition model and can more accurately identify different speech languages.
Smart Images

Figure CN118658455A
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio processing, and more specifically, to a training method, device, electronic device and storage medium for a language recognition model. Background Art
[0002] With the rapid development of science and technology, artificial intelligence is being used more and more widely in people's daily lives. In order to be able to recognize the text content of the speaker's speech in real time according to the language corresponding to the speaker's speech, it is a crucial step to recognize the language corresponding to the speaker's speech. However, since there are many dialects in Chinese, each dialect has a certain connection and similarity with Mandarin, and the speaker is influenced by the growth environment and mother tongue, the second language will have a high degree of similarity and overlap with the first language, and thus it is impossible to accurately identify the language of the speech to be recognized. Therefore, how to accurately identify the language of the speech to be recognized has become an urgent problem to be solved. Summary of the invention
[0003] In view of the above problems, the embodiments of the present application propose a language recognition model training method, device, electronic device and storage medium to improve the above problems.
[0004] In a first aspect, an embodiment of the present application provides a method for training a language recognition model, the method comprising: obtaining a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker; inputting the speech sample set into a language recognition model, obtaining a first recognition result of the language recognition model outputting the speech sample set for language recognition, and obtaining a second recognition result of the language recognition model outputting the speech sample set for speaker recognition; determining a language recognition loss, a speaker recognition loss, and a trigram loss based on the first recognition result and the second recognition result; determining a total loss of the language recognition model based on the language recognition loss, the speaker recognition loss, and the trigram loss; if the total loss is greater than or equal to a loss threshold, updating parameters of the language recognition model based on the total loss until the total loss is less than the loss threshold, thereby completing the training of the language recognition model.
[0005] In a second aspect, an embodiment of the present application provides a training device for a language recognition model, comprising: an acquisition module, used to acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker; a recognition module, used to input the speech sample set into the language recognition model, obtain a first recognition result of the language recognition model outputting the speech sample set for language recognition, and obtain a second recognition result of the language recognition model outputting the speech sample set for speaker recognition; a first loss determination module, used to determine the language recognition loss, speaker recognition loss and trigram loss according to the first recognition result and the second recognition result; a second loss determination module, used to determine the total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the trigram loss; and a training module, used to update the parameters of the language recognition model according to the total loss if the total loss is greater than or equal to a loss threshold, until the training of the language recognition model is completed when the total loss is less than the loss threshold.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor; a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the training method of the language recognition model as described above is implemented.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having computer-readable instructions stored thereon. When the computer-readable instructions are executed by a processor, the training method of the language recognition model as described above is implemented.
[0008] In the scheme of the present application, the language recognition and speaker recognition are respectively performed on speech samples including at least two voices of the same speaker through the language recognition model, so as to obtain a first recognition result and a second recognition result, and then, the language recognition loss, speaker recognition loss and ternary loss are respectively determined according to the first recognition result and the second recognition result, so that the total loss of the language recognition model can be determined according to the language recognition loss, speaker recognition loss and ternary loss, and finally, when the total loss is greater than or equal to the loss threshold, the parameters of the language recognition model can be updated according to the total loss, and the step of recognizing the speech sample can be repeated according to the language recognition model after the parameter update, until the total loss is less than the loss threshold to complete the training of the language recognition model. The scheme of the present application determines the total loss by combining the language recognition loss, speaker recognition loss and ternary loss, so that the parameters of the language recognition model can be updated and trained according to the total loss, so that the trained language recognition model is more accurate.
[0009] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0011] Figure 1 It is a flowchart of a method for training a language recognition model according to an embodiment of the present application.
[0012] Figure 2 It is a flowchart of a method for training a language recognition model according to another embodiment of the present application.
[0013] Figure 3 It is a schematic diagram of the specific step flow of step 260 according to an embodiment of the present application.
[0014] Figure 4 It is a flowchart of specific steps after step 270 according to an embodiment of the present application.
[0015] Figure 5 It is a flowchart of a method for training a language recognition model according to yet another embodiment of the present application.
[0016] Figure 6 It is a flowchart of a method for training a language recognition model according to another embodiment of the present application.
[0017] Figure 7 It is a flowchart of a method for training a language recognition model according to another embodiment of the present application.
[0018] Figure 8 It is a block diagram of a training device for a language recognition model according to an embodiment of the present application.
[0019] Fig. 9 It is a hardware structure diagram of an electronic device according to an embodiment of the present application.
[0020] The above-mentioned drawings have shown clear embodiments of the present invention, which will be described in more detail hereinafter. These drawings and textual descriptions are not intended to limit the scope of the present invention in any way, but to illustrate the concept of the present invention to computer technicians in this field through specific embodiments. DETAILED DESCRIPTION
[0021] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the present application.
[0024] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices. The flowcharts shown in the accompanying drawings are merely exemplary and do not necessarily include all the contents and operations / steps, nor do they necessarily have to be executed in the order described. For example, some operations / steps may be further decomposed, while some operations / steps may be combined or partially combined, so the actual execution order may change according to the actual situation.
[0025] See also Figure 1 , Figure 1 The training method of the language recognition model provided by an embodiment of the present application is shown. In a specific embodiment, the training method of the language recognition model can be applied to Figure 8 The training device 600 for the language recognition model and the electronic device 700 equipped with the training device 600 for the language recognition model are shown. Fig. 9 ). The specific process of this embodiment will be described below. Of course, it can be understood that the method can be executed by a cloud server with computing processing capabilities. Figure 1 The process shown is described in detail, and the training method of the language recognition model may specifically include the following steps:
[0026] Step 110: Acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker.
[0027] As a method, the speech sample set may include multiple speech samples, and the multiple speech samples correspond to at least two speech types, for example, language L 1 , Language L 2 , Language L n And so on, a total of N, and the multiple speech samples may correspond to multiple speakers, for example, speaker S 1 , speaker S 2 , speaker S m And so on, a total of M. Optionally, in the speech sample set, the speech samples corresponding to the same speaker correspond to at least two languages, so that the language recognition model can be trained according to the speech samples of different languages corresponding to the same speaker, reducing the impact of different speakers on the training of the language recognition model.
[0028] Step 120: input the speech sample set into a language recognition model, obtain a first recognition result output by the language recognition model for language recognition of the speech sample set, and obtain a second recognition result output by the language recognition model for speaker recognition of the speech sample set.
[0029] As a method, the language recognition model may include a shared neural network, a language recognition neural network, and a speaker recognition neural network, wherein the shared neural network may be a conventional multi-layer stack of linear layers, convolutional layers, or recurrent layers, as a parameter sharing part of the subsequent language recognition neural network and speaker recognition neural network; the language recognition network and the speaker recognition neural network may both use the rough features output by the last hidden layer of the shared network as input, and the language recognition neural network and the speaker recognition neural network may also be constructed by a conventional multi-layer stack of linear layers, convolutional layers, or recurrent layers, but the corresponding neural network parameters in the language recognition neural network and the speaker recognition neural network are different, that is, the language recognition network and the speaker recognition neural network as sub-networks are independent of each other, and there is no parameter sharing, but the corresponding input features are the same, which are all rough features output by the shared network. Optionally, the output dimension of the last hidden layer of the language recognition network may be the same as the output dimension of the last hidden layer of the speaker recognition network.
[0030] Optionally, the first recognition result may include the language corresponding to each speech sample in the speech sample set and the language features corresponding to each speech sample, and the second recognition result may include the speaker identity corresponding to each speech sample in the speech sample set and the speaker features corresponding to each speech sample, and the speaker features may be the audio features of the speaker for the same character or the same word.
[0031] Optionally, the speech sample set may include speech samples of different languages of the same speaker. Therefore, a corresponding speaker identifier may be set for each speech sample in advance. Correspondingly, the second recognition result may include speaker identifiers corresponding to each of the multiple speech samples.
[0032] Step 130: determine language recognition loss, speaker recognition loss and ternary loss according to the first recognition result and the second recognition result.
[0033] As a method, when the language recognition model recognizes the speech sample set, a loss will be generated. The loss can be compared with the loss threshold to determine whether the training of the language recognition model is completed. In order to make the training of the language recognition model more accurate and rapid, the language recognition loss and ternary loss corresponding to the language recognition neural network in the language recognition model, as well as the speaker recognition loss and ternary loss corresponding to the speaker recognition network can be determined respectively according to the first recognition result and the second recognition result. Among them, the ternary loss is used to learn the similarities and differences between embedded data points. In the scheme of the present application, the ternary loss is used to indicate the difference between the language and the speaker corresponding to each speech sample in the speech sample set. Optionally, the language recognition loss can be determined by a language loss function, and the speaker recognition loss can be confirmed by a speaker loss function. Then, the ternary loss is determined based on the language recognition loss and the speaker recognition loss, as well as based on the language recognition features in the first recognition result and the speaker recognition features in the second recognition result.
[0034] Step 140: determining a total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the triple loss.
[0035] As a method, in order to accurately train the language recognition model, the total loss can be determined based on the language recognition loss, speaker recognition loss and ternary loss, so that it can be determined whether the training of the language recognition model is completed based on the total loss. Optionally, the total loss of the language recognition model can be determined by taking a weighted sum of the language recognition loss, speaker recognition loss and ternary loss. Optionally, the weights corresponding to the language recognition loss, speaker recognition loss and ternary loss can be pre-set, so that a weighted sum can be performed.
[0036] Step 150: If the total loss is greater than or equal to the loss threshold, update the parameters of the language recognition model according to the total loss until the total loss is less than the loss threshold, thereby completing the training of the language recognition model.
[0037] As a method, when it is determined that the total loss is less than the loss threshold, it can be determined that the loss function of the language recognition model has converged, so that it can be determined that the training of the language recognition model has reached the best iteration state, and then, the iterative training of the language recognition model can be ended to complete the training of the language recognition model. On the contrary, when it is determined that the total loss is greater than or equal to the loss threshold, it can be determined that the loss function of the language loss model has not converged, so it is necessary to continue to iteratively train the language recognition model. In order to make the language recognition model more accurate in recognizing the language of speech, the parameters of the language recognition model can be updated according to the value of the total loss, so that in the next iterative training, the language recognition model with updated parameters can be iteratively trained.
[0038] Optionally, when it is determined that the total loss is greater than or equal to the loss threshold, according to the back propagation of the neural network, after each iterative training of the language recognition model, the gradient based on the total loss can be determined for the parameters of each hidden layer of the language recognition model through the total loss, and then the parameters of the language recognition model can be updated according to the determined gradient.
[0039] In an embodiment of the present application, a speech sample including at least two voices of the same speaker is subjected to language recognition and speaker recognition respectively through a language recognition model, thereby obtaining a first recognition result and a second recognition result, and then, the language recognition loss, speaker recognition loss and ternary loss are determined respectively according to the first recognition result and the second recognition result, so that the total loss of the language recognition model can be determined according to the language recognition loss, speaker recognition loss and ternary loss, and finally, when the total loss is greater than or equal to the loss threshold, the parameters of the language recognition model can be updated according to the total loss, and the step of recognizing the speech sample can be repeated according to the language recognition model after the parameter update, until the total loss is less than the loss threshold to complete the training of the language recognition model. The scheme of the present application determines the total loss by combining the language recognition loss, speaker recognition loss and ternary loss, so that the parameters of the language recognition model can be updated and trained according to the total loss, so that the trained language recognition model is more accurate.
[0040] See also Figure 2 , Figure 2 The following is a training method for a language recognition model provided by an embodiment of the present application. Figure 2 The process shown is described in detail, and the training method of the language recognition model may specifically include the following steps:
[0041] Step 210: Acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker.
[0042] Step 220: input the speech sample set into a language recognition model, obtain a first recognition result output by the language recognition model for language recognition of the speech sample set, and obtain a second recognition result output by the language recognition model for speaker recognition of the speech sample set.
[0043] Step 230, obtaining a first sample label and a second sample label corresponding to each of the speech samples in the speech sample set, wherein the first sample label indicates the target language to which the corresponding speech sample belongs, and the second sample label indicates the target speaker to which the corresponding speech sample belongs.
[0044] As a method, when setting a speech sample set, the language label of the language corresponding to each speech sample in the speech sample set and the speaker label corresponding to each speech sample can be set, and after setting the label, the language label and speaker label of each speech sample are associated, so as to obtain a mapping relationship between each speech sample in the speech sample set and the corresponding first sample label and second sample label.
[0045] Optionally, a first sample label set and a second sample label set may be pre-set, so that after the language labels and speaker labels corresponding to each speech sample are determined, the language labels corresponding to all speech samples are stored in the first sample label set, and the speaker labels corresponding to the speech samples are stored in the second sample label set, so as to facilitate obtaining the first sample labels and the second sample labels corresponding to each speech sample in the speech sample set.
[0046] Step 240: determine the language recognition loss according to the first sample label and the first recognition result, and determine the speaker recognition loss according to the second sample label and the second recognition result.
[0047] As a method, the language recognition loss can be determined based on the first sample label and the first recognition result through the cross entropy loss function. Similarly, the speaker recognition loss can be determined based on the second sample label and the second recognition result through the cross entropy loss function. Optionally, cross entropy is a concept in information entropy theory. It was originally used to estimate the average coding length. In deep learning, it can be regarded as the distance between two probability distributions. That is to say, the smaller the value corresponding to the cross entropy loss function, the closer the two probability distributions are. In this embodiment, the smaller the value corresponding to the cross entropy loss function, the closer the first recognition result is to the first sample label, the closer the second recognition result is to the first sample label, and the more accurate the recognition accuracy of the corresponding language recognition model is.
[0048] Optionally, the formula LOSS_L i =∑ i Q L (x i )logP L (x i ) to determine the language recognition loss, where Q L is the input sample x i The corresponding first sample label is encoded in 0-1, with a dimension of N, 1 corresponding to the ordinal number of the target language, P L The result of the language recognition output layer of the language recognition model is the logarithmic softmax posterior probability of the cross entropy loss function.
[0049] Optionally, the formula OLSS_S i =∑ i Q S (x i )logP S (x i ) to determine the speaker recognition loss, where Q S is the input sample x i The corresponding second sample label is encoded in 0-1, with a dimension of N, where 1 corresponds to the serial number of the target speaker, P S The result of the speaker recognition output layer of the language recognition model is the logarithmic softmax posterior probability of the cross entropy loss function.
[0050] As another way, the language recognition loss may be determined by calculating the distance between the first sample label and the first recognition result, and the speaker recognition loss may be determined by calculating the distance between the second sample label and the second recognition result.
[0051] Step 250: determining a first recognition feature for the language recognition model to recognize the speech sample set according to the first recognition result, and determining a second recognition feature for the language recognition model to recognize the speech sample set according to the second recognition result.
[0052] As a method, the first recognition result may include the language recognition result corresponding to each voice sample in the voice sample set and the first recognition feature corresponding to each voice sample, and the second recognition result may include the speaker recognition result corresponding to each voice sample in the voice sample set and the second recognition feature corresponding to each voice sample, so that the first recognition feature can be determined according to the first recognition result and the second recognition feature can be determined according to the second recognition result.
[0053] Step 260: Determine the ternary loss based on the first identification feature and the second identification feature.
[0054] As a method, the ternary loss input is a triplet, including an anchor example, a positive example, and a negative example. By optimizing the distance between the anchor example and the positive example to be smaller than the distance between the anchor example and the negative example, the similarity calculation between the samples is realized. In this embodiment, in order to increase the difference between different languages of the same speaker, the total loss can be determined according to the ternary loss, and the parameters of the language recognition model are updated based on the total loss, so that the language recognition model can recognize the language more accurately. Optionally, the feature vector used as the anchor example can be determined first, and then the ternary loss can be determined based on the first recognition feature, the second recognition feature and the feature vector according to the ternary loss function.
[0055] In some embodiments, the speech sample set includes a first speech sample and a second speech sample, the first speech sample and the second speech sample belong to different languages, the first recognition feature includes a first language recognition feature and a second language recognition feature, and the second recognition feature includes a first speaker recognition feature and a second speaker recognition feature, such as Figure 3 As shown, the step 260 includes:
[0056] Step 261, obtaining the initial language center vector corresponding to the speech sample set.
[0057] As one method, the initial language center vector corresponding to the speech sample set can be determined by determining the intersection of the first speech sample and the second speech sample, wherein the first speech sample and the second speech sample can be speech samples of the same speaker for different languages, and the intersection of the first speech sample and the second speech sample refers to the speech features corresponding to the words, phrases or sentences with the same pronunciation in different languages in the first speech sample and the second speech sample, so as to determine the speech features as the initial language center vector corresponding to the speech sample set.
[0058] Step 262: determining a first parameter according to the first language recognition feature, the first speaker recognition feature and the initial language center vector.
[0059] As a method, the feature difference between the first language recognition feature and the first speaker recognition feature can be determined first, and then the Euclidean distance between the feature difference and the initial language center vector can be determined based on the feature difference and the initial language center vector, and the Euclidean distance can be determined as the first parameter. Optionally, the formula A=‖L i ―S i ―L ni ‖ to determine the first parameter, where L i is the first language identification feature, S i is the first speaker identification feature, L niis the initial language center vector, A is the first parameter, and the calculation of this formula is to determine L i ―S i The characteristic difference between ni The Euclidean distance.
[0060] Step 263: determining a second parameter according to the second language recognition feature, the second speaker recognition feature and the initial language center vector.
[0061] As a method, the feature difference between the second language recognition feature and the second speaker recognition feature can be determined first, and then the Euclidean distance between the feature difference and the initial language center vector can be determined based on the feature difference and the initial language center vector, and the Euclidean distance can be determined as the second parameter. Optionally, the formula B = ‖L j ―S j ―L ni ‖ to determine the second parameter, where L j is the second language recognition feature, S j Identify the features of the second speaker, L ni is the initial language center vector, B is the first parameter, and the calculation of this formula is to determine L j ―S j The characteristic difference between ni The Euclidean distance.
[0062] Step 264: determine the ternary loss according to the first parameter and the second parameter.
[0063] As a method, the ternary loss can be determined by determining the difference between the first parameter and the second parameter, so as to determine the sample difference between the first speech sample and the second speech sample, and the sample difference can be used as the ternary loss, so that the language recognition model can learn the sample difference between the first speech sample and the second speech sample during the training process, so that the training of the language recognition model is more accurate.
[0064] In some embodiments, the step 264 includes: determining a minimum difference between the first parameter and the second parameter, and determining the minimum difference as the ternary loss.
[0065] As a way, in order to make different languages of the same speaker have obvious differences, the difference between the first parameter and the second parameter can be minimized, so that the Euclidean distance between the feature difference between the first language recognition feature and the first speaker recognition feature and the initial language center vector is as small as possible, and at the same time, the Euclidean distance between the feature difference between the second language recognition feature and the second speaker recognition feature and the initial language center vector is as large as possible, so that the minimized difference between the first parameter and the second parameter is determined as the ternary loss, so that the total loss determined according to the ternary loss is more accurate, and then when the parameters of the language recognition model are updated according to the total loss, the difference between the first speech sample and the second speech sample can be learned, so that the training of the language recognition model is more accurate. Optionally, the formula LOSS_T ij =min{‖L i ―S i ―L ni ‖―‖L j ―S j ―L ni ‖} to determine the ternary loss, where ‖L i ―S i ―L ni ‖ indicates the feature difference L between the first language recognition feature and the first speaker recognition feature i ―S i and the initial language center vector L ni The Euclidean distance between .
[0066] Please continue reading Figure 2 , step 270, determining the total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the triple loss.
[0067] In some embodiments, after step 270, the method further includes:
[0068] Step 310: If the total loss is greater than or equal to the loss threshold, determine the feature quantity of the first language recognition feature or the second language recognition feature, and determine the language feature corresponding to the first speech sample or the second speech sample.
[0069] As a method, when it is determined that the total loss is greater than or equal to the loss threshold, it can be determined that the language recognition model has not completed training. Therefore, it is necessary to update the parameters of the language recognition neural network according to the total loss. In order to improve the accuracy of each iteration training of the language recognition model, the language center vector of the speech sample set can be updated after each iteration to make the ternary loss of the next iteration more accurate. Optionally, the number of features of the first language recognition feature corresponding to the first speech sample or the number of features of the second language recognition feature corresponding to the second speech sample can be determined first, and the language feature corresponding to the first speech sample or the second speech sample can be determined, wherein the language feature can also be the language feature of the language corresponding to the first speech sample in the speech sample set.
[0070] Step 320: determining a target language center vector according to the language features and the feature quantity.
[0071] As a method, after determining the language features and the number of features, the ratio between the language features and the number of features can be determined, and the ratio can be determined as the target language center vector. To determine the target language center vector, where L n is the target language center vector, L ni,nj is the language feature corresponding to the first speech sample or the second speech sample, or may be the language feature of the language corresponding to the first speech sample in the speech sample set, NUM n It may be the feature quantity of the first language recognition feature corresponding to the first voice sample or the feature quantity of the second language recognition feature corresponding to the second voice sample, or it may be the total feature quantity of the corresponding language feature in the voice sample set.
[0072] Step 330: Update the initial language center vector corresponding to the speech sample set to the target language center vector.
[0073] As a method, after determining the target language center vector, the initial language center vector is replaced with the target language center vector, so that in the next iterative training of the language recognition model, the ternary loss is determined according to the updated target language center vector, and then the total loss is determined according to the ternary loss, so that it can be determined whether the training of the language recognition model is completed based on the total loss.
[0074] Please continue reading Figure 2 , step 280, if the total loss is greater than or equal to the loss threshold, the parameters of the language recognition model are updated according to the total loss until the total loss is less than the loss threshold, and the training of the language recognition model is completed.
[0075] Among them, the specific step descriptions of steps 210-220 and steps 270-280 can refer to steps 110-120 and steps 140-150, which will not be repeated here.
[0076] In this embodiment, the language recognition loss is determined according to the first sample label and the first recognition result, and the speaker recognition loss is determined according to the second sample label and the second recognition result. Then, the ternary loss is determined according to the first recognition feature in the first recognition result, the second recognition feature in the second recognition result, and the initial language center vector corresponding to the speech sample set. The ternary loss is minimized so that different languages of the same speaker in the speech sample set have obvious differences. In this way, the total loss of the language recognition model can be determined according to the language recognition loss, the speaker recognition loss and the ternary loss, thereby improving the accuracy of the total loss and further improving the training accuracy of the language recognition model.
[0077] See also Figure 5 , Figure 5 The following is a training method for a language recognition model provided by an embodiment of the present application. Figure 5 The process shown is described in detail, the language recognition loss includes the first language recognition loss and the second language recognition loss, the speaker recognition loss includes the first speaker recognition loss and the second speaker recognition loss, and the training method of the language recognition model may specifically include the following steps:
[0078] Step 410: Acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker.
[0079] Step 420: input the speech sample set into a language recognition model, obtain a first recognition result output by the language recognition model for language recognition of the speech sample set, and obtain a second recognition result output by the language recognition model for speaker recognition of the speech sample set.
[0080] Step 430: determine language recognition loss, speaker recognition loss and ternary loss according to the first recognition result and the second recognition result.
[0081] Step 440: determining a first loss sum of the first language recognition loss and the second language recognition loss and determining a second loss sum of the first speaker recognition loss and the second speaker recognition loss.
[0082] As a method, in order to determine the total loss of the language recognition model, the language loss sum and the speaker recognition loss sum corresponding to the first speech sample and the second speech sample may be determined, and then the total loss may be obtained by weighted calculation based on the language recognition loss sum, the speaker recognition loss sum and the ternary loss. Optionally, the first loss sum may be obtained by adding the first language recognition loss and the second language recognition loss, and the second loss sum may be obtained by adding the first speaker recognition loss and the second speaker recognition loss.
[0083] Step 450, obtaining the first loss and the corresponding first weight, the second loss and the corresponding second weight, and the third weight corresponding to the ternary loss.
[0084] As a method, the first weight, the second weight and the third weight can be pre-set, and the language loss flag can be set for the first weight, the speaker loss label can be set for the second weight, and the ternary loss flag can be set for the third weight, so that the first weight, the second weight and the third weight can be obtained according to the loss labels corresponding to each weight. Optionally, the first weight, the second weight and the third weight can be fixed values, or values that change with the iterative training of the language recognition model, and the corresponding weight value after each iteration can be determined according to the total loss.
[0085] Step 460, performing weighted calculation based on the first weight, the first loss sum, the second weight, the second loss sum, the third weight and the ternary loss to determine the total loss.
[0086] As a method, a first product of the first weight and the first loss, a second product of the second weight and the second loss, and a third product of the ternary loss and the third weight may be determined first, and then the sum of the first product, the second product, and the third product may be determined to be the total loss. Optionally, the total loss may be determined by the formula LOSS = λ(LOSS_L i +LOSS_L i )+γ(LOSS_S i +LOSS_S j )+δLOSS_T ij To determine the total loss, where LOSS is the total loss, λ is the first weight, γ is the second weight, δ is the third weight, LOSS_L i is the first recognition loss, LOSS_L j Identify loss for the second language, LOSS_S i is the first speaker identification loss, LOSS_S j is the second speaker identification loss, LOSS_T ij It is a three-yuan loss.
[0087] Step 470: If the total loss is greater than or equal to the loss threshold, update the parameters of the language recognition model according to the total loss until the total loss is less than the loss threshold, thereby completing the training of the language recognition model.
[0088] The specific step descriptions of step 410 to step 430 and step 470 can refer to step 110 to step 130 and step 150, which will not be repeated here.
[0089] In this embodiment, the first loss sum is first determined according to the first language recognition loss and the second language recognition loss, and the second loss sum is determined according to the first speaker recognition loss and the second speaker recognition loss. Then, a weighted calculation can be performed based on the obtained first weight, first loss sum, second weight, second loss sum, third weight and ternary loss to obtain the total loss, so that the total loss is more accurate.
[0090] See also Figure 6 , Figure 6 The following is a training method for a language recognition model provided by an embodiment of the present application. Figure 6 The process shown is described in detail, the language recognition model includes a language recognition network and a speaker recognition network, and the training method of the language recognition model can specifically include the following steps:
[0091] Step 510: Acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker.
[0092] Step 520: input the speech sample set into a language recognition model, obtain a first recognition result output by the language recognition model for language recognition of the speech sample set, and obtain a second recognition result output by the language recognition model for speaker recognition of the speech sample set.
[0093] Step 530: determine language recognition loss, speaker recognition loss and ternary loss according to the first recognition result and the second recognition result.
[0094] Step 540: determine the total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the triple loss.
[0095] Step 550: If the total loss is greater than or equal to the loss threshold, update the parameters of the language recognition model according to the total loss until the total loss is less than the loss threshold, thereby completing the training of the language recognition model.
[0096] The specific step descriptions of step 510 to step 550 can refer to step 110 to step 150, which will not be repeated here.
[0097] Step 560: Delete the speaker recognition network in the language recognition model to obtain a target language recognition model.
[0098] As a way to avoid the situation where the language recognition model performs speaker recognition on the speech to be recognized, resulting in inaccurate language recognition, after the language recognition model is trained, the speaker recognition network in the language recognition model is deleted and only the language recognition network is retained, thereby obtaining the target language recognition model including the language recognition network.
[0099] Step 570, obtaining the speech to be recognized, and inputting the speech to be recognized into the target language recognition model, so that the target language recognition model performs language recognition to obtain a language recognition result, wherein the language recognition result indicates the recognition scores corresponding to the speech to be recognized in multiple languages.
[0100] As a method, when obtaining the target language recognition model, the acquired speech to be recognized can be used as the input of the target language recognition model, so as to perform language recognition on the speech to be recognized through the target language recognition model, and obtain the recognition scores corresponding to the speech to be recognized in multiple languages, wherein the recognition score indicates the similarity between the language corresponding to the speech to be recognized and the multiple languages. Optionally, when deleting the speaker recognition network, the corresponding language loss part is only retained for calculating the logarithmic softmax posterior probability of the test sample, so as to determine the recognition scores corresponding to the speech to be recognized in multiple languages according to the posterior probability. Optionally, the recognition score can be obtained by the formula socre=logP S (x test ) to determine, where P S (x test ) is the posterior probability corresponding to the speech sample set in the training stage of the language recognition model, and score is the recognition score.
[0101] Step 580: Determine the target language to which the speech to be recognized belongs from the multiple languages according to the recognition score.
[0102] As a method, the language with the highest recognition score is determined as the target language of the speech to be recognized according to the recognition scores corresponding to the recognized speech in multiple languages. By filtering the speaker information, pure language information is obtained, and the target language of the speech to be recognized is determined based on the pure language information, thereby improving the accuracy of the target language and the recognition accuracy of the language recognition model.
[0103] In this embodiment, before the trained language recognition model is applied offline, the speaker recognition network in the language recognition network is first deleted to obtain a target language recognition model, and the target language recognition model is used to perform language recognition on the speech to be recognized, and the recognition results of the recognition scores corresponding to the speech to be recognized in multiple languages are obtained, so that the target language of the speech to be recognized can be determined in multiple languages according to the recognition scores. By performing language recognition on the speech to be recognized according to the language recognition model without the speaker recognition network, the ternary loss of the speaker information is removed, and the speaker component in the language modeling can be effectively eliminated, which enhances the distinction between different languages of the same person and improves the accuracy of language recognition.
[0104] Figure 7 A training method for a language recognition model according to an embodiment of the present application is shown as follows: Figure 7 As shown, the first training sample i and the second training sample j are input into the neural network, and the shared neural network in the neural network performs initial recognition according to the input first training sample i and the second training sample j, and obtains the initial features output by the last hidden layer of the shared neural network, and the initial features are respectively input into the language recognition neural network and the speaker recognition network, and respectively obtain the first recognition result output by the language recognition network and the second recognition result output by the speaker recognition network, and then determine the language recognition loss, the speaker recognition loss and the ternary recognition loss according to the first recognition result and the second recognition result, and then determine the total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the ternary recognition loss, so that it can be determined whether the training of the language recognition model is completed according to whether the total loss is less than the loss threshold, and when the total loss is less than the loss threshold, it is determined that the training of the language recognition model is completed; when the total loss is greater than or equal to the loss threshold, the parameters of the language recognition model are updated according to the total loss, and the step of recognizing the training sample is repeated according to the language recognition model after the parameter update, until the total loss is less than the loss threshold to complete the training of the language recognition model.
[0105] Figure 8 is a block diagram of a training device for a language recognition model according to an embodiment of the present application, such as Figure 8 As shown, the training device 600 for the language recognition model includes: an acquisition module 610 , a recognition module 620 , a first loss determination module 630 , a second loss determination module 640 and a training module 650 .
[0106] The acquisition module 610 is used to acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker; the recognition module 610 is used to input the speech sample set into a language recognition model, obtain a first recognition result output by the language recognition model for language recognition of the speech sample set, and obtain a second recognition result output by the language recognition model for speaker recognition of the speech sample set; the first loss determination module 630 is used to determine the language recognition loss, speaker recognition loss and trigram loss according to the first recognition result and the second recognition result; the second loss determination module 640 is used to determine the total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the trigram loss; the training module 650 is used to update the parameters of the language recognition model according to the total loss if the total loss is greater than or equal to the loss threshold, until the training of the language recognition model is completed when the total loss is less than the loss threshold.
[0107] In some embodiments, the first loss determination module 630 includes: a label acquisition submodule, used to acquire the first sample label and the second sample label corresponding to each speech sample in the speech sample set, wherein the first sample label indicates the target language to which the corresponding speech sample belongs, and the second sample label indicates the target speaker to which the corresponding speech sample belongs; a loss determination submodule, used to determine the language recognition loss according to the first sample label and the first recognition result, and to determine the speaker recognition loss according to the second sample label and the second recognition result; a recognition feature determination submodule, used to determine the first recognition feature of the language recognition model for identifying the speech sample set according to the first recognition result, and to determine the second recognition feature of the language recognition model for identifying the speech sample set according to the second recognition result; a ternary loss determination submodule, used to determine the ternary loss according to the first recognition feature and the second recognition feature.
[0108] In some embodiments, the speech sample set includes a first speech sample and a second speech sample, the first speech sample and the second speech sample belong to different languages, the first recognition feature includes a first language recognition feature and a second language recognition feature, the second recognition feature includes a first speaker recognition feature and a second speaker recognition feature, and the ternary loss determination submodule includes: an initial language center vector acquisition unit, used to acquire the initial language center vector corresponding to the speech sample set; a first parameter determination unit, used to determine a first parameter based on the first language recognition feature, the first speaker recognition feature and the initial language center vector; a second parameter determination unit, used to determine a second parameter based on the second language recognition feature, the second speaker recognition feature and the initial language center vector; and a ternary loss determination unit, used to determine the ternary loss based on the first parameter and the second parameter.
[0109] In some embodiments, the ternary loss determination unit includes: a ternary loss determination subunit, configured to determine a minimum difference between the first parameter and the second parameter, and determine the minimum difference as the ternary loss.
[0110] In some embodiments, the ternary loss determination submodule also includes: a determination unit, used to determine the feature quantity of the first language recognition feature or the second language recognition feature, and determine the language feature corresponding to the first speech sample or the second speech sample if the total loss is greater than or equal to the loss threshold; a target language center vector determination unit, used to determine the target language center vector based on the language feature and the feature quantity; an updating unit, used to update the initial language center vector corresponding to the speech sample set to the target language center vector.
[0111] In some embodiments, the language recognition loss includes a first language recognition loss and a second language recognition loss, the speaker recognition loss includes a first speaker recognition loss and a second speaker recognition loss, and the second loss determination module 640 includes: a loss sum determination submodule, used to determine a first loss sum of the first language recognition loss and the second language recognition loss and to determine a second loss sum of the first speaker recognition loss and the second speaker recognition loss; a weight acquisition submodule, used to acquire a first weight corresponding to the first loss sum, a second weight corresponding to the second loss sum, and a third weight corresponding to the ternary loss; and a total loss determination submodule, used to perform weighted calculation based on the first weight, the first loss sum, the second weight, the second loss sum, the third weight, and the ternary loss to determine the total loss.
[0112] In some embodiments, the language recognition model includes a language recognition network and a speaker recognition network, and the language recognition model training device 600 also includes: a target language recognition model determination module, which is used to delete the speaker recognition network in the language recognition model to obtain a target language recognition model; a language recognition module, which is used to obtain a speech to be recognized and input the speech to be recognized into the target language recognition model so that the target language recognition model performs language recognition to obtain a language recognition result, wherein the language recognition result indicates the recognition scores corresponding to the speech to be recognized in multiple languages; and a target language determination module, which is used to determine the target language to which the speech to be recognized belongs from the multiple languages according to the recognition scores.
[0113] According to one aspect of the embodiments of the present application, an electronic device is also provided, such as Fig. 9 As shown, the vehicle 600 includes a processor 610 and one or more memories 620. The one or more memories 620 are used to store program instructions executed by the processor 610. When the processor 610 executes the program instructions, the above-mentioned language recognition model training method is implemented.
[0114] Furthermore, the processor 610 may include one or more processing cores. The processor 610 runs or executes instructions, programs, code sets or instruction sets stored in the memory 620, and calls data stored in the memory 620. Optionally, the processor 610 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 610 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor, but may be implemented separately through a communication chip.
[0115] According to one aspect of the present application, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium carries computer-readable instructions, and when the computer-readable storage instructions are executed by a processor, the method in any of the above embodiments is implemented.
[0116] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0117] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0118] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0119] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0120] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for training a language recognition model, characterized in that: The method comprises: Acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker; Inputting the speech sample set into a language recognition model, obtaining a first recognition result output by the language recognition model for language recognition of the speech sample set, and obtaining a second recognition result output by the language recognition model for speaker recognition of the speech sample set; Determine a language recognition loss, a speaker recognition loss, and a ternary loss according to the first recognition result and the second recognition result; Determining a total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the triple loss; If the total loss is greater than or equal to the loss threshold, the parameters of the language recognition model are updated according to the total loss until the total loss is less than the loss threshold, thus completing the training of the language recognition model.
2. The method according to claim 1, characterized in that The determining of the language recognition loss, the speaker recognition loss and the ternary loss according to the first recognition result and the second recognition result includes: Obtaining a first sample label and a second sample label corresponding to each of the speech samples in the speech sample set, wherein the first sample label indicates a target language to which the corresponding speech sample belongs, and the second sample label indicates a target speaker to which the corresponding speech sample belongs; Determining the language recognition loss according to the first sample label and the first recognition result, and determining the speaker recognition loss according to the second sample label and the second recognition result; Determine a first recognition feature for the language recognition model to recognize the speech sample set according to the first recognition result, and determine a second recognition feature for the language recognition model to recognize the speech sample set according to the second recognition result; The ternary loss is determined based on the first identification feature and the second identification feature.
3. The method according to claim 2, characterized in that The speech sample set includes a first speech sample and a second speech sample, the first speech sample and the second speech sample belong to different languages, the first recognition feature includes a first language recognition feature and a second language recognition feature, the second recognition feature includes a first speaker recognition feature and a second speaker recognition feature, and determining the ternary loss according to the first recognition feature and the second recognition feature includes: Obtaining an initial language center vector corresponding to the speech sample set; Determine a first parameter according to the first language recognition feature, the first speaker recognition feature and the initial language center vector; determining a second parameter according to the second language recognition feature, the second speaker recognition feature, and the initial language center vector; The ternary loss is determined according to the first parameter and the second parameter.
4. The method according to claim 3, characterized in that The determining the ternary loss according to the first parameter and the second parameter comprises: A minimum difference between the first parameter and the second parameter is determined, and the minimum difference is determined as the ternary loss.
5. The method according to claim 3, characterized in that: After determining the total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the tri-gram loss, the method further includes: If the total loss is greater than or equal to the loss threshold, determining the feature quantity of the first language recognition feature or the second language recognition feature, and determining the language feature corresponding to the first speech sample or the second speech sample; Determine the target language center vector according to the language features and the number of features; The initial language center vector corresponding to the speech sample set is updated to the target language center vector.
6. The method according to claim 1, characterized in that The language recognition loss includes a first language recognition loss and a second language recognition loss, the speaker recognition loss includes a first speaker recognition loss and a second speaker recognition loss, and determining the total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the ternary loss includes: determining a first loss sum of the first language recognition loss and the second language recognition loss and determining a second loss sum of the first speaker recognition loss and the second speaker recognition loss; Obtaining the first loss and the corresponding first weight, the second loss and the corresponding second weight, and the third weight corresponding to the ternary loss; The total loss is determined by performing weighted calculation based on the first weight, the first loss sum, the second weight, the second loss sum, the third weight, and the ternary loss.
7. The method according to any one of claims 1 to 6, characterized in that: The language recognition model includes a language recognition network and a speaker recognition network. If the total loss is greater than or equal to a loss threshold, the parameters of the language recognition model are updated according to the total loss until the total loss is less than the loss threshold and the training of the language recognition model is completed, the method further includes: Deleting the speaker recognition network in the language recognition model to obtain a target language recognition model; Acquire a speech to be recognized, and input the speech to be recognized into the target language recognition model so that the target language recognition model performs language recognition to obtain a language recognition result, wherein the language recognition result indicates the recognition scores corresponding to the speech to be recognized in multiple languages; The target language to which the speech to be recognized belongs is determined from the multiple languages according to the recognition score.
8. A method for training a language recognition model, characterized in that: The method comprises: An acquisition module, configured to acquire a speech sample set, wherein the speech sample set includes speech samples of at least two languages of the same speaker; A recognition module, used for inputting the speech sample set into a language recognition model, obtaining a first recognition result output by the language recognition model for language recognition of the speech sample set, and obtaining a second recognition result output by the language recognition model for speaker recognition of the speech sample set; A first loss determination module, configured to determine a language recognition loss, a speaker recognition loss, and a ternary loss according to the first recognition result and the second recognition result; A second loss determination module, configured to determine a total loss of the language recognition model according to the language recognition loss, the speaker recognition loss and the ternary loss; A training module is used to update the parameters of the language recognition model according to the total loss if the total loss is greater than or equal to the loss threshold, until the total loss is less than the loss threshold to complete the training of the language recognition model.
9. An electronic device, characterized in that: The electronic device comprises: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 7.
