Model training method, speech recognition method and device, electronic equipment, computer readable storage medium and computer program product

By adding a routing module to the coding layer of the speech recognition model, adaptive selection of the attention dimension of speech features is realized, which solves the problems of high computing resource consumption and low efficiency in the processing of long speech signals in the existing technology, and improves speech recognition. The training efficiency and recognition accuracy of the model.

CN118658461APending Publication Date: 2024-09-17MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410099603.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-22
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Existing speech recognition models consume high computing resources and have low efficiency when processing long speech signals, and cannot achieve adaptive selection of attention dimensions at the frame level, resulting in high training complexity and low recognition efficiency.

Method used

Add a routing module to the first type of coding layer of the pre-trained speech recognition model, and train the model to be trained through training data to achieve adaptive selection of the attention dimension of speech features in the coding layer, reducing model inference time and computing resources consumption.

Benefits of technology

Through frame-level adaptive selection of attention dimensions, model training complexity and inference time are reduced, and the training efficiency and recognition accuracy of the speech recognition model are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118658461A
    Figure CN118658461A
Patent Text Reader

Abstract

The invention provides a model training method, a voice recognition method and device, electronic equipment, a computer readable storage medium and a computer program product. The model training method comprises the following steps: acquiring training data and a preset speech recognition model; pre-training the preset speech recognition model by using the training data to obtain a pre-trained speech recognition model; adding a route selection module in a first type coding layer of the pre-trained voice recognition model to obtain a to-be-trained voice recognition model; and training the to-be-trained speech recognition model by using the training data to obtain the speech recognition model. Through the model training method provided by the invention, the model training efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of speech processing technology, and in particular to a model training method, a speech recognition method, a device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] Speech processing technology refers to the technology of analyzing, processing and identifying speech signals through computer algorithms. It covers multiple aspects, including the acquisition, preprocessing, feature extraction, speech recognition, speech synthesis and speech enhancement of speech signals.

[0003] Speech recognition is an important application branch of artificial intelligence. The commonly used method for speech recognition is to train a speech recognition model and perform speech recognition through the speech recognition model. Therefore, how to train the speech recognition model directly affects the accuracy of speech recognition. Summary of the invention

[0004] The embodiments of the present application provide a model training method, a speech recognition method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product, which can improve the efficiency of model training.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] The present application provides a model training method, the method comprising:

[0007] Obtain training data and preset speech recognition models;

[0008] Pre-training the preset speech recognition model using the training data to obtain a pre-trained speech recognition model;

[0009] Adding a routing selection module to the first type of encoding layer of the pre-trained speech recognition model to obtain a speech recognition model to be trained;

[0010] The speech recognition model to be trained is trained using the training data to obtain a speech recognition model.

[0011] The present invention provides a speech recognition method, which includes:

[0012] Performing feature extraction processing on the speech frame to be recognized of the speech data to be recognized, to obtain speech features;

[0013] A routing module of a first type of encoding layer in a speech recognition model determines an attention dimension of the speech feature in the first type of encoding layer;

[0014] The first type of encoding layer encodes the speech feature based on the attention dimension to obtain a first encoding result;

[0015] The decoding layer in the speech recognition model decodes the first encoding result to obtain a speech recognition result of the speech data to be recognized.

[0016] The present application provides a model training device, the device comprising:

[0017] An acquisition module, used to acquire training data and a preset speech recognition model;

[0018] A pre-training module, used to pre-train the preset speech recognition model using the training data to obtain a pre-trained speech recognition model;

[0019] An adding module, used for adding a routing selection module in the first type of encoding layer of the pre-trained speech recognition model to obtain a speech recognition model to be trained;

[0020] The training module is used to train the speech recognition model to be trained using the training data to obtain a speech recognition model.

[0021] The present application provides a speech recognition device, the device comprising:

[0022] A processing module, used for performing feature extraction processing on the speech frame to be recognized of the speech data to obtain speech features;

[0023] A determination module, used for a routing selection module of a first type of coding layer in a speech recognition model, to determine an attention dimension of the speech feature in the first type of coding layer;

[0024] An encoding module, configured for the first type of encoding layer to encode the speech feature based on the attention dimension to obtain a first encoding result;

[0025] A decoding module is used for the decoding layer in the speech recognition model to decode the first encoding result to obtain the speech recognition result of the speech data to be recognized.

[0026] An embodiment of the present application provides an electronic device, the electronic device comprising:

[0027] A memory for storing computer executable instructions;

[0028] The processor is used to implement the model training method or speech recognition method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.

[0029] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions for implementing the model training method or speech recognition method provided in the embodiment of the present application when executed by a processor.

[0030] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the model training method or speech recognition method provided in the embodiment of the present application is implemented.

[0031] The embodiments of the present application have the following beneficial effects:

[0032] In the model training method provided in the embodiment of the present application, by obtaining training data and a preset speech recognition model, the preset speech recognition model is pre-trained using the training data to obtain the pre-trained speech recognition model. After obtaining the pre-trained speech recognition model, the speech recognition model to be trained is obtained by adding a routing selection module in the first type of coding layer of the pre-trained speech recognition model, so that the speech recognition model to be trained is obtained by training the speech recognition model to be trained using the training data. The routing selection module can be used to select the attention dimension for the input speech frame to be recognized. Therefore, the above-mentioned innovative speech recognition model of the embodiment of the present application can realize the adaptive selection of the attention dimension at the frame level. Compared with the fixed attention dimension, the adaptive selection of the attention dimension at the frame level can reduce the complexity of model training, thereby improving the model training efficiency. In addition, since the first type of coding layer in the speech recognition model can capture local information, there is less demand for the attention dimension, thereby ensuring the speech recognition accuracy of the speech recognition model while improving the recognition efficiency of the speech recognition model. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 It is a schematic diagram of the prior art solution provided by the embodiment of the present application;

[0034] Figure 2 It is a structural diagram of the speech recognition system architecture provided in an embodiment of the present application;

[0035] Figure 3 It is a schematic diagram of the structure of the server provided in the embodiment of the present application;

[0036] Figure 4A It is a schematic diagram of the implementation flow of the model training method provided in the embodiment of the present application;

[0037] Figure 4B It is a schematic diagram of the implementation process of obtaining training data provided in an embodiment of the present application;

[0038] Figure 4CIt is a schematic diagram of the implementation process of the pre-training model provided in the embodiment of the present application;

[0039] Figure 4D It is a schematic diagram of the implementation process of training a speech recognition model provided in an embodiment of the present application;

[0040] Figure 4E This is a schematic diagram of an implementation flow of determining a dimension selection loss value provided in an embodiment of the present application;

[0041] Figure 5 It is a schematic diagram of the implementation flow of the speech recognition method provided in the embodiment of the present application;

[0042] Figure 6 It is a schematic diagram of the structure of the intelligent question-answering system provided in an embodiment of the present application;

[0043] Figure 7 It is a structural diagram of the speech recognition model provided in the embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0045] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0046] If similar descriptions of "first / second" appear in the application documents, the following explanation is added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0047] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0048] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0049] 1) End-to-end speech recognition: The goal of speech recognition is to convert the vocabulary content in human speech into text content. End-to-end speech recognition uses a pure neural network approach instead of the traditional mixed and separate training methods such as alignment models, acoustic models, and language models.

