Speech synthesis method, system, device and storage medium
By improving the multi-head self-attention mechanism of the Transformer model and replacing the generator of the HiFi-GAN model, the problem of insufficient computational efficiency of HiFi-GAN in real-time speech synthesis is solved, and a more efficient speech synthesis method is achieved.
Patent Information
- Application Number
- CN202211010812.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-23
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-08-23
AI Technical Summary
The existing HiFi-GAN speech synthesis model has high requirements for real-time speech synthesis, but its computational efficiency and synthesis speed are insufficient to meet actual needs.
By improving the multi-head self-attention mechanism of the Transformer model, using a sliding window or expanding the sliding window to reduce computational complexity, and replacing the generator in the HiFi-GAN model with the improved Transformer model to form a target vocoder to improve speech synthesis efficiency.
It achieves lower computational complexity and faster calculation speed, reduces the number of model parameters, and improves the real-time performance and efficiency of speech synthesis.
Smart Images

Figure CN115394284B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of speech synthesis technology, and in particular to a speech synthesis method, system, device and storage medium. Background Art
[0002] Speech Synthesis technology refers to the technology that converts any text into fluent speech through computer analysis. It is an important channel for human-computer interaction and plays an important role in many scenarios such as intelligent customer service, virtual anchors, virtual singers, and novel broadcasting. The speech synthesis system generally includes three modules: text front-end module, acoustic model module and vocoder. The text front-end module is used to convert the original text into characters or phonemes, and the acoustic model module is used to convert characters or phonemes into acoustic features, such as linear spectrogram, Mel spectrogram, LPC (linear predictive coding), etc. The vocoder converts the acoustic features into speech waveforms.
[0003] The best existing vocoder model is HiFi-GAN, which is an efficient encoding and decoding model based on GAN (Generative Adversarial Nets). HiFi-GAN includes a generator and two discriminators. However, in some situations where real-time speech synthesis is required, the computational efficiency and synthesis speed of HiFi-GAN still cannot meet the requirements in these situations. Therefore, a speech synthesis method with low computational complexity and fast synthesis speed is urgently needed. Summary of the invention
[0004] The present invention provides a speech synthesis method, system, device and storage medium, the main purpose of which is to reduce the computational complexity of a target vocoder and effectively improve the speech synthesis efficiency.
[0005] In a first aspect, an embodiment of the present invention provides a speech synthesis method, comprising:
[0006] Obtaining acoustic features of the text to be synthesized;
[0007] The acoustic features of the text to be synthesized are input into a trained target vocoder to obtain a target speech, wherein the target vocoder model is a neural network model, and the target vocoder model is obtained by replacing the generator in the HiFi-GAN model with an improved Transformer model, and the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window.
[0008] Preferably, the sliding window indicates that the size of the window is fixed, and the extended sliding window indicates that the size of the sliding window is dynamic and gradually increases.
[0009] Preferably, the target vocoder includes the improved Transformer model and two discriminators, and before inputting the acoustic features of the text to be synthesized into the trained target vocoder, the step further includes:
[0010] The improved Transformer model and the two discriminators are trained using sample texts and standard speech corresponding to the sample texts to obtain a trained target vocoder.
[0011] Preferably, the improved Transformer model includes a first linear layer, an improved network layer with multi-head self-attention as the core, several block layers and a second linear layer, wherein the fast layer includes an upsampling layer and several improved network layers with multi-head self-attention as the core.
[0012] Preferably, the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window, and is obtained by the following steps:
[0013] The multi-head self-attention mechanism is improved by using the sliding window or the enlarged sliding window to obtain the improved network layer with multi-head self-attention as the core, so as to further obtain the improved Transformer model.
[0014] Preferably, the multi-head self-attention mechanism is improved by the sliding window, and is calculated by the following formula:
[0015]
[0016] Among them, Attention(Q,K,V)1 represents the output of the improved multi-head self-attention mechanism through the sliding window, Q, K and V represent the input vector, d k represents the dimension of K, SW(K) represents a sliding window on K, and SW(V) represents a sliding window on V.
[0017] Preferably, the multi-head self-attention mechanism is improved by expanding the sliding window, and is calculated by the following formula:
[0018]
[0019] Wherein, Attention(Q,K,V)2 represents the output after the multi-head self-attention mechanism is improved by the extended sliding window, Q, K and V represent the input vector, d k represents the dimension of K, and B represents the position deviation parameter.
[0020] In a second aspect, an embodiment of the present invention provides a speech synthesis system, including:
[0021] Acoustic feature module, used to obtain the acoustic features of the text to be synthesized;
[0022] The speech synthesis module is used to input the acoustic features of the text to be synthesized into a trained target vocoder to obtain a target speech, wherein the target vocoder model is a neural network model, and the target vocoder model is obtained by replacing the generator in the HiFi-GAN model with an improved Transformer model, and the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window.
[0023] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned speech synthesis method when executing the computer program.
[0024] In a fourth aspect, an embodiment of the present invention provides a computer storage medium, wherein the computer storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned speech synthesis method are implemented.
[0025] The embodiment of the present invention proposes a speech synthesis method, system, device and storage medium, which improves the multi-head self-attention mechanism in the Transformer model by sliding a window or expanding the sliding window to obtain an improved Transformer model, which can reduce the complexity of the model and improve the model performance; then, by replacing the generator in the HiFi-GAN model with the improved Transformer model, a target vocoder is obtained, so that the speech synthesis method can combine the advantages of the Transformer model and the HiFi-GAN model at the same time. Compared with the traditional HiFi-GAN model, the speech synthesis method has lower computational complexity, occupies less space, and has faster calculation speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 An application scenario diagram of a speech synthesis method provided by an embodiment of the present invention;
[0027] Figure 2A flowchart of a speech synthesis method provided by an embodiment of the present invention;
[0028] Figure 3 It is a schematic diagram of the structure of the improved Transformer model in an embodiment of the present invention;
[0029] Figure 4 A schematic diagram of the structure of a speech synthesis system provided by an embodiment of the present invention;
[0030] Figure 5 The present invention is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention.
[0031] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0032] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0033] Figure 1 An application scenario diagram of a speech synthesis method provided by an embodiment of the present invention, such as Figure 1 As shown, the user inputs the text to be synthesized on the client. After the client obtains the text to be synthesized, it performs feature extraction on the text to be synthesized, extracts the acoustic features of the text to be synthesized, and sends the acoustic features of the text to be synthesized to the server. After the server receives the text to be synthesized, it executes the speech synthesis method to obtain the target speech.
[0034] It should be noted that the server can be implemented by an independent server or a server cluster composed of multiple servers. The client can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc., but is not limited thereto. The client and the server can be connected via Bluetooth, USB (Universal Serial Bus) or other communication connection methods, which is not limited in the embodiments of the present invention.
[0035] The embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Among them, AI (Artificial Intelligence, referred to as artificial intelligence) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0036] The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. Artificial intelligence software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, as well as machine learning and deep learning.
[0037] Figure 2 A flowchart of a speech synthesis method provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the method includes:
[0038] S210, obtaining acoustic features of the text to be synthesized;
[0039] First, the acoustic features of the text to be synthesized are obtained. The text to be synthesized refers to the text characters to be synthesized. The text characters are usually a sentence, including at least one character. When the speech synthesis method is applied to the intelligent customer scenario, the text to be synthesized is the response statement made by the intelligent customer service system according to the user input information. The response statement is converted into a response speech by the speech synthesis method and fed back to the customer; when the speech synthesis method is applied to the virtual singer scenario, the text to be synthesized is the lyrics sung by the virtual singer; when the speech synthesis method is applied to the novel broadcast, news broadcast and other scenarios, the text to be synthesized is the novel text and news text manuscript. The text to be synthesized can be determined according to the actual situation, and the embodiment of the present invention does not specifically limit this.
[0040] Acoustic features represent the physical quantity of the acoustic characteristics of speech, and are also a general term for the acoustic performance of various elements of sound, such as the energy concentration area, resonance peak frequency, resonance peak intensity and bandwidth that represent the timbre, as well as the duration, fundamental frequency, average voice power, etc. that represent the rhythmic characteristics of speech. Common acoustic features include linear spectrogram, Mel spectrum, LPC, etc. The acoustic features in the embodiment of the present invention refer to Mel spectrum. Mel spectrum is invented based on the characteristics of the human auditory system. Human perception of frequency is not linear, and the perception of low-frequency signals is more sensitive than high-frequency signals. For example, people can easily find the difference between 500 and 1000Hz, but it is difficult to find the difference between 7500 and 8000Hz. By applying a nonlinear transformation to the frequency axis of the short-time Fourier transform, the frequency range is compressed with a relatively low dimension. Compared with language features and other acoustic features, Mel spectrum can better characterize lower-level audio signals.
[0041] According to the text to be synthesized, the acoustic features of the text to be synthesized are extracted, which can be achieved by the following methods. The first method is to perform text normalization and G2P (Grapheme-to-Phoneme, word to phoneme) processing on the text to be synthesized to obtain the phonemes corresponding to the text to be synthesized; the text to be synthesized is subjected to text normalization, that is, the expressions in the text to be synthesized are normalized and disambiguated, so as to facilitate the subsequent processing flow of the text to be synthesized, for example, 62% is converted to 62%, and the number 27149 is converted to the number 27149; after being regularized, the text to be synthesized will be converted into phonemes to obtain a phoneme string (phoneme is the smallest unit that constitutes a syllable). Then the phonemes are input into the acoustic model to obtain the acoustic features of the text to be synthesized. The task of the acoustic model is to restore the timbre information, rhythm information and emotional information contained in the speech, etc. Common acoustic models include Tacotron, Tacotron2, etc., which can be determined according to actual conditions, and the embodiment of the present invention does not make specific limitations on this. The second method is an acoustic feature extraction method based on a neural network. First, a sample text and a Mel spectrum sample are obtained, and then the sample text is filtered to remove useless characters in the sample text, such as special characters, and Arabic characters are converted into corresponding text words, and Chinese text characters are converted into pinyin characters or phoneme characters to obtain a sample text in a standard format. Then, the Mel spectrum sample is subjected to noise reduction and filtering to obtain a clean and neat Mel spectrum sample, and the pre-processed sample text and Mel spectrum sample are aligned, and the aligned data is used as training data. The acoustic feature extraction model is trained using the training data. When the training accuracy reaches the requirement, the training ends and the trained acoustic feature extraction model is obtained; then the text to be synthesized is input into the trained acoustic feature extraction model to obtain the acoustic features of the text to be synthesized. The above two methods are both relatively common methods for obtaining text acoustic features. In specific implementation, they can be selected according to actual conditions, and the embodiments of the present invention do not make specific limitations on this.
[0042] S220, inputting the acoustic features of the text to be synthesized into the trained target vocoder to obtain the target speech, wherein the target vocoder model is a neural network model, and the target vocoder model is obtained by replacing the generator in the HiFi-GAN model with an improved Transformer model, and the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window.
[0043] In the process of converting acoustic features into waveforms, the vocoder needs to solve the "information missing completion problem". Information missing refers to the lack of phase information when the audio waveform is converted into a spectrogram; when the spectrogram is converted into a mel spectrogram, there is information missing caused by frequency domain compression. Assuming that the sampling rate of the audio is 16kHz, that is, 1s of audio has 16,000 sampling points, and one frame of audio has 10ms, then 1s contains 100 frames, each frame has 160 sampling points, and the role of the vocoder is to convert a spectrum frame into 160 sampling points of the audio waveform, so the vocoder generally includes an upsampling module. Based on this, SAN (SelfAttention, self-attention mechanism) is an effective method for modeling natural language and images, but because the computational complexity of SAN grows quadratically relative to the input sequence, when the traditional SAN is applied to waveform generation with a high sampling rate, its computational complexity will be very large. In order to solve this problem, the embodiment of the present invention improves SAN by sliding windows or extending sliding windows. The Transformer model is a neural network model based on the multi-head self-attention mechanism, which is expanded on the basis of SAN. The Transformer model is often used in scenarios such as speech synthesis and speech conversion. Therefore, by improving the multi-head self-attention mechanism in the Transformer model through sliding windows or expanding the sliding windows, an improved Transformer model can be obtained.
[0044] Specifically, in an embodiment of the present invention, the multi-head self-attention mechanism in the Transformer model can be improved through a sliding window to obtain an improved Transformer model. Improving the multi-head self-attention mechanism only through a sliding window can reduce the complexity of the model, thereby reducing the amount of calculation. However, at this time, the receptive field (ReceptiveField) of the model is relatively small, and the network parameters are relatively large, resulting in poor model performance. The receptive field refers to the size of the area on the input image where the pixel points on the feature map (feature map) output by each layer of the convolutional neural network are mapped back to the input image. In layman's terms, the size of a point on the feature map relative to the original image is also the area of the input image that the convolutional neural network feature can see. When the speech synthesis method is applied to scenarios with relatively high requirements for speed and efficiency but not too high requirements for synthesis quality, such as audio book reading and other scenarios, the multi-head self-attention mechanism can be improved only through a sliding window. It is also possible to improve the multi-head self-attention mechanism in the Transformer model by simply extending the sliding window to obtain an improved Transformer model. The multi-head attention mechanism is improved only by extending the sliding window. The extended sliding window can expand the receptive field of the model and improve the model performance under the premise of ensuring the same amount of calculation as the sliding window. Therefore, the model obtained by improving the multi-head self-attention mechanism by extending the sliding window is better than the model obtained by improving the sliding window. When the speech synthesis method is applied in a scenario where the synthesis accuracy is high but the real-time and synthesis speed requirements are not high, such as the scenario of Chinese text to speech in self-media, the multi-head self-attention mechanism in the Transformer model can be improved only by extending the sliding window. In the embodiment of the present invention, two methods for improving the multi-head self-attention mechanism are provided. According to the different requirements of different application scenarios, a suitable improvement method can be selected. In order to facilitate the explanation of the technical solution, the embodiment of the present invention takes the improvement of the multi-head self-attention mechanism by sliding window and extended sliding window as an example.
[0045] After obtaining the improved Transformer model, the HiFi-GAN model is currently the best vocoder model. In order to obtain the target vocoder model in the embodiment of the present invention, the generator in the HiFi-GAN model is replaced with the improved Transformer model to obtain the target vocoder. The main structure of the HiFi-GAN model mainly includes two parts, a generator and a discriminator. The generator uses the Mel spectrum as input to generate audio waveform data. The discriminator is mainly used to determine the degree of difference between the output of the model and the label during the training process of the HiFi-GAN model. Since the improved Transformer model has a good effect in high sampling rate waveform generation, replacing the generator in the HiFi-GAN model with the improved Transformer model can make the target vocoder have lower model complexity, smaller space occupation, and a larger receptive field than the traditional HiFi-GAN model.
[0046] In order to verify the effect of the speech synthesis method proposed in the embodiment of the present invention, the performance of the target vocoder is compared with that of several other vocoders. The comparative tests are all conducted on the LJ-Speech dataset, which contains 13,100 audio clips of a speaker with a total length of about 24 hours. The audio format is 16-bit PCM and the sampling frequency is 22.05 kHz. The original audio spectrogram with 80 bands is used as input, and the FFT size, hop number and window size are 1024, 256 and 1024 respectively.
[0047] For model configuration: First, use a linear layer to transform the 80-band Mel spectrum into a hidden representation dimension, and use h int Indicates that the embodiment of the present invention provides one large and one small h int represents the target vocoder model under two configurations, Ours (small) represents h int The target vocoder model when is 128, Ours(big) represents h int The target vocoder model when is 512. The most popular GAN vocoders: HiFi-GAN and MelGAN are used as reference models. HiFi-GANV1 and HiFi-GANV2 are two different HiFi-GAN models proposed in the prior art.
[0048] In the embodiment of the present invention, MOS (Mean Opinion Score) is used to evaluate the quality of synthesized speech. 20 speech segments are randomly selected from the test set, and the target vocoder proposed in the embodiment of the present invention is used for speech synthesis and other vocoders are used for speech synthesis. Each speech segment is synthesized 20 times to obtain the average synthesis speed. When calculating the synthesis speed, the time overhead of transmitting data between the CPU and the GPU needs to be excluded. Table 1 is a comparison table of model size and comprehensive speed in different speech synthesis methods in the embodiment of the present invention, and Table 2 is a comparison table of model MOS in different speech synthesis methods in the embodiment of the present invention. It can be concluded from Tables 1 and 2 that the target vocoder with a larger first hidden dimension proposed in the embodiment of the present invention achieves the same MOS ranking as the best HiFi-GANV1 model while requiring fewer parameters. The target vocoder with a smaller first hidden dimension proposed in the embodiment of the present invention has a model parameter of 0.57M, and the speed of synthesizing 22.05kHZ high-fidelity speech is 113 times faster than real time, which is highly competitive compared with HiFi-GANV2 and MelGAN.
[0049] Table 1
[0050]
[0051] Table 2
[0052]
[0053] In summary, the embodiment of the present invention proposes a speech synthesis method, which improves the multi-head self-attention mechanism in the Transformer model by sliding the window or expanding the sliding window to obtain an improved Transformer model, which can not only reduce the complexity of the model, but also expand the receptive field of the model and improve the model performance; then, by replacing the generator in the HiFi-GAN model with the improved Transformer model, a target vocoder is obtained, so that the speech synthesis method can combine the advantages of the improved Transformer model and the HiFi-GAN model. Compared with the traditional HiFi-GAN model, the speech synthesis method has lower computational complexity, occupies less space, and has faster calculation speed.
[0054] Based on the above embodiment, preferably, the sliding window represents that the size of the window is fixed, and the extended sliding window represents that the size of the sliding window is dynamic and gradually increases.
[0055] In the embodiment of the present invention, a sliding window or an extended sliding window is used to reduce the amount of data calculation in the multi-head self-attention mechanism. For the multi-head self-attention mechanism in the prior art, it is necessary to calculate the interaction between each data in the input sequence and other data, which leads to a large amount of calculation for the multi-head self-attention mechanism. In order to reduce the amount of calculation, it is necessary to select an appropriate amount of data to calculate the interaction. Therefore, the range of other data is determined by a sliding window pair. Other data can be designated as data within the window, and there is no need to calculate the interaction for data outside the window, thereby effectively reducing the amount of calculation for the multi-head self-attention mechanism. Since the window size of the sliding window is constant during each data calculation process, although the amount of calculation is reduced, it also makes the attention overly focused on the data within the window. The receptive field of the model after improving the multi-head self-attention mechanism using a sliding window is small. In order to expand the receptive field, the extended sliding window is used to improve the multi-head self-attention mechanism. The extended sliding window also limits other data within the window without calculating the interaction with the data outside the window. Therefore, the computational complexity of the extended sliding window is the same as that of the sliding window. Unlike the sliding window, the size of the extended sliding window changes in each aggregation, and becomes larger and larger until the entire sequence is covered. In each attention calculation, the interaction calculation between the data and other data also becomes larger, avoiding excessive concentration of attention, thereby increasing the receptive field of the model.
[0056] Based on the above embodiment, preferably, the target vocoder includes the improved Transformer model and two discriminators, and before inputting the acoustic features of the text to be synthesized into the trained target vocoder, the step further includes:
[0057] The improved Transformer model and the two discriminators are trained using sample texts and standard speech corresponding to the sample texts to obtain a trained target vocoder.
[0058] Specifically, in the embodiment of the present invention, the target vocoder includes an improved Transformer model and two discriminators. Before using the target vocoder for reasoning, the target vocoder needs to be trained first. During the training, both the improved Transformer model and the two discriminators need to participate. It should be noted that the target vocoder in the embodiment of the present invention belongs to a type of neural network. The training process of the target vocoder can be divided into three steps: defining the output result of the forward propagation; defining the loss function and the algorithm for back-propagation optimization; finally generating a conversation and repeatedly running the back-propagation optimization algorithm with the sample text as input and the standard speech corresponding to the sample text as the label.
[0059] Among them, neurons are the smallest units that constitute neural networks. A neuron can have multiple inputs and one output. The input of each neuron can be the output of other neurons or the input of the entire neural network. The output of the neural network is the weighted sum of the inputs of all neurons. The weights of different inputs are the neuron parameters. The optimization process of the neural network is the process of optimizing the values of neuron parameters. The effect of the neural network and the optimization goal are defined by the loss function. The loss function gives the calculation formula for the gap between the output result of the neural network and the true label. Supervised learning is a way of training neural networks. Its idea is that on the labeled data set with known answers, the results given by the neural network should be as close to the true answer (i.e., label) as possible. The training data is fitted by adjusting the parameters in the neural network so that the neural network can provide prediction capabilities for unknown samples. The back propagation algorithm implements an iterative process. At the beginning of each iteration, a part of the training data is taken first, and the prediction results of the neural network are obtained through the forward propagation algorithm. Because the training data have correct answers, the gap between the predicted results and the correct answers can be calculated. Based on this gap, the back propagation algorithm will update the values of the neural network parameters accordingly to make it closer to the true answer.
[0060] After completing the training process through the above method, the trained target vocoder can be used for inference. When performing inference, the target speech can be obtained by simply inputting the acoustic features of the text to be synthesized into the improved Transformer model after training. The role of the discriminator is to determine the difference between the inference speech generated during the training process and the standard speech, so as to adjust the model parameters of the target vocoder. Therefore, the discriminator does not participate in the inference process.
[0061] Based on the above embodiments, preferably, the improved Transformer model includes a first linear layer, an improved network layer with multi-head self-attention as the core, several block layers and a second linear layer, wherein the fast layer includes an upsampling layer and several improved network layers with multi-head self-attention as the core.
[0062] Figure 3 is a schematic diagram of the structure of the improved Transformer model in the embodiment of the present invention, such as Figure 3As shown, the improved Transformer model in the embodiment of the present invention consists of a first linear layer, a network layer with improved multi-head self-attention as the core, N identical blocks and a second linear layer. The Mel spectrum first passes through the first linear layer and the network layer with improved multi-head self-attention as the core, and then is sent to N identical block layers. Each block contains an upsampling layer and k network layers with improved multi-head self-attention as the core. Finally, the hidden vector is projected to the waveform output using the second linear layer. The upsampling layer is implemented by a stack of rank-transformed convolutional layers. Each improved network layer with multi-head self-attention as the core consists of a multi-head self-attention layer and a position feedforward linear layer, and each module is followed by a residual connection and a linear layer.
[0063] On the basis of the above embodiment, preferably, the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window, and is obtained by the following steps:
[0064] The multi-head self-attention mechanism is improved by sliding the window or expanding the sliding window to obtain the improved network layer with multi-head self-attention as the core, so as to further obtain the improved Transformer model.
[0065] The multi-head self-attention mechanism consists of multiple self-attention heads working in parallel. Each attention head applies the attention mechanism to its own input. Assuming X is the input sequence, the formula for calculating the multi-head self-attention mechanism is as follows:
[0066]
[0067] Y=Concat(Head 1 ,…,Head h )W O +X, (2)
[0068] Among them, W Q , W K , W V , W O represents the linear transformation of all shared positions, Y is the output sequence, and is the same size as X. The scoring function is expressed as follows:
[0069]
[0070] Since the computational complexity of the traditional SAN is very large when it is applied to waveform generation with a high sampling rate, the embodiment of the present invention proposes the following solution to this problem:
[0071] As mentioned above, the computational complexity of traditional SAN is quadratic relative to the sequence length, so it is less efficient when modeling long sequences. In order to reduce the computational complexity, the range of computational attention is limited to a sliding window of fixed size. Assuming w is the window size, the complexity of window-based self-attention increases from O(n 2 ) is reduced to O(n,w), which is linearly related to the window size. It is calculated by the following formula:
[0072]
[0073] Among them, Attention(Q,K,V)1 represents the output of the improved multi-head self-attention mechanism through the sliding window, Q, K and V represent the input vector, d k represents the dimension of K, SW(K) represents a sliding window on K, and SW(V) represents a sliding window on V.
[0074] In addition, the extended sliding window refers to increasing the size of the window on the basis of the sliding window. The sampling rate of audio data is usually between 8kHZ (telephone channel) and 48kHZ (high-fidelity audio). When applied to speech synthesis scenarios, it is usually necessary to generate longer series, usually millions of samples instead of dozens of words. For neural networks, learning long-term relationships is a considerable challenge. The above-mentioned use of sliding windows to calculate attention, the size of the receptive field is limited by the window size, making the receptive field of the model smaller. To address this problem, the embodiment of the present invention uses an extended sliding window to expand the receptive field, thereby increasing the receptive field. The extended sliding window is used to run SAN to increase the receptive field at a constant scale factor without increasing the computational cost.
[0075] When implementing the expanded sliding window, since the attention mechanism is position insensitive, in order to utilize the order information of the sequence, it is necessary to inject some position information into the sequence when calculating the self-attention. This is achieved by adding a position deviation to each attention head, which is calculated by the following formula:
[0076]
[0077] Wherein, Attention(Q,K,V)2 represents the output after the multi-head self-attention mechanism is improved by the extended sliding window, Q, K and V represent the input vector, d k represents the dimension of K, and B represents the position deviation parameter.
[0078] Table 3
[0079]
[0080] Table 3 is a comparison table of the complexity and receptive field of three different attention mechanisms provided in an embodiment of the present invention. As shown in Table 3, n in the table represents the sequence length, and d represents the extension parameter. It can be seen from the table that the complexity of the self-attention mechanism improved by the sliding window and the self-attention mechanism improved by the extended sliding window are the same. Compared with the original self-attention mechanism, their complexity is much lower, and the receptive field of the extended sliding window is n times that of the sliding window. The extended sliding window can be used to expand the receptive field while keeping the complexity unchanged.
[0081] Figure 4 A schematic diagram of the structure of a speech synthesis system provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the system includes an acoustic feature module 410 and a speech synthesis module 420, wherein:
[0082] The acoustic feature module 410 is used to obtain the acoustic features of the text to be synthesized;
[0083] The speech synthesis module 420 is used to input the acoustic features of the text to be synthesized into the trained target vocoder to obtain the target speech, wherein the target vocoder model is a neural network model, and the target vocoder model is obtained by replacing the generator in the HiFi-GAN model with an improved Transformer model, and the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window.
[0084] Based on the above embodiment, preferably, the sliding window represents that the size of the window is fixed, and the extended sliding window represents that the size of the sliding window is dynamic and gradually increases.
[0085] Based on the above embodiment, preferably, the target vocoder includes the improved Transformer model and two discriminators, and the speech synthesis system further includes a training module, wherein:
[0086] The training module is used to train the improved Transformer model and the two discriminators through sample text and the standard speech corresponding to the sample text to obtain the trained improved Transformer model; and use the trained improved Transformer model as the trained target vocoder.
[0087] Based on the above embodiments, preferably, the improved Transformer model includes a first linear layer, an improved network layer with multi-head self-attention as the core, several block layers and a second linear layer, wherein the fast layer includes an upsampling layer and several improved network layers with multi-head self-attention as the core.
[0088] Based on the above embodiment, preferably, the speech synthesis module includes an improvement unit, wherein:
[0089] The improvement unit is used to improve the multi-head self-attention mechanism by sliding the window or expanding the sliding window to obtain the improved network layer with multi-head self-attention as the core, so as to further obtain the improved Transformer model.
[0090] Based on the above embodiment, preferably, the improvement unit is implemented by the following formula:
[0091]
[0092] Among them, Attention(Q,K,V)1 represents the output of the improved multi-head self-attention mechanism through the sliding window, Q, K and V represent the input vector, d k represents the dimension of K, SW(K) represents a sliding window on K, and SW(V) represents a sliding window on V.
[0093] Based on the above embodiment, preferably, the improvement unit is implemented by the following formula:
[0094]
[0095] Wherein, Attention(Q,K,V)2 represents the output after the multi-head self-attention mechanism is improved by the extended sliding window, Q, K and V represent the input vector, d k represents the dimension of K, and B represents the position deviation parameter.
[0096] Each module in the above speech synthesis system can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0097] Figure 5 FIG. 1 is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 5As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a computer storage medium and an internal memory. The computer storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the computer storage medium. The database of the computer device is used to store data generated or obtained during the execution of the speech synthesis method, such as the text to be synthesized and acoustic features. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a speech synthesis method is implemented.
[0098] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the speech synthesis method in the above embodiment when executing the computer program. Alternatively, the processor implements the functions of each module / unit in the embodiment of the speech synthesis system when executing the computer program.
[0099] In one embodiment, a computer storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the speech synthesis method in the above embodiment are implemented. Alternatively, when the computer program is executed by a processor, the functions of each module / unit in the above embodiment of the speech synthesis system are implemented.
[0100] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0101] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0102] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A speech synthesis method, characterized in that: include: Obtaining acoustic features of the text to be synthesized; The acoustic features of the text to be synthesized are input into a trained target vocoder to obtain a target speech, wherein the target vocoder model is a neural network model, and the target vocoder model is obtained by replacing the generator in the HiFi-GAN model with an improved Transformer model, and the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window.
2. The speech synthesis method according to claim 1, characterized in that: The sliding window indicates that the size of the window is fixed, and the enlarged sliding window indicates that the size of the sliding window is dynamic and gradually increases.
3. The speech synthesis method according to claim 1, characterized in that: The target vocoder includes the improved Transformer model and two discriminators, and before inputting the acoustic features of the text to be synthesized into the trained target vocoder, the method further includes: The improved Transformer model and the two discriminators are trained using sample texts and standard speech corresponding to the sample texts to obtain a trained target vocoder.
4. The speech synthesis method according to claim 1, characterized in that: The improved Transformer model includes a first linear layer, an improved network layer with multi-head self-attention as the core, several block layers and a second linear layer, wherein the block layer includes an upsampling layer and several improved network layers with multi-head self-attention as the core.
5. The speech synthesis method according to claim 1, characterized in that: The improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window, and is obtained by the following steps: The multi-head self-attention mechanism is improved by using the sliding window or the enlarged sliding window to obtain an improved network layer with multi-head self-attention as the core, so as to further obtain the improved Transformer model.
6. The speech synthesis method according to claim 5, characterized in that: The multi-head self-attention mechanism is improved by the sliding window, and is calculated by the following formula: Among them, Attention(Q,K,V)1 represents the output of the improved multi-head self-attention mechanism through the sliding window, Q, K and V represent the input vector, d k represents the dimension of K, SW(K) represents a sliding window on K, and SW(V) represents a sliding window on V.
7. The speech synthesis method according to claim 5, characterized in that: The multi-head self-attention mechanism is improved by expanding the sliding window, and is calculated by the following formula: Wherein, Attention(Q,K,V)2 represents the output of the improved multi-head self-attention mechanism by the enlarged sliding window, Q, K and V represent the input vector, d k represents the dimension of K, and B represents the position deviation parameter.
8. A speech synthesis system, characterized in that: include: Acoustic feature module, used to obtain the acoustic features of the text to be synthesized; The speech synthesis module is used to input the acoustic features of the text to be synthesized into a trained target vocoder to obtain a target speech, wherein the target vocoder model is a neural network model, and the target vocoder model is obtained by replacing the generator in the HiFi-GAN model with an improved Transformer model, and the improved Transformer model is obtained by improving the multi-head self-attention mechanism in the Transformer model by sliding the window or enlarging the sliding window.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the speech synthesis method according to any one of claims 1 to 7 are implemented.
10. A computer storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the speech synthesis method according to any one of claims 1 to 7 are implemented.