[0050] 2) Transformer: A time series model based on the self-attention mechanism. It can effectively encode time series information in the encoder part. Its processing ability of time series information is much better than that of the Long Short-Term Memory (LSTM) network, and its speed is fast. It is widely used in natural language processing, computer vision, machine translation, speech recognition and other fields.

[0051] 3) Conformer: Combining Transformer and Convolutional Neural Networks (CNN), the Transformer model is good at capturing content-based global interactions, while CNN effectively utilizes local features. This allows the model to better model both long-term global interaction information and local features.

[0052] 4) Soft max: Normalized exponential function, which is a generalization of the logic function. It can "compress" a K-dimensional vector containing any real number into another K-dimensional real vector, so that each element is between [0, 1] and the sum of all elements is 1.

[0053] 5) Encoder-decoder structure: A network structure commonly used in machine learning technology. It consists of two parts: an encoder and a decoder. The encoder converts the input text into a series of context vectors that can express the characteristics of the input text. The decoder receives the output of the encoder as its own input and outputs the corresponding text sequence in another language.

[0054] In related technologies, such as Figure 1 As shown, Figure 1 The solution uses a speech recognition network with local information fusion of a Transformer model, including an encoder and a decoder. The encoder's Multi-Head Attention (MHA) and the decoder's Multi-Head Cross-Attention (MHCA) use local feature masks within a limited range. The related technology also uses a speech recognition method and terminal device with local information fusion based on a Transformer model. It makes up for the defect of the original Transformer model that lacks explicit extraction of local features, and effectively reduces the CER value of speech recognition.

[0055] Since the related technology does not involve a routing selection module and uses a unified attention dimension, it is impossible to achieve adaptive selection of attention dimensions at the frame level, and the attention dimension parameters are relatively high during speech recognition. In addition, the "local feature mask within a limited range" used is only a relatively rough extraction of local features, which cannot accurately capture local information, and the speech recognition efficiency is low.

[0056] Based on this, the embodiments of the present application provide a model training method, a speech recognition method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product, which can solve the technical problem that the input speech signal is too long, resulting in an increase in model reasoning time and consumption of too many model computing resources. The exemplary application of the electronic device provided by the embodiment of the present application is described below. The electronic device provided by the embodiment of the present application can be implemented as a laptop, a tablet computer, a desktop computer, a set-top box, a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device), a smart phone, a smart speaker, a smart watch, a smart TV, a vehicle-mounted terminal, and other types of user terminals, and can also be implemented as a server. Below, an exemplary application when the device is implemented as a server will be described.

[0057] See also Figure 2 , Figure 2 It is a structural diagram of the speech recognition system architecture provided in an embodiment of the present application. To support an intelligent question-and-answer application, the terminal 200 is connected to the server 400 via a network 300. The network 300 may be a wide area network or a local area network, or a combination of the two.

[0058] The terminal 200 is used to collect voice data and send a voice recognition request to the server 400. The server 400 is used to parse the question and answer request to obtain the voice data to be recognized. The server 400 obtains the speech data to be recognized and the speech recognition model, the speech recognition model includes a plurality of first-class coding layers for capturing local information, each of the first-class coding layers includes a routing selection module, and the routing selection module is used to determine the attention dimension in the first-class coding layer; the server 400 performs frame processing on the speech data to be recognized to obtain a plurality of speech frames to be recognized; the server 400 inputs each speech frame to be recognized into the speech recognition model, and determines the attention dimension of the speech frame to be recognized in each first-class coding layer through the routing selection module; based on the attention dimension in the first-class coding layer, the server 400 uses a plurality of first-class coding layers to encode the speech frame to be recognized to obtain a first encoding result; the server 400 uses a plurality of decoding layers to decode the first encoding result to obtain a speech recognition result; the output speech recognition result is input into the intention understanding module, and according to the intention understanding judgment, the judgment logic is matched to the reply to be answered, and the text to be synthesized is generated through the text generation module, and then the synthesized speech is obtained through the speech synthesis module, and the server 400 sends the synthesized speech to the terminal 200, and a round of answer reply is completed at this time.

[0059] The speech recognition method provided in the embodiment of the present application can also be executed by the terminal 200. The terminal 200 obtains the speech recognition model from the server 400. Similarly, the speech recognition model includes multiple first-class coding layers. The first-class coding layer is used to capture local information. Each first-class coding layer includes a routing selection module. The routing selection module is used to determine the attention dimension in the first-class coding layer. After collecting the speech data, the terminal 200 uses the speech recognition model to recognize the collected speech data and outputs the recognition result.

[0060] In some embodiments, the server 400 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The terminal 400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a car terminal, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0061] Take server 400 for model training as an example, see Figure 3 , Figure 3 is a schematic diagram of the structure of the server provided in the embodiment of the present application, Figure 3 The server 400 shown includes: at least one processor 410, a memory 450, at least one network interface 420 and a user interface 430. The various components in the server 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 440 is not described in detail. Figure 3 Various buses are labeled as bus system 440 .

[0062] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0063] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.

[0064] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.

[0065] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0066] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0067] A network communication module 452, used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB), etc.;

[0068] The input processing module 454 is used to detect one or more user inputs or interactions from one of the one or more input devices 432 and translate the detected inputs or interactions.

[0069] In some embodiments, the model training device provided in the embodiments of the present application can be implemented in software. Figure 3 The model training device 455 stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: an acquisition module 4551, a pre-training module 4552, an addition module 4553 and a training module 4554. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.

[0070] In some embodiments, the speech recognition device provided in the embodiments of the present application may be implemented in software, and the speech recognition device ( Figure 3 ), which may be software in the form of programs and plug-ins, including the following software modules: a processing module, a determination module, an encoding module, and a decoding module. These modules are logical, and thus can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0071] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the model training method and speech recognition method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), digital signal processors (Digital Signal Processor, DSP), programmable logic devices (Programmable Logic Device, PLD), complex programmable logic devices (Complex Programmable Logic Device, CPLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other electronic components.

[0072] The model training method provided by the embodiment of the present application will be described in conjunction with the exemplary application and implementation of the server provided by the embodiment of the present application. The electronic device that implements the model training method of the embodiment of the present application can be a terminal, a server, or a combination of the two. Therefore, the execution subject of each step will not be repeated below.

[0073] See also Figure 4A , Figure 4A This is a schematic diagram of the implementation flow of the model training method provided in the embodiment of the present application, which will be combined with Figure 4A The steps shown are explained.

[0074] Step 101: Obtain training data and a preset speech recognition model.

[0075] The training data includes training speech data and text recognition results corresponding to the training speech data. The preset speech recognition model may be a neural network model, such as a deep learning model, a recurrent neural network model, etc., which is not specifically limited here. The preset speech recognition model includes an encoding module and a decoding module.

[0076] In some embodiments, the encoding module may be an encoder module of an encoder-decoder model (encoder-decoder structure). In a specific embodiment, the encoder module may be a Conformer network, comprising 8 first-class encoding layers and 4 second-class encoding layers. Among them, the first-class encoding layer may include layers 1-4 and 9-12, and the second-class encoding layer may include layers 5-8. The first-class encoding layer is used to capture local information, and the second decoding layer is used to capture global information. The first-class encoding layer and the second-class encoding layer have the same attention dimension to meet the encoding requirements for the recognized speech data.

[0077] In some embodiments, the Figure 4B Steps 1011 to 1013 shown are for obtaining training data, which will be described in detail below.

[0078] Step 1011: Obtain training speech data and text recognition results corresponding to the training speech data.

[0079] In some embodiments, the training voice data and the text recognition results corresponding to the training voice data can be a conversation and the text corresponding to the conversation, or a song and the lyrics of the song, or a recording of a TV series or movie and the corresponding lines of the recording, without specific limitation here.

[0080] In some embodiments, the training voice data and the text recognition results corresponding to the training voice data may be pre-uploaded by the terminal. In actual implementation, the training voice data and the text recognition results corresponding to the training voice data are pre-uploaded on the server, and the server stores the training voice data and the text recognition results corresponding to the training voice data.

[0081] In some embodiments, the training voice data and the text recognition results corresponding to the training voice data may also be actively uploaded before training; in another embodiment, the training voice data and the text recognition results corresponding to the training voice data may be a public training set obtained by the server from the Internet.

[0082] Step 1012: Perform index processing on the training voice data and the text recognition results corresponding to the training voice data to obtain the training voice data and the text index corresponding to the training voice data.

[0083] In actual implementation, create an empty index file to store the index of the training voice data. Create an empty text index file to store the text index corresponding to the training voice data. Traverse each voice file of the training voice data and obtain the file name as the index identifier. Write the file name of the voice data file into the voice data index, write the text recognition result and the corresponding index identifier into the text index file, and obtain the training voice data and the text index corresponding to the training voice data.

[0084] Step 1013: determine the training speech data and the text index corresponding to the training speech data as the training data.

[0085] In actual implementation, the text index corresponding to the training voice data is used to indicate the order of the corresponding voice frame in all the voice frames of the training voice data. For example, the frame index of the first voice frame in the training voice data can be recorded as 0, the frame index of the second voice frame can be recorded as 1, and so on. After obtaining the frame information of multiple voice frames, the frame information can be arranged in a preset order to obtain a preset frame sequence, that is, the objects in the preset frame sequence are sorted in units of frame information. Among them, the preset order can be set according to actual needs, without specific limitation, and can also be dynamically adjusted according to actual needs during the application process.

[0086] Continue to refer to Figure 4A , proceed to step 101 for explanation.

[0087] Step 102: Pre-train a preset speech recognition model using the training data to obtain a pre-trained speech recognition model.

[0088] In actual implementation, the preset speech recognition model is pre-trained using the training data to obtain a pre-trained speech recognition model. The purpose is to determine the parameters of each part of the speech recognition model, optimize the recognition ability of the speech recognition model, and facilitate the implementation of subsequent steps.

[0089] In some embodiments, the training data includes training speech data and a text index corresponding to the training speech data, the preset speech recognition model includes a plurality of first-class encoding layers, a plurality of second-class encoding layers and a plurality of decoding layers, and the attention dimensions of the plurality of first-class encoding layers and the plurality of second-class encoding layers are the same. Figure 4C Steps 1021 to 1025 shown implement the pre-training model, which is described in detail below.

[0090] Step 1021: pre-process the training speech data to obtain training speech features.

[0091] Here, since the speech data to be recognized is represented by a series of discrete sampling points in the electronic device, each sampling point represents the amplitude of the sound at a moment, a speech data of a few seconds, the sequence length will be very long, and each sampling point contains relatively little speech information, so the original speech data to be recognized is not suitable for direct input of the model, but needs to be preprocessed before speech recognition, and the preprocessing of the speech data to be recognized includes: pre-emphasis, framing, windowing, fast Fourier transform, feature extraction and other processes. Framing processing is used to divide the continuous speech signal into short-term speech frames, which helps to capture more subtle feature changes in the speech signal for subsequent use. When the speech data to be recognized is framed, first select the appropriate frame length and frame shift parameters, and then perform windowing operation on the speech data to be recognized according to the frame length and frame shift parameters, so that the windowed speech data to be recognized is divided into multiple speech frames to be recognized, the length of each speech frame to be recognized is the frame length, and the interval between adjacent frames is the frame shift. Pre-emphasis, framing, and windowing are all preparations for fast Fourier transform, so that the spectrum obtained by fast Fourier transform has higher quality. After using fast Fourier transform to perform time-frequency conversion on each speech frame to be identified and obtain the spectrum of each speech frame to be identified, the spectrum of each speech frame to be identified can be used to extract features to obtain the speech features of each speech frame to be identified, where the speech features can be Fbbank features or MFCC features, which are not limited in the embodiments of the present application.

[0092] Step 1022: The first type of coding layer and the second type of coding layer in the preset speech recognition model sequentially encode the training speech features to obtain training coding results.

[0093] In some embodiments, the first type of coding layer includes a first feedforward module, a convolution module, a second feedforward module and a normalization module. In step 1022, after being processed by the first feedforward module, the convolution module is used to perform convolution processing to obtain a convolution result, and then the second feedforward module and the normalization module are used to process respectively to obtain the coding result of the first type of coding layer. The coding result of the first type of coding layer is passed to the next coding layer. If the next coding layer is still the first type of coding layer, then the next coding layer is used to perform the same processing as the above operation, and after the coding result is obtained, it is passed to the next coding layer. If the next coding layer is the second type of coding layer, the second type of coding layer includes a first feedforward module, a multi-head attention module, a convolution module, a second feedforward module and a normalization module. At this time, the first feedforward module, the multi-head attention module, the convolution module, the second feedforward module and the normalization module included in the next coding layer are used to encode the coding result passed from the previous coding layer in turn to obtain the coding result of the current coding layer, until the last coding layer is reached to obtain the training coding result.

[0094] Step 1023: Determine a first encoding loss value based on the training encoding result and the text index.

[0095] Here, the training encoding result and the text index may be used to calculate the loss value to obtain a first encoding loss value.

[0096] In some embodiments, the loss function of the encoding module can be pre-set. Exemplarily, the encoding module adopts the CTC loss function. The text index corresponding to the training encoding result and the training speech data is substituted into the loss function to obtain the first encoding loss value.

[0097] Step 1024: The decoding layer decodes the training encoding result to obtain a predicted recognition result.

[0098] In some embodiments, when the model of the decoding module is Transformer, the first encoding result is processed by 6 layers of decoding layers and a predicted recognition result is output.

[0099] Step 1025: Determine a first decoding loss value based on the predicted recognition result and the text index, determine a first model loss value based on the first encoding loss value and the first decoding loss value, and adjust the model parameters of the preset speech recognition model based on the first model loss value until the end condition is reached to obtain a pre-trained speech recognition model.

[0100] In some embodiments, the predicted recognition result and the text index are subjected to loss value calculation to obtain a first decoding loss value. Similar to the encoding module, the loss function corresponding to the decoding module can be pre-set. Exemplarily, the loss function corresponding to the decoding module can be an Attention function. Substituting the first predicted recognition result and the text index into the loss function, the first decoding loss value can be obtained. The first encoding loss value and the first decoding loss value can be directly summed to determine the first model loss value; in other embodiments, the first encoding loss value and the first decoding loss value can also be weighted and summed to determine the first model loss value.

[0101] In actual implementation, back propagation starts from the output layer of the speech recognition model and propagates forward layer by layer, that is, in the direction of the input layer, layer by layer. During the propagation process, the model parameters of the corresponding network layer are updated until the training end condition is reached to obtain a pre-trained speech recognition model. The training end condition can be the convergence of the first model loss value, that is, the first model loss value reaches the minimum value, or it can be the reaching of a preset number of training times, or it can be the difference between the first model loss values ​​of two consecutive trainings is less than a preset difference threshold.

[0102] By pre-training the speech model, pre-training uses large-scale data to pre-process the speech model to improve the generalization ability and efficiency of the speech model, accelerate the training speed of the speech model in subsequent steps, and reduce training costs.

[0103] Continue to refer to Figure 4A , proceed to step 102 for explanation.

[0104] Step 103: Add a routing selection module to the first type of encoding layer of the pre-trained speech recognition model to obtain the speech recognition model to be trained.

[0105] In some embodiments, when the encoding module is a Conformer, the 1st to 4th layers and the 9th to 12th layers are selected as the first type of encoding layers, and a routing selection module is added thereto. The structure of each encoding layer in the original Conformer model is a first feedforward module, a multi-head attention module, a convolution module, a second feedforward module, and a normalization module. After adding the routing selection module, the structure of the first type of encoding layer is a first feedforward module, a routing selection module, a multi-head attention module, a convolution module, a second feedforward module, and a normalization module.

[0106] Step 104: Using the training data to train the speech recognition model to be trained to obtain a speech recognition model.

[0107] In some embodiments, the Figure 4D The speech recognition model is trained from step 1041 to step 1046 as shown, which is described in detail below.

[0108] Step 1041: The routing selection module in the first type of encoding layer determines the attention dimension of the training speech feature in the first type of encoding layer.

[0109] In some embodiments, step 1041 may be implemented through the following steps, which are described in detail below.

[0110] Step 1: The pre-trained speech recognition model predicts the training speech features to obtain the dimensional prediction results of the routing selection module in the first type of encoding layer.

[0111] In some embodiments, when N selectable attention dimensions are preset, the dimension prediction result of the routing selection module may be a 1*N dimensional vector, in which each vector value represents the possibility of selection of each attention dimension.

[0112] Step 2: Determine the attention dimension of the training speech feature in the first encoding layer based on the dimension prediction results.

[0113] In some embodiments, the attention dimension corresponding to the highest probability value in the dimension prediction result is determined as the attention dimension of the training speech feature in the first type of encoding layer through the routing selection module.

[0114] Exemplarily, there are four selectable attention dimensions, namely 128 dimensions, 160 dimensions, 192 dimensions, and 256 dimensions, and the dimension prediction results are [3.2, 6, 7.9, 2.9]. Since the dimension prediction result is 7.9, 7.9 corresponds to 192 dimensions, then the attention dimension of the training speech features in the first encoding layer is 192.

[0115] Continue to refer to Figure 4D , proceed to step 1041 for explanation.

[0116] Step 1042: Determine the dimension selection loss value corresponding to the routing selection module, and back-propagate the dimension selection loss value corresponding to the routing selection module to the routing selection module to adjust the parameters of the routing selection module.

[0117] In actual implementation, the back propagation of the routing module starts from the output layer of the routing module and propagates forward layer by layer, that is, propagates in the direction of the input layer. During the propagation process, the parameters of the routing module are updated.

[0118] In some embodiments, the step 1042 of “determining the dimension selection loss value corresponding to the routing selection module” can be performed as follows: Figure 4E Steps 421 to 424 shown in the figure are implemented by combining Figure 4E Specific instructions.

[0119] Step 421: Obtain dimension label information corresponding to the training speech features.

[0120] In some embodiments, after the training speech data is framed, each frame can be encoded using one-hot encoding as the dimension label information of the training speech feature corresponding to the training speech frame, and the dimension label information is uniformly distributed and sampled from the selected dimensions, which becomes a uniform distribution according to the frame, combined with the uniform distribution, and the updated dimension label vector y is used. i To replace the traditional ont-hot encoded label vector y hot :

[0121] y i =y hot (1-α)+α / k (1);

[0122] Among them, k is the total number of multi-classification categories, α is a small hyperparameter (usually 0.1), and i is the ordinal number of the dimension label, that is,

[0123]

[0124] The distribution after label smoothing is equivalent to adding noise to the true distribution, which prevents the model from being overconfident about the correct label and makes the difference between the output values ​​of predicted positive and negative samples smaller, thereby avoiding overfitting and improving the generalization ability of the model.

[0125] Step 422: normalize the dimension prediction result to obtain a normalized dimension prediction result.

[0126] Among them, normalization processing aims to scale the data to a fixed range or convert it into a format that meets specific requirements according to certain rules, ensure that the data conforms to a specific distribution within a certain range, reduce the differences between data, and improve the training effect and prediction accuracy of the model.

[0127] Step 423: Obtain a preset dimension selection loss function.

[0128] Step 424: The normalized dimension prediction result and dimension label information are used as input data of the dimension selection loss function to calculate the loss value, and the dimension selection loss value corresponding to the routing selection module is obtained.

[0129] Exemplarily, the dimension selection loss function may be a cross entropy loss function, and the dimension selection loss value may be obtained by substituting the prediction result and dimension label information output by the routing selection module into the dimension selection loss function.

[0130] Step 1043: The first encoding layer encodes the training speech features based on the attention dimension;

[0131] Step 1044: Determine a second encoding loss value based on the encoding processing result and the text index.

[0132] It should be noted that the implementation process of "the first type of encoding layer encodes the training speech features based on the attention dimension to obtain the encoding processing result; and determines the second encoding loss value based on the encoding processing result and the text index" is similar to the implementation process of step 204 below, and the implementation process can refer to the implementation process of step 204. After obtaining the encoding processing result, the loss value is calculated between the encoding processing result and the text index to obtain the second encoding loss value.

[0133] In some embodiments, the loss function of the encoding module can be pre-set. Exemplarily, the encoding module adopts the CTC loss function, and the encoding processing result and the text index are substituted into the loss function to obtain the second encoding loss value.

[0134] Step 1045: The decoding layer decodes the encoding result to obtain a second prediction recognition result.

[0135] In some embodiments, when the model of the decoding module is Transformer, the encoding processing result is processed by 6 layers of decoding layers to output a second prediction recognition result.

[0136] Step 1046: Determine a second decoding loss value based on the second predicted recognition result and the text index, determine a second model loss value based on the second encoding loss value and the second decoding loss value, and adjust the model parameters of the pre-trained speech recognition model based on the second model loss value.

[0137] In some embodiments, the second predicted recognition result and the text index are subjected to a loss value calculation to obtain a second decoding loss value. Similar to the encoding module, the loss function corresponding to the decoding module can be pre-set. For example, the loss function corresponding to the decoding module can be an Attention function. Substituting the second predicted recognition result and the text index into the loss function, the second decoding loss value can be obtained. The second encoding loss value and the first decoding loss value can be directly summed to determine the second model loss value; in other embodiments, the second encoding loss value and the second decoding loss value can also be weighted and summed to determine the second model loss value.

[0138] In actual implementation, back propagation starts from the output layer of the speech recognition model and propagates forward layer by layer, that is, in the direction of the input layer, layer by layer. During the propagation process, the model parameters of the corresponding network layer are updated. Until the training end condition is reached, the pre-trained speech recognition model is obtained. The training end condition can be the convergence of the second model loss value, that is, the first model loss value reaches the minimum value, or it can be the preset number of training times, or the difference between the second model loss values ​​of two consecutive trainings is less than the preset difference threshold.

[0139] Through the above steps, the attention dimension of the speech frame to be recognized in each first-class coding layer can be determined by the routing selection module, and the adaptive selection of the attention dimension at the frame level can be realized. Under the premise of ensuring local information, the computational amount of model reasoning and prediction can be greatly reduced, thereby reducing the resources consumed by model reasoning and improving the efficiency of speech recognition.

[0140] The following describes the speech recognition method provided by the embodiment of the present application. As mentioned above, the electronic device implementing the speech recognition method of the embodiment of the present application can be a terminal, a server, or a combination of the two. Therefore, the execution subject of each step will not be repeatedly described below.

[0141] See also Figure 5 , Figure 5 is a schematic diagram of the implementation flow of the speech recognition method provided in the embodiment of the present application, which will be combined with Figure 5 The steps shown are explained, Figure 5 The steps are performed by an electronic device.

[0142] In step 201, feature extraction processing is performed on a speech frame to be recognized of speech data to obtain speech features.

[0143] In some embodiments, the voice data to be recognized can be obtained first. The voice data to be recognized can be the collected question voice of the user, or a song clip in a song, or a character dialogue (or narration) voice extracted from a movie or TV series. It can also be raw audio data from a microphone, a recording file, or other audio source. The speech recognition model can be a neural network model, such as a deep learning model, a recurrent neural network model, etc., which is not specifically limited here. The speech recognition model is trained with a large amount of speech data to learn how to accurately recognize speech as corresponding text. The speech recognition model includes at least an encoding module and a decoding module.

[0144] Here, since the speech data to be recognized is represented by a series of discrete sampling points in the electronic device, each sampling point represents the amplitude of the sound at a moment, a speech data of a few seconds, the sequence length will be very long, and each sampling point contains relatively little speech information, so the original speech data to be recognized is not suitable for being directly used as the input of the model, but it is necessary to first perform frame processing on the speech data to be recognized before speech recognition to obtain the speech frame to be recognized. Frame processing is used to divide the continuous speech signal into short-term speech frames, which helps to capture more subtle feature changes in the speech signal for subsequent use. When the speech data to be recognized is framed, first select a suitable frame length and frame shift parameters, and then perform a windowing operation on the speech data to be recognized according to the frame length and frame shift parameters, so that the windowed speech data to be recognized is divided into a plurality of speech frames to be recognized, the length of each speech frame to be recognized is the frame length, and the interval between adjacent frames is the frame shift. When performing feature extraction processing on the speech frames to be recognized, first use the fast Fourier transform to perform time-frequency conversion on each speech frame to be recognized to obtain the spectrum of each speech frame to be recognized, and then use the spectrum of each speech frame to be recognized to perform feature extraction to obtain the speech features of each speech frame to be recognized, wherein the speech features can be Fbbank features or MFCC features, which is not limited in the embodiments of the present application.

[0145] In step 202, a routing selection module of a first type of encoding layer in a speech recognition model determines an attention dimension of a speech feature in the first type of encoding layer.

[0146] In some embodiments, a speech recognition model is first obtained. Exemplarily, the speech recognition model can include multiple first-class encoding layers, multiple second-class encoding layers, and multiple decoding layers. The first-class encoding layers are used to capture local information, and the second-class encoding layers are used to capture global information. The first-class encoding layers each include a routing selection module, and the routing selection module is used to determine the attention dimension in the first-class encoding layer. Local information can be understood as local features, and global information can be understood as global features.

[0147] The encoding module can be an encoder module of an encoder-decoder model (encoder-decoder structure), and the encoding module includes multiple encoding layers, which are used to encode the voice data. Among them, at least one encoding layer at the bottom and at least one encoding layer at the top of the encoding module are used to capture the local information of the voice data, so the requirements for the total dimension of the attention mechanism are not high. In an embodiment of the present application, a routing selection module is added to each first-class encoding layer to determine the attention dimension in the first-class encoding layer through the routing selection module, so as to realize the adaptive selection of the attention dimension. The encoding layer in the middle part of the encoding module is used to capture global information, so the second-class encoding layer can be understood as at least one encoding layer in the middle part of the encoding module. And the attention dimension in the second-class encoding layer is fixed.

[0148] Exemplarily, the coding module may be a Conformer network module, assuming that the coding module includes a total of 12 coding layers, of which 8 first-type coding layers and 4 second-type coding layers may be included. The first-type coding layers may include layers 1-4 and 9-12, and the second-type coding layers may include layers 5-8.

[0149] The decoding module may be a decoder module of an encoder-decoder model (encoder-decoder structure), and the decoding module may include multiple decoding layers for decoding the encoding result. In a specific embodiment, the decoder module may be a Transformer network, including 6 decoding layers. This satisfies the decoding requirements for the output results of the Conformer network.

[0150] When step 202 is implemented, the speech feature can be input into the speech recognition model, and the attention dimension of the speech feature in the first coding layer can be determined by the routing module. The speech feature is input into the speech recognition model, so that each speech feature is processed by the speech recognition model to obtain the speech recognition result. Since the speech recognition model includes a coding module and a decoding module, and after each speech feature is input into the speech recognition model, each speech feature is firstly coded by the coding module. Further, since the coding module includes multiple coding layers, the first type of coding layer including the routing module is located at the top and bottom of the coding module. Therefore, when each speech feature is coded by multiple coding layers, if the current coding layer is the first type of coding layer, the routing module in the first type of coding layer will be used to determine the attention dimension of the speech feature in the first type of coding layer, and then the attention dimension will be used for coding, and the coding result obtained by the current coding layer will be passed to the next coding layer to continue coding until it is passed to the last coding layer to obtain the final coding result.

[0151] In some embodiments, the first type of coding layer includes a first feedforward module, a routing module, a convolution module, a second feedforward module, and a normalization module. Taking the input of speech features into the first coding layer as an example, the first coding layer is the first type of coding layer, then the speech features will first be processed using the first feedforward module to obtain a processing result, and then the processing result will be input into the routing module to determine the attention dimension corresponding to the speech feature through the routing module. Among them, a plurality of preset attention dimensions will be pre-set. For example, 8 attention dimensions of 128 to 256 dimensions can be pre-set, and the routing module is used to predict the probability of speech features selecting these 8 preset attention dimensions, and the preset attention dimension corresponding to the highest probability is determined as the attention dimension of the speech feature in the first type of coding layer.

[0152] In step 203, the first type of encoding layer encodes the speech features based on the attention dimension to obtain a first encoding result.

[0153] In some embodiments, the first type of coding layer includes a first feedforward module, a routing selection module, a convolution module, a second feedforward module and a normalization module. After the attention dimension of the speech feature is determined by the routing selection module, the convolution module is used to perform convolution processing using the attention dimension to obtain the convolution result, and then the second feedforward module and the normalization module are used to process respectively to obtain the coding result of the first type of coding layer.

[0154] In some embodiments, the number of first-class coding layers is M, and the speech recognition model further includes N second-class coding layers, the M first-class coding layers are divided into a first part and a second part, the first part includes P first-class coding layers connected in series, and the second part includes MP first-class coding layers connected in series; the first part, the N second-class coding layers, and the second part are connected in series in sequence; wherein M and N are both integers greater than 1, and P is a positive integer less than M. The above step 1033 can be implemented by the following steps:

[0155] In the first step, each first-category encoding layer in the first part encodes the speech features based on the corresponding attention dimension to obtain the first intermediate encoding result.

[0156] Here, first, the speech features are encoded according to the corresponding attention dimension through the first first-category encoding layer in the first part, and then the encoding result of the first first-category encoding layer is passed to the next encoding layer. If the next encoding layer is still the first-category encoding layer, the routing selection module in the next encoding layer is used to determine the attention dimension, and the determined attention dimension is used for encoding, and then it is passed to the next encoding layer, and the above steps of the first first-category encoding layer are repeated until the last first-category encoding layer is reached to obtain the first intermediate encoding result.

[0157] In the second step, each of the N second-type coding layers encodes the first intermediate coding result to obtain a second intermediate coding result.

[0158] Here, the second type of coding layer includes a first feedforward module, a multi-head attention module, a convolution module, a second feedforward module, and a normalization module. If the next coding layer passed by the first type of coding layer is a second type of coding layer, the first feedforward module, the multi-head attention module, the convolution module, the second feedforward module, and the normalization module included in the first second type of coding layer in the second type of coding layer are used to encode the coding result passed from the previous coding layer to obtain the coding result of the current second type of coding layer, and then pass it to the next second type of coding layer, and repeat the above steps of the first second type of coding layer until the last second type of coding layer is reached to obtain the second intermediate coding result.

[0159] In the third step, each first-category encoding layer in the second part encodes the second intermediate encoding result based on the corresponding attention dimension to obtain the first encoding result.

[0160] Here, the second intermediate coding result is encoded by the first first-category coding layer in the second part according to the corresponding attention dimension, and then the coding result of the first first-category coding layer is passed to the next coding layer, and then the routing selection module in the next coding layer is used to determine the attention dimension, and the determined attention dimension is used for encoding. Continue to pass to the next coding layer in the second part, and loop the above steps of the first first-category coding layer in the second part until the last first-category coding layer is reached to obtain the first coding result.

[0161] In step 204, the decoding layer in the speech recognition model decodes the first encoding result to obtain a speech recognition result of the speech data to be recognized.

[0162] In some embodiments, the decoding module includes multiple decoding layers, each decoding layer includes a masked multi-head attention layer, a multi-head attention layer and a feedforward network layer, and the input of each decoding layer includes a first encoding result and an output result of a previous decoding layer. Using the multiple decoding layers in the decoding module, the first encoding result is decoded in sequence to obtain a speech recognition result.

[0163] In the speech recognition method provided in the embodiment of the present application, the first type of coding layer of the speech recognition model is used to capture local information. In the embodiment of the present application, the first type of coding layer includes a routing selection module, and the routing selection module is used to determine the attention dimension in the first type of coding layer. After obtaining the speech data to be recognized, the speech data to be recognized is framed to obtain multiple speech frames to be recognized, and the speech features of each speech frame to be recognized are extracted. When each speech feature is input into the speech recognition model, the attention dimension of the speech frame to be recognized in the first type of coding layer is determined by the routing selection module, and the adaptive selection of the attention dimension at the frame level is realized. Compared with the use of a unified attention dimension, this method can effectively reduce the attention dimension parameters in the speech recognition process. Since the first type of coding layer is used to capture local information, the demand for the attention dimension is less, thereby improving the efficiency of speech recognition while ensuring the accuracy of speech recognition.

[0164] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.

[0165] The speech recognition method provided in this application can be applied to any scenario that requires speech recognition, such as speech quality inspection, voice intelligent question and answer, voice robots, etc. Figure 6 is a schematic diagram of the structure of the intelligent question-answering system provided in the embodiment of the present application. Figure 6 As shown, the intelligent question-answering system includes: a voice collection module 601, a voice recognition module 602, an intention understanding module 603, a text generation module 604 and a speech synthesis module 605, wherein the voice collection module 601 is used to collect question voice data, and exemplarily, the voice collection module 601 can be a microphone; the speech recognition module 602 is used to perform voice recognition on the collected question voice data to obtain a recognition result; the speech recognition module 602 is implemented by the speech recognition method adopted in the embodiment of the present application; the intention understanding module 603 is used to determine the question intention using the recognition result, the text generation module 604 is used to determine the reply text according to the determined question intention, and the speech synthesis module 605 is used to generate the voice data corresponding to the reply text and output it. At this time, a round of reply is completed, and this goes back and forth.

[0166] When the speech recognition module (also referred to as the speech recognition model) performs speech recognition using the speech recognition method provided by the embodiment of the present application, the attention dimension in the coding layer for extracting local features is adaptively determined by the routing selection network, so that the attention dimension parameter in the reasoning process can be reduced, so that the speech recognition model can effectively improve the reasoning speed, so that when the reasoning speed is improved, the accuracy of the model is not greatly reduced. The speech recognition method provided by the embodiment of the present application can effectively improve the efficiency of the speech recognition module in the intelligent question and answer system, and improve the speed of reply while taking into account the recognition accuracy. The accuracy and efficiency of speech recognition determine the accuracy of intention recognition. If speech recognition cannot achieve the efficiency and real-time performance that meet actual needs, it will seriously affect the effect of the system landing. The speech recognition method provided by the embodiment of the present application can effectively improve the accuracy and efficiency of speech recognition, and bring strong beneficial effects to the implementation of the intelligent question and answer system and the outbound call system.

[0167] Figure 7 is a schematic diagram of the structure of the speech recognition model provided in the embodiment of the present application, such as Figure 7 As shown, the speech recognition model includes an encoding module 701 and a decoding module 702, and the encoding module 701 includes multiple encoding layers, and the decoding module 702 includes multiple decoding layers. Since the bottom encoding layer and the top encoding layer of the encoding module focus on capturing local information, the total dimension requirement of the attention mechanism is not very large. Therefore, in the embodiment of the present application, a routing selection module is added to the bottom encoding layer and the top encoding layer in the encoding module to automatically select the attention dimension in the encoding layer. Figure 7 As shown, the encoding module 701 may include 12 encoding layers. In an embodiment of the present application, the multi-head attention layers in layers 1-4 and layers 8-12 in the encoding module may be changed to a routing selection network, which can automatically select the attention dimension, thereby reducing the attention feature inference time.

[0168] Combine the following Figure 7 The training process of the speech recognition model is explained.

[0169] Step 1: Obtain training data and initial speech recognition model.

[0170] In some embodiments, when this step is implemented, ten thousand hours of speech recognition data (including audio data and its corresponding text recognition results) can be indexed to obtain the text index applied to each training speech data. In this embodiment, an empty index file wav.scp is created to store the index of the training speech data. Then an empty text index file txt is created to store the text index corresponding to the training speech data. Each speech file of the training speech data is traversed to obtain the file name as the index identifier. The file name of the speech data file is written into the speech data index, and the text recognition result and the corresponding index identifier are written into the text index file to obtain the training speech data and the text index corresponding to the training speech data.

[0171] The dimensions of all attention layers in the initial speech recognition model are the same, illustratively, they can all be 256 dimensions, and the total number of encoding layers is 12 layers.

[0172] After the training speech data is framed, each frame is encoded using one-hot as a dimension label, and the dimension label is uniformly sampled from the selected dimension. This becomes a uniform distribution based on the frame, combined with the uniform distribution, and the updated label vector is used. To replace the traditional ont-hot encoded label vector y hot :

[0173] y i =y hot (1-α)+α / k (3);

[0174] Where K is the total number of multi-classification categories, α is a small hyperparameter (usually 0.1), and i is the sequence number of the vector, that is,

[0175]

[0176] The distribution after label smoothing is equivalent to adding noise to the true distribution, which prevents the model from being overconfident about the correct label and makes the difference between the output values ​​of predicted positive and negative samples smaller, thereby avoiding overfitting and improving the generalization ability of the model.

[0177] Step 2: Use the training data to train the speech recognition model to obtain a pre-trained speech recognition model.

[0178] In some embodiments, the above-mentioned training data is loaded by code, and then the speech features of the training data are extracted, which can be fbank features, for example, and then the speech features are input into the encoding layer of the speech recognition module for encoding processing to obtain an acoustic vector mapping (corresponding to the training encoding results in other embodiments), and then the loss function corresponding to the encoding module (for example, it can be the CTC loss function) is used to calculate the loss value of the acoustic vector mapping and the label to obtain the loss value (CTCloss) corresponding to the encoding module, and at the same time, the acoustic vector mapping is input into the decoding module to perform language model context learning, output the language model vector (corresponding to the speech recognition results in other embodiments), and the loss function corresponding to the decoding module (for example, it can be Attention loss) is used to calculate the loss value to obtain the loss value corresponding to the decoding module. The two losses are weighted and summed to obtain the total loss value, and the total loss value is back-propagated to the speech recognition model, thereby optimizing the parameters of the speech recognition model. The calculation formula of the total loss value is shown in Formula 5. It should be noted that the entire speech recognition model is trained in step 2, so the network parameters of the entire speech recognition model are determined.

[0179] charloss=0.3*CTCloss+0.7*Attentionloss (5);

[0180] Among them, Attention loss improves the generalization of the model to erroneous data through soft score loss.

[0181] Step 3: Add a routing selection network to the 1st to 4th layer network and the multi-head attention module in the 8th to 12th layer of the pre-trained speech recognition model, and train the pre-trained speech recognition model to obtain the final trained speech recognition model.

[0182] In an embodiment of the present application, the routing network can select the attention dimension at the frame level from different dimensions of 128 to 256. The routing network is added to the multi-head self-attention module of the pre-trained speech recognition model obtained in step 2. During the training process, the result of the routing network is output to a softmax layer for normalization to obtain the probability distribution of the attention dimension selection, and the probability distribution of the softmax output is determined by the cross entropy loss function to determine the difference between the actual output probability and the expected output probability (corresponding to the dimension selection loss value in other embodiments). The loss value determined by the cross entropy loss function is back-propagated to the routing network, thereby updating the parameters of the routing network. During the training process, the value of the cross entropy loss function is made as small as possible. When the loss value of formula 3 is the minimum, it indicates that the speech model training is completed. At this time, the parameters of the routing network are stopped to obtain the trained speech model. In addition, during the training process, the learning rate is adjusted to 1 / 8 of step 2, and if the dimension of the routing network output is not compatible with the dimension of the subsequent convolutional neural network, the linear layer is used to align the dimensions of the routing network and the convolutional layer.

[0183] In the embodiment of the present application, the goal of training the routing selection network is to enable all branches of different attention dimensions to be selected evenly. That is, the ultimate goal of training the routing selection network is not to allow one attention dimension to be always selected while another or several other attention dimensions are not always selected, but to make the probability of different attention dimensions being selected relatively balanced.

[0184] When the speech recognition model trained above needs to be applied, the model parameters of the encoding module and decoding module formed in step three are loaded. After the speech data is collected, the speech data is first preprocessed and the 80-dimensional fbank features are extracted. Then, the trained speech recognition model is used to perform model inference on the fbank features. During the inference process, the routing selection network is used to automatically determine the attention dimension used by the encoding layer, which effectively reduces the inference resource consumption during the inference process and improves the speech recognition efficiency of the model.

[0185] The following continues to describe the exemplary structure of the model training device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, such as Figure 3 As shown, the software modules stored in the model training device 455 of the memory 450 may include:

[0186] An acquisition module 4551 is used to acquire training data and a preset speech recognition model;

[0187] A pre-training module 4552 is used to pre-train the preset speech recognition model using the training data to obtain a pre-trained speech recognition model;

[0188] An adding module 4552 is used to add a routing selection module in the first type of encoding layer of the pre-trained speech recognition model to obtain a speech recognition model to be trained;

[0189] The training module 4554 is also used to use the training data to train the speech recognition model to be trained to obtain a speech recognition model.

[0190] In some embodiments, the training data includes training voice data and a text index corresponding to the training voice data, and the preset voice recognition model includes a first type encoding layer, a second type encoding layer and a decoding layer; the pre-training module is also used to: pre-process the training voice data to obtain training voice features; the first type encoding layer and the second type encoding layer in the preset voice recognition model encode the training voice features in turn to obtain a training encoding result; determine a first encoding loss value based on the training encoding result and the text index; the decoding layer decodes the training encoding result to obtain a predicted recognition result; determine a first decoding loss value based on the predicted recognition result and the text index, and determine a first model loss value based on the first encoding loss value and the first decoding loss value, and adjust the model parameters of the preset voice recognition model based on the first model loss value until the end condition is reached to obtain the pre-trained voice recognition model.

[0191] In some embodiments, the pre-training module is also used for: the routing selection module in the first type of encoding layer determines the attention dimension of the training speech feature in the first type of encoding layer; determines the dimension selection loss value corresponding to the routing selection module, and back-propagates the dimension selection loss value corresponding to the routing selection module to the routing selection module to adjust the parameters of the routing selection module; the first type of encoding layer encodes the training speech feature based on the attention dimension to obtain a third encoding result; determines a second encoding loss value based on the encoding result and the text index; the decoding layer decodes the encoding result to obtain a second predicted recognition result; determines a second decoding loss value based on the second predicted recognition result and the text index, and determines a second model loss value based on the second encoding loss value and the second decoding loss value, and adjusts the model parameters of the pre-trained speech recognition model based on the second model loss value.

[0192] In some embodiments, the pre-training module is also used for: the pre-trained speech recognition model performs prediction processing on the training speech features to obtain the dimension prediction results of the routing selection module in the first type of coding layer; based on the dimension prediction results, determining the attention dimension of the training speech features in the first type of coding layer.

[0193] In some embodiments, the training module is also used to: obtain dimension label information corresponding to the training speech features; normalize the dimension prediction results to obtain normalized dimension prediction results; obtain a preset dimension selection loss function; use the normalized dimension prediction results and the dimension label information as input data of the dimension selection loss function to calculate the loss value, and obtain the dimension selection loss value corresponding to the routing selection module.

[0194] The following is a description of an exemplary structure of a speech recognition device provided in an embodiment of the present application implemented as a software module. In some embodiments, the software module stored in the speech recognition device in the memory 450 may include:

[0195] A processing module, used for performing feature extraction processing on the speech frame to be recognized of the speech data to obtain speech features;

[0196] A determination module, used for a routing selection module of a first type of coding layer in a speech recognition model, to determine an attention dimension of the speech feature in the first type of coding layer;

[0197] An encoding module, configured for the first type of encoding layer to encode the speech feature based on the attention dimension to obtain a first encoding result;

[0198] A decoding module is used for the decoding layer in the speech recognition model to decode the first encoding result to obtain the speech recognition result of the speech data to be recognized.

[0199] In some embodiments, the number of the first type of coding layers is M, and the speech recognition model also includes N second type of coding layers, the M first type of coding layers are divided into a first part and a second part, the first part includes P first type of coding layers connected in series, and the second part includes MP first type of coding layers connected in series; the first part, the N second type of coding layers and the second part are serially connected in sequence; wherein M and N are both integers greater than 1, and P is a positive integer less than M; the encoding module is also used for: each first type of coding layer in the first part encodes the speech feature based on the corresponding attention dimension to obtain a first intermediate encoding result; each second type of coding layer in the N second type of coding layers encodes the first intermediate encoding result to obtain a second intermediate encoding result; each first type of coding layer in the second part encodes the second intermediate encoding result based on the corresponding attention dimension to obtain a first encoding result.

[0200] The present application embodiment provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will be caused to execute the model training method or speech recognition method provided in the present application embodiment, for example, Figure 4A The model training method shown and Figure 5 The speech recognition method shown.

[0201] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer executable instruction from the computer-readable storage medium, and the processor executes the computer executable instruction, so that the electronic device executes the model training method or the speech recognition method described in the embodiment of the present application.

[0202] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.

[0203] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0204] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0205] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0206] In summary, through the embodiments of the present application, the efficiency of speech recognition can be improved while ensuring the accuracy of speech recognition.

[0207] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A model training method, characterized in that: The method comprises: Obtain training data and preset speech recognition models; Pre-training the preset speech recognition model using the training data to obtain a pre-trained speech recognition model; Adding a routing selection module to the first type of encoding layer of the pre-trained speech recognition model to obtain a speech recognition model to be trained; The speech recognition model to be trained is trained using the training data to obtain a speech recognition model.

2. The method according to claim 1, characterized in that The training data includes training speech data and a text index corresponding to the training speech data, and the preset speech recognition model includes a first type encoding layer, a second type encoding layer and a decoding layer; The pre-training of the preset speech recognition model using the training data to obtain the pre-trained speech recognition model includes: Preprocessing the training speech data to obtain training speech features; The first type of coding layer and the second type of coding layer in the preset speech recognition model sequentially encode the training speech features to obtain a training coding result; Determine a first encoding loss value based on the training encoding result and the text index; The decoding layer decodes the training encoding result to obtain a prediction recognition result; A first decoding loss value is determined based on the predicted recognition result and the text index, and a first model loss value is determined based on the first encoding loss value and the first decoding loss value, and model parameters of the preset speech recognition model are adjusted based on the first model loss value until the end condition is reached, thereby obtaining the pre-trained speech recognition model.

3. The method according to claim 2, characterized in that The step of training the speech recognition model to be trained by using the training data to obtain the speech recognition model includes: The routing selection module in the first type of encoding layer determines the attention dimension of the training speech feature in the first type of encoding layer; Determine a dimension selection loss value corresponding to the routing selection module, and back-propagate the dimension selection loss value corresponding to the routing selection module to the routing selection module to adjust parameters of the routing selection module; The first type of encoding layer encodes the training speech features based on the attention dimension; Determine a second encoding loss value based on the encoding process result and the text index; The decoding layer performs decoding processing on the encoding processing result to obtain a second prediction recognition result; A second decoding loss value is determined based on the second predicted recognition result and the text index, a second model loss value is determined based on the second encoding loss value and the second decoding loss value, and model parameters of the pre-trained speech recognition model are adjusted based on the second model loss value.

4. The method according to claim 3, characterized in that The routing selection module in the first type of encoding layer determines the attention dimension of the training speech feature in the first type of encoding layer, including: The pre-trained speech recognition model performs prediction processing on the training speech features to obtain a dimension prediction result of the routing selection module in the first type of coding layer; The attention dimension of the training speech feature in the first type of encoding layer is determined based on the dimension prediction result.

5. The method according to claim 4, characterized in that The determining the dimension selection loss value corresponding to the routing selection module includes: Obtaining dimension label information corresponding to the training speech feature; Normalizing the dimension prediction result to obtain a normalized dimension prediction result; Get the preset dimension selection loss function; The normalized dimension prediction result and the dimension label information are used as input data of the dimension selection loss function to calculate the loss value, so as to obtain the dimension selection loss value corresponding to the routing selection module.

6. A speech recognition method, characterized in that: The method comprises: Performing feature extraction processing on the speech frame to be recognized of the speech data to be recognized, to obtain speech features; A routing selection module of a first type of coding layer in a speech recognition model determines an attention dimension of the speech feature in the first type of coding layer; the speech recognition model is obtained by the model training method according to any one of claims 1 to 5; The first type of encoding layer encodes the speech feature based on the attention dimension to obtain a first encoding result; The decoding layer in the speech recognition model decodes the first encoding result to obtain a speech recognition result of the speech data to be recognized.

7. The method according to claim 6, characterized in that The number of the first type of coding layers is M, the speech recognition model further includes N second type of coding layers, the M first type of coding layers are divided into a first part and a second part, the first part includes P first type of coding layers connected in series, and the second part includes MP first type of coding layers connected in series; the first part, the N second type of coding layers and the second part are connected in series in sequence; wherein M and N are both integers greater than 1, and P is a positive integer less than M; The first type of encoding layer encodes the speech feature based on the attention dimension to obtain a first encoding result, including: Each first-type encoding layer in the first part encodes the speech feature based on the corresponding attention dimension to obtain a first intermediate encoding result; Each of the N second-type coding layers performs coding processing on the first intermediate coding result to obtain a second intermediate coding result; Each first-category encoding layer in the second part encodes the second intermediate encoding result based on the corresponding attention dimension to obtain a first encoding result.

8. A model training device, comprising: An acquisition module, used to acquire training data and a preset speech recognition model; A pre-training module, used to pre-train the preset speech recognition model using the training data to obtain a pre-trained speech recognition model; An adding module, used for adding a routing selection module in the first type of encoding layer of the pre-trained speech recognition model to obtain a speech recognition model to be trained; The training module is used to train the speech recognition model to be trained using the training data to obtain a speech recognition model.

9. A speech recognition device, characterized in that: The device comprises: A processing module, used for performing feature extraction processing on the speech frame to be recognized of the speech data to obtain speech features; A determination module, a routing selection module for a first type of coding layer in a speech recognition model, determining an attention dimension of the speech feature in the first type of coding layer; the speech recognition model is obtained by the model training method according to any one of claims 1 to 5; An encoding module, configured for the first type of encoding layer to encode the speech feature based on the attention dimension to obtain a first encoding result; A decoding module is used for the decoding layer in the speech recognition model to decode the first encoding result to obtain the speech recognition result of the speech data to be recognized.

10. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions; A processor, used to implement the model training method described in any one of claims 1 to 5, or the speech recognition method described in any one of claims 6 and 7 when executing computer executable instructions stored in the memory.

11. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the model training method described in any one of claims 1 to 5, or the speech recognition method described in any one of claims 6 and 7 is implemented.

12. A computer program product, comprising a computer program or computer executable instructions, which, when executed by a processor, implements the model training method described in any one of claims 1 to 5, or the speech recognition method described in any one of claims 6 and 7.

Citation Information

Cited By

  • Cross-language speech translation method, device and equipment based on AI large model

    CN119378571A

  • Cross-language speech translation method, device and equipment based on AI big model

    CN119378571B

  • Speech recognition method and system applied to classroom evaluation

    CN119380703A