Speech synthesis method and device, terminal equipment and storage medium
By setting a storage space threshold during the speech synthesis process to control the generation of Mel spectrum and audio data, and by using acoustic feature models and vocoders to efficiently generate speech data, the problem of resource waste in speech synthesis technology is solved, and a balance between real-time performance and resource conservation is achieved.
Patent Information
- Application Number
- CN202410545272.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2024-09-20
AI Technical Summary
Existing speech synthesis technologies, while ensuring real-time performance, result in a waste of storage and computing resources.
By setting a data volume threshold in the preset storage space, the generation steps of Mel spectrum and audio data are controlled, and the corresponding conversion is only performed when the storage space is not full. The acoustic feature model and vocoder are used to efficiently generate speech data.
While ensuring the real-time performance of speech synthesis, it reduces the consumption of storage and computing resources, avoids data accumulation, and improves resource utilization efficiency.
Smart Images

Figure CN118675498A
Abstract
Description
Technical Field
[0001] The present application relates to the field of speech processing technology, and in particular to a speech synthesis method, apparatus, terminal device and storage medium. Background Art
[0002] Speech synthesis refers to the process of converting input text into playable audio data. With the rapid development of speech synthesis technology, the technology of speech synthesis through neural networks has gradually been widely used.
[0003] Speech synthesis based on neural networks can produce more natural sounds, but it also requires more storage resources and computing resources. In the current technical solutions, only the real-time nature of speech synthesis is considered, so the storage resources and computing resources are continuously increased for speech synthesis, which will cause a waste of storage resources and computing resources.
[0004] Therefore, how to reduce the usage of storage resources and computing resources while ensuring the real-time performance of speech synthesis is a technical problem that technicians in this field currently need to solve. Summary of the invention
[0005] The purpose of the present application is to provide a speech synthesis method, apparatus, terminal device and computer-readable storage medium, which can reduce the occupation of storage resources and computing resources while ensuring the real-time performance of speech synthesis.
[0006] In a first aspect, the present application provides a speech synthesis method. The method comprises:
[0007] Acquire a text to be synthesized, and perform word segmentation processing on the text to be synthesized to obtain word segments to be synthesized and phrases to be synthesized;
[0008] Determine corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase respectively;
[0009] If the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, determining the corresponding Mel spectrum according to the phoneme; otherwise, stopping the step of determining the corresponding Mel spectrum according to the phoneme;
[0010] If the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, the corresponding audio data is determined according to the Mel spectrum; otherwise, the step of determining the corresponding audio data according to the Mel spectrum is stopped.
[0011] In one embodiment, determining the corresponding Mel spectrum according to the phoneme includes:
[0012] The phoneme is input into a pre-trained acoustic feature model, and the corresponding Mel spectrum is determined using the acoustic feature model.
[0013] In one embodiment, determining the corresponding audio data according to the Mel spectrum includes:
[0014] The Mel spectrum is input into a vocoder, and the vocoder is used to convert the Mel spectrum into corresponding audio data.
[0015] In one embodiment, if the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, determining the corresponding Mel spectrum according to the phoneme includes:
[0016] Determine a corresponding first time length according to a first data amount of the Mel spectrum in the first preset storage space;
[0017] If the first time length is less than or equal to a first time length threshold, a corresponding Mel spectrum is determined according to the phoneme.
[0018] In one embodiment, if the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, determining the corresponding audio data according to the Mel spectrum includes:
[0019] Determine a corresponding second time length according to a second data amount of the audio data in the second preset storage space;
[0020] If the second time length is less than or equal to a second time length threshold, the corresponding audio data is determined according to the Mel spectrum.
[0021] In one embodiment, after determining the corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase, the method further includes:
[0022] Get the historical synthesis duration;
[0023] Determine the estimated synthesis time of the word segmentation according to the historical synthesis time and the number of the word segmentation phonemes of the to-be-synthesized word segmentation, and determine the estimated synthesis time of the phrase according to the historical synthesis time and the number of the short phonemes of the to-be-synthesized phrase segmentation;
[0024] According to the relationship between the estimated synthesis time length of the word segment or the estimated synthesis time length of the phrase and the second time length, the corresponding phoneme is determined according to the to-be-synthesized word segment or the to-be-synthesized phrase.
[0025] In one embodiment, obtaining the historical synthesis duration includes:
[0026] Obtain the first historical duration for converting the historical number of historical phonemes into the corresponding historical Mel-spectrograms;
[0027] Obtaining a second historical duration of synthesizing the historical Mel-spectrograms into corresponding historical audio data;
[0028] The historical synthesis duration is determined according to the first historical duration and the second historical duration.
[0029] In a second aspect, the present application also provides a speech synthesis device. The device comprises:
[0030] A word segmentation module is used to obtain the text to be synthesized, and perform word segmentation processing on the text to be synthesized to obtain the word segments to be synthesized and the phrases to be synthesized;
[0031] A phoneme determination module, used to determine corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase respectively;
[0032] a first conversion module, configured to determine a corresponding Mel spectrum according to the phoneme if the first data amount of the Mel spectrum in the first preset storage space is less than or equal to a first quantity threshold; otherwise, stop the step of determining the corresponding Mel spectrum according to the phoneme;
[0033] The second conversion module is used to determine the corresponding audio data according to the Mel spectrum if the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold; otherwise, stop the step of determining the corresponding audio data according to the Mel spectrum.
[0034] In a third aspect, the present application further provides a terminal device, wherein the terminal device comprises 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 method when executing the computer program.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0036] The present application provides a speech synthesis method. When the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, the corresponding Mel spectrum is determined according to the phoneme, otherwise, the step of determining the corresponding Mel spectrum according to the phoneme is stopped; when the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, the corresponding audio data is determined according to the Mel spectrum, otherwise, the step of determining the corresponding audio data according to the Mel spectrum is stopped. Determining whether to continue the synthesis step or stop the synthesis step based on the first data amount of the stored Mel spectrum and the second data amount of the stored audio data can improve the real-time performance of speech synthesis on the one hand; on the other hand, it can avoid data accumulation caused by too much stored Mel spectrum or synthesized audio data, and reduce the occupation of storage resources and processing resources; therefore, the present method can reduce the occupation of storage resources and computing resources on the basis of ensuring the real-time performance of speech synthesis.
[0037] It can be understood that the speech synthesis device, terminal equipment and computer-readable storage medium provided in the embodiments of the present application have the same beneficial effects as the above-mentioned speech synthesis method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 A flowchart of a speech synthesis method provided in an embodiment of the present application;
[0040] Figure 2 A flowchart of another speech synthesis method provided in an embodiment of the present application;
[0041] Figure 3 A schematic diagram of the structure of a speech synthesis device provided in an embodiment of the present application;
[0042] Figure 4 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0044] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0045] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0046] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0047] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0048] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. "Multiple" means "two or more".
[0049] A speech synthesis method provided in an embodiment of the present application can be executed by a processor of a terminal device when running a corresponding computer program.
[0050] Figure 1 This is a flowchart of a speech synthesis method provided in an embodiment of the present application. For the sake of convenience, only the part related to the present embodiment is shown. The method provided in the present embodiment includes the following steps:
[0051] S100: Obtain a text to be synthesized, and perform word segmentation processing on the text to be synthesized to obtain word segments to be synthesized and phrases to be synthesized.
[0052] The text to be synthesized refers to the text that needs to be synthesized into audio data; and the audio data refers to the data that can be played.
[0053] Among them, word segmentation refers to the process of splitting the text to be synthesized into words and phrases; phrases refer to multiple words with pauses. In practical applications, word segmentation can be performed according to semantic segmentation or punctuation marks, or according to forward maximum matching word segmentation, reverse maximum matching word segmentation, statistical word grid word segmentation, and bidirectional maximum matching word segmentation. This embodiment does not limit the specific method of word segmentation. After the text to be synthesized is segmented, the segmented words to be synthesized and the phrases to be synthesized are obtained.
[0054] S200: Determine corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase respectively.
[0055] Among them, phoneme refers to the smallest unit of speech divided according to the natural attributes of speech, and is analyzed according to the pronunciation action in the syllable, and one action constitutes a phoneme. Specifically, for the participle to be synthesized and the phrase to be synthesized, the phoneme corresponding to the participle to be synthesized and the phoneme corresponding to the phrase to be synthesized are determined respectively.
[0056] S300: if the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, determining the corresponding Mel spectrum according to the phoneme; otherwise, stopping the step of determining the corresponding Mel spectrum according to the phoneme.
[0057] The first preset storage space and the second preset storage space refer to preset storage spaces at different locations in the terminal device, which are used to store the converted Mel spectrum and the synthesized audio data respectively. This embodiment does not limit the specific locations of the first preset storage space and the second preset storage space, and does not limit the space sizes of the first preset storage space and the second preset storage space.
[0058] It should be noted that, in this embodiment, after the corresponding Mel spectrum is determined according to the phoneme, the Mel spectrum is stored in the first preset storage space; the Mel spectrum is obtained from the first preset storage space, and the corresponding audio data is determined according to the Mel spectrum, and the Mel spectrum in the first preset storage space is deleted.
[0059] In this step, the Mel spectrum in the first preset storage space is first obtained, and the first data amount of the Mel spectrum is determined; the first data amount is compared with the first quantity threshold; if the first data amount is less than or equal to the first quantity threshold, it means that the Mel spectrum in the first preset storage space has not reached the corresponding first quantity threshold, so the step of determining the corresponding Mel spectrum according to the phoneme continues to be executed; if the first data amount is greater than the first quantity threshold, it means that the Mel spectrum in the first preset storage space has reached the corresponding first quantity threshold, and it is necessary to limit the continued generation of the Mel spectrum, so the step of determining the corresponding Mel spectrum according to the phoneme is stopped.
[0060] S400: If the second data volume of the audio data in the second preset storage space is less than or equal to the second quantity threshold, determining the corresponding audio data according to the Mel spectrum; otherwise, stopping the step of determining the corresponding audio data according to the Mel spectrum.
[0061] It should be noted that, in this embodiment, the corresponding audio data is determined according to the Mel spectrum, and the generated audio data is stored in the second preset storage space; the player reads the audio data from the second preset storage space for playback, and deletes the audio data after reading and playing.
[0062] In this step, the audio data in the second preset storage space is first obtained, and the second data volume of the audio data is determined; the second data volume is compared with the second quantity threshold; if the second data volume is less than or equal to the second quantity threshold, it means that the audio data in the second preset storage space has not yet reached the corresponding second quantity threshold, so the step of determining the corresponding audio data according to the Mel spectrum is continued; if the second data volume is greater than the second quantity threshold, it means that the audio data in the second preset storage space has reached the corresponding second quantity threshold, and it is necessary to limit the continued generation of audio data, so the step of determining the corresponding audio data according to the Mel spectrum is stopped.
[0063] In a speech synthesis method provided by an embodiment of the present application, when the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, the corresponding Mel spectrum is determined according to the phoneme, otherwise, the step of determining the corresponding Mel spectrum according to the phoneme is stopped; when the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, the corresponding audio data is determined according to the Mel spectrum, otherwise, the step of determining the corresponding audio data according to the Mel spectrum is stopped. Determining whether to continue the synthesis step or stop the synthesis step based on the first data amount of the stored Mel spectrum and the second data amount of the stored audio data can improve the real-time performance of speech synthesis on the one hand; on the other hand, it can avoid data accumulation caused by too much stored Mel spectrum or synthesized audio data, and reduce the occupation of storage resources and processing resources; therefore, the method can reduce the occupation of storage resources and computing resources on the basis of ensuring the real-time performance of speech synthesis.
[0064] Based on the above embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, in this embodiment, the corresponding Mel spectrum is determined according to the phoneme, including:
[0065] The phonemes are input into the pre-trained acoustic feature model, and the corresponding Mel spectrum is determined using the acoustic feature model.
[0066] Among them, the acoustic feature model refers to a pre-trained machine learning model that can convert phonemes into corresponding Mel-spectrum models; among them, the acoustic feature models include AFM (Attentional Factorization Machine) model, NFM model (Neural Factorization Machine), FNN model (Factorisation Machine supported Neural Network) and DeepFM model, etc. This embodiment does not limit the specific type of the acoustic feature model.
[0067] In this embodiment, a pre-trained acoustic feature model is obtained, and the phoneme is input into the pre-trained acoustic feature model, and the corresponding Mel spectrum is determined using the acoustic feature model.
[0068] It can be seen that according to the method of this embodiment, the corresponding Mel spectrum can be determined according to the phoneme efficiently and conveniently, thereby improving the efficiency of speech synthesis.
[0069] Based on the above embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, in this embodiment, the corresponding audio data is determined according to the Mel spectrum, including:
[0070] The Mel spectrum is input into the vocoder, and the vocoder is used to convert the Mel spectrum into corresponding audio data.
[0071] Among them, a vocoder (VC) refers to a model system that converts a Mel spectrum into corresponding audio data.
[0072] In this embodiment, after the Mel spectrum is determined and stored in the first preset storage space (BF1), the Mel spectrum is obtained from the first preset storage space, and the Mel spectrum is input into the vocoder, the audio data is synthesized by the vocoder, and the synthesized audio data is stored in the second preset storage space (BF2).
[0073] In this embodiment, the mel spectrum is directly converted into corresponding audio data using a vocoder, so that the audio data can be determined efficiently and conveniently, thereby improving the efficiency of speech synthesis.
[0074] Based on the above embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, in this embodiment, if the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, the corresponding Mel spectrum is determined according to the phoneme, including:
[0075] Determine a corresponding first time length according to a first data amount of the Mel spectrum in the first preset storage space;
[0076] If the first time length is less than or equal to the first time length threshold, a corresponding Mel spectrum is determined according to the phoneme.
[0077] Among them, the first data amount refers to the data amount of the stored Mel spectrum, that is, the data amount of the Mel spectrum stored in the first preset storage space; the first time length refers to the time length corresponding to the first data amount of the Mel spectrum in the first preset storage space, that is, the time required to play the corresponding audio.
[0078] In this embodiment, the first time length is used to represent the first data amount of the Mel spectrum; correspondingly, the first time length threshold is used to represent the time length corresponding to the data amount of the first quantity threshold. The first time length threshold may be a preset multiple of the second time length, specifically, may be twice the second time length; the second time length is the time length corresponding to the second data amount of the audio data in the second preset storage space.
[0079] Specifically, the first data amount of the Mel spectrum can be determined according to the first data length of the Mel spectrum in the first preset storage space, and the first time length can be calculated according to the first data length of the Mel spectrum, the first sampling rate, and the first bit width; the calculation method is as follows:
[0080] T1 = L1 / (s1*bw1);
[0081] Wherein, T1 represents the first time length corresponding to the Mel spectrum; L1 represents the first data length of the Mel spectrum; s1 represents the first sampling rate of the Mel spectrum; and bw1 represents the first bit width of the Mel spectrum.
[0082] In this embodiment, the first time length is compared with the first time length threshold. If the first time length is less than or equal to the first time length threshold, the step of determining the corresponding Mel spectrum according to the phoneme is executed; otherwise, the step of determining the corresponding Mel spectrum according to the phoneme is stopped.
[0083] For example, if the first time length is less than or equal to twice the second time length (T1≤2T2), the corresponding Mel spectrum is determined according to the phoneme; if the first time length is greater than twice the second time length (T1>2T2), the step of determining the corresponding Mel spectrum according to the phoneme is stopped.
[0084] It can be seen that according to the method of this embodiment, it is possible to more accurately determine whether to execute the step of determining the corresponding Mel spectrum according to the phoneme.
[0085] Based on the above embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, in this embodiment, if the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, the corresponding audio data is determined according to the Mel spectrum, including:
[0086] Determine a corresponding second time length according to a second data amount of the audio data in the second preset storage space;
[0087] If the second time length is less than or equal to the second time length threshold, the corresponding audio data is determined according to the Mel spectrum.
[0088] Among them, the second data amount refers to the data amount of stored audio data, that is, the data amount of audio data stored in the second preset storage space; the second time length refers to the time length corresponding to the second data amount of audio data in the second preset storage space, that is, the time required to play the corresponding audio.
[0089] In this embodiment, a second time length is used to represent a second amount of audio data; correspondingly, a second time length threshold is used to represent a time length corresponding to the amount of data of the second amount threshold. The second time length threshold may be a preset multiple of the minimum delay time, specifically, may be twice the minimum delay time.
[0090] Specifically, the first data amount of the audio data can be determined according to the second data length of the audio data in the second preset storage space, and the second time length can be calculated according to the second data length of the audio data, the second sampling rate, and the second bit width; the calculation method is as follows:
[0091] T2 = L2 / (s2*bw2);
[0092] Among them, T2 represents the second time length corresponding to the audio data; L2 represents the second data length of the audio data, s2 represents the second sampling rate of the audio data, and bw2 represents the second bit width of the audio data.
[0093] In this embodiment, the second time length is compared with the second time length threshold. If the second time length is less than or equal to the second time length threshold, the step of determining the corresponding audio data according to the Mel spectrum is executed; otherwise, the step of determining the corresponding audio data according to the Mel spectrum is stopped.
[0094] For example, if the second time length is less than or equal to twice the minimum delay time (T2≤2T delay), the step of determining the corresponding audio data according to the Mel spectrum is executed; if the second time length is greater than twice the second time length (T2>2T delay), the step of determining the corresponding audio data according to the Mel spectrum is stopped.
[0095] It can be seen that according to the method of this embodiment, it is possible to more accurately determine whether to execute the step of determining the corresponding audio data according to the Mel spectrum.
[0096] On the basis of the above embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, in this embodiment, after the corresponding phonemes are determined according to the to-be-synthesized participle and the to-be-synthesized phrase, the method further includes:
[0097] Get the historical synthesis duration;
[0098] Determine the estimated synthesis time of the word segmentation according to the historical synthesis time and the number of the word segmentation phonemes of the to-be-synthesized word segmentation, and determine the estimated synthesis time of the phrase according to the historical synthesis time and the number of the short phonemes of the to-be-synthesized phrase segmentation;
[0099] According to the relationship between the estimated synthesis time length of the word segmentation or the estimated synthesis time length of the phrase and the second time length, the corresponding phoneme is determined according to the to-be-synthesized word segmentation or the to-be-synthesized phrase.
[0100] The historical synthesis time refers to the time required to synthesize text into corresponding audio data in the historical records. Generally, the time to convert a word or phrase into a phoneme is very short and can be ignored; therefore, the historical synthesis time can also be the time required to synthesize a phoneme into corresponding audio data.
[0101] In actual applications, the duration of the last speech synthesis of the first historical number of phonemes can be determined as the historical synthesis duration, or the duration of multiple speech synthesis and the weighted average of the corresponding first historical quantities can be determined as the historical synthesis duration. This embodiment does not limit the specific method for determining the historical synthesis duration.
[0102] Specifically, if the historical synthesis time corresponding to p0 (the first historical number) phonemes is Ts0; the number of segmentation phonemes to be synthesized is p1, and it is assumed that the estimated synthesis time of the segmentation is Ts1, then the ratio of the historical synthesis time to the first historical number is equal to the ratio of the estimated synthesis time of the segmentation to the number of segmentation phonemes, that is:
[0103]
[0104] Determine the estimated synthesis time of the word to be synthesized
[0105] If the historical synthesis time corresponding to p0 (the first historical number) phonemes is Ts0; the number of short phonemes in the phrase to be synthesized is p2, and it is assumed that the estimated synthesis time of the word segmentation is Ts2, then the ratio of the historical synthesis time to the first historical number is equal to the ratio of the estimated synthesis time of the phrase to the number of short phonemes, that is:
[0106]
[0107] Determine the estimated synthesis time of the phrase corresponding to the phrase to be synthesized
[0108] In a specific embodiment, the relationship between the estimated synthesis time of the phrase and the second time length is determined. If the estimated synthesis time of the phrase is less than the second time length, it means that when the audio data is played, the phrase to be synthesized can be synthesized into the corresponding audio data. Therefore, the corresponding phonemes are determined based on the phrase to be synthesized first. Specifically, the phrase to be synthesized can be input into the text-to-phoneme model GTP to obtain the corresponding phonemes. Otherwise, it means that when the audio is played, the phrase to be synthesized cannot be synthesized into the corresponding audio data. Therefore, the corresponding phonemes are determined based on the participle to be synthesized first. Specifically, the participle to be synthesized can be input into the text-to-phoneme model GTP to obtain the corresponding phonemes.
[0109] In another specific embodiment, the relationship between the estimated synthesis time of the word segmentation and the second time length is determined. If the estimated synthesis time of the word segmentation is less than the second time length, it means that when the audio data is played, the word segmentation to be synthesized can be synthesized into the corresponding audio data. Therefore, the corresponding phoneme is determined based on the word segmentation to be synthesized first. Specifically, the word segmentation to be synthesized can be input into the text-to-phoneme model GTP to obtain the corresponding phoneme; otherwise, it means that when the audio is played, the word segmentation to be synthesized cannot be synthesized into the corresponding audio data. Therefore, the corresponding phoneme is determined based on the phrase to be synthesized first. Specifically, the phrase to be synthesized can be input into the text-to-phoneme model GTP to obtain the corresponding phoneme.
[0110] It can be seen that according to the method of this embodiment, the real-time performance of speech synthesis can be further guaranteed.
[0111] Based on the above embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, in this embodiment, obtaining the historical synthesis duration includes:
[0112] Obtain the first historical duration for converting the historical number of historical phonemes into the corresponding historical Mel-spectrograms;
[0113] Obtain a second historical duration of synthesizing the historical Mel spectrum into the corresponding historical audio data;
[0114] The historical synthesis duration is determined according to the first historical duration and the second historical duration.
[0115] In a specific embodiment, after the historical text to be synthesized is segmented to obtain historical segmented words to be synthesized and historical phrases to be synthesized, w0 (w0>1) historical segmented words to be synthesized or historical phrases to be synthesized are input into the text-to-phoneme model GTP, and the corresponding p0 (historical number) historical phonemes are determined by using the text-to-phoneme model GTP;
[0116] Input p0 historical phonemes into the acoustic feature model AFM, use the acoustic feature model AFM to output the historical Mel spectrum, and count the running time of the acoustic feature model AFM, that is, determine the first historical time length t1 of converting p0 (historical number) historical phonemes into the corresponding historical Mel spectrum; save the historical Mel spectrum output by the acoustic feature model AFM in the first preset storage space (BF1);
[0117] The vocoder (VC) reads the historical Mel spectrum from the first preset storage space (BF1), inputs the historical Mel spectrum into the vocoder (VC), synthesizes the historical audio data, stores the synthesized historical audio data in the second preset storage space (BF2), and simultaneously counts the second historical time length t2 of the historical audio data corresponding to the historical Mel spectrum synthesized;
[0118] The historical synthesis duration is determined according to the sum of the first historical duration and the second historical duration, that is, the historical synthesis duration Ts0 = t1 + t2.
[0119] It can be seen that according to the method of this embodiment, the historical synthesis time can be determined efficiently and conveniently, so as to determine the estimated synthesis time of the word segmentation and the estimated synthesis time of the phrase based on the historical synthesis time, and then determine to give priority to processing the word segmentation or phrase to be synthesized, thereby improving the real-time performance of speech synthesis.
[0120] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application are described in detail below in combination with actual application scenarios. Figure 2 The flowchart of another speech synthesis method is shown in FIG. 1 . In an embodiment of the present application, the specific steps of a speech synthesis method are as follows:
[0121] Obtain historical texts, and split the historical texts into historical words and historical phrases;
[0122] Determine a historical number (p0) of historical phonemes corresponding to w0 (w0>1) historical word segments, or determine a historical number (p0) of historical phonemes corresponding to w0 (w0>1) historical phrases;
[0123] Input p0 historical phonemes into the acoustic feature model AFM, use the acoustic feature model AFM to output the historical Mel spectrum, and count the running time of the acoustic feature model AFM, that is, determine the first historical time length t1 of converting p0 (historical number) historical phonemes into the corresponding historical Mel spectrum;
[0124] Input the historical Mel spectrum into the vocoder (VC) to synthesize the historical audio data, and statistically synthesize the historical Mel spectrum to obtain the second historical duration t2 of the corresponding historical audio data;
[0125] Determine the historical synthesis duration Ts0=t1+t2 according to the first historical duration and the second historical duration;
[0126] Obtaining the text to be synthesized, and performing word segmentation processing on the text to be synthesized to obtain a corresponding number of word segments to be synthesized and phrases to be synthesized;
[0127] Determine the estimated synthesis time of the word segmentation according to the historical synthesis time Ts0 and the number of word segmentation phonemes p1 of the word to be synthesized;
[0128] Determine the estimated synthesis time of the phrase according to the historical synthesis time Ts0 and the number of short phonemes p2 of the phrase to be synthesized;
[0129] Determine the second data volume of the audio data in the second preset storage space (BF2) and determine the corresponding second time length T2; T2 = L2 / (s2 * bw2); where T2 represents the second time length corresponding to the audio data; L2 represents the second data length of the audio data, s2 represents the second sampling rate of the audio data, and bw2 represents the second bit width of the audio data;
[0130] Judge the magnitude relationship between the estimated synthesis duration Ts2 of the phrase and the second time length T2. If the estimated synthesis duration of the phrase is less than the second time length (Ts2 < T2), input the phrase to be synthesized into the grapheme-to-phoneme model GTP to obtain the corresponding phonemes of the words to be synthesized; otherwise, input the words to be synthesized into the grapheme-to-phoneme model GTP to obtain the corresponding phonemes;
[0131] Determine the first time length T1 corresponding to the first data volume of the Mel spectrum in the first preset storage space (BF1); T1 = L1 / (s1 * bw1); where T1 represents the first time length corresponding to the Mel spectrum; L1 represents the first data length of the Mel spectrum, s1 represents the first sampling rate of the Mel spectrum, and bw1 represents the first bit width of the Mel spectrum;
[0132] If the first time length T1 is less than or equal to 2 times the second time length (T1 ≤ 2T2), then input the phonemes into the pre-trained acoustic feature model AFM, and use the acoustic feature model AFM to determine the corresponding Mel spectrum; store the Mel spectrum in the first preset storage space (BF1), and count the first duration of the Mel spectrum output by the acoustic feature model according to the phonemes; otherwise, stop the step of determining the corresponding Mel spectrum according to the phonemes;
[0133] If the second time length T2 is less than or equal to 2 times the minimum delay time (T2 ≤ 2Tdelay), then input the Mel spectrum into the vocoder, use the vocoder to convert the Mel spectrum into the corresponding audio data, store the audio data in the second preset storage space (BF2), and count the second duration of the audio data output by the vocoder according to the Mel spectrum; otherwise, stop the step of determining the corresponding audio data according to the Mel spectrum;
[0134] Until all the text to be synthesized is synthesized into audio data and stored in the second preset storage space and played completely.
[0135] Determine the synthesis duration according to the sum of the first duration and the second duration, update the first historical duration t1 with the first duration, update the second historical duration t2 with the second duration, update the historical quantity p0 with the number of word segmentation phonemes and the number of short speech phonemes, and update the historical synthesis duration Ts0 with the synthesis duration.
[0136] In a speech synthesis method provided by an embodiment of the present application, when the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, the corresponding Mel spectrum is determined according to the phoneme, otherwise, the step of determining the corresponding Mel spectrum according to the phoneme is stopped; when the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, the corresponding audio data is determined according to the Mel spectrum, otherwise, the step of determining the corresponding audio data according to the Mel spectrum is stopped. Determining whether to continue the synthesis step or stop the synthesis step based on the first data amount of the stored Mel spectrum and the second data amount of the stored audio data can improve the real-time performance of speech synthesis on the one hand; on the other hand, it can avoid data accumulation caused by too much stored Mel spectrum or synthesized audio data, and reduce the occupation of storage resources and processing resources; therefore, the method can reduce the occupation of storage resources and computing resources on the basis of ensuring the real-time performance of speech synthesis.
[0137] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0138] Figure 3 FIG. 1 is a schematic diagram of the structure of a speech synthesis device provided in an embodiment of the present application. Figure 3 As shown, the speech synthesis device of this embodiment includes a word segmentation module 310, a phoneme determination module 320, a first conversion module 330 and a second conversion module 340; wherein,
[0139] The word segmentation module 310 is used to obtain the text to be synthesized, and perform word segmentation processing on the text to be synthesized to obtain the word segmentation to be synthesized and the phrase to be synthesized;
[0140] A phoneme determination module 320, configured to determine corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase;
[0141] A first conversion module 330 is configured to determine a corresponding Mel spectrum according to the phoneme if the first data amount of the Mel spectrum in the first preset storage space is less than or equal to a first quantity threshold; otherwise, stop the step of determining the corresponding Mel spectrum according to the phoneme;
[0142] The second conversion module 340 is configured to determine the corresponding audio data according to the Mel spectrum if the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold; otherwise, stop the step of determining the corresponding audio data according to the Mel spectrum.
[0143] A speech synthesis device provided in an embodiment of the present application has the same beneficial effects as the above-mentioned speech synthesis method.
[0144] In a specific implementation, the first conversion module includes:
[0145] The first conversion submodule is used to input the phoneme into a pre-trained acoustic feature model and determine the corresponding Mel spectrum using the acoustic feature model.
[0146] In a specific implementation, the second conversion module includes:
[0147] The second conversion submodule is used to input the Mel spectrum into the vocoder, and use the vocoder to convert the Mel spectrum into corresponding audio data.
[0148] In a specific implementation, the first conversion module includes:
[0149] A first time length determination submodule, used to determine a corresponding first time length according to a first data amount of the Mel spectrum in a first preset storage space;
[0150] The first conversion submodule is configured to determine a corresponding Mel spectrum according to the phoneme if the first time length is less than or equal to a first time length threshold.
[0151] In a specific implementation, the second conversion module includes:
[0152] A second time length determination submodule, used to determine a corresponding second time length according to a second data amount of the audio data in the second preset storage space;
[0153] The second conversion submodule is configured to determine corresponding audio data according to the Mel spectrum if the second time length is less than or equal to a second time length threshold.
[0154] In a specific implementation, a speech synthesis device further includes:
[0155] The historical synthesis duration acquisition submodule is used to obtain the historical synthesis duration;
[0156] An estimated synthesis time determination submodule is used to determine the estimated synthesis time of a word according to the historical synthesis time and the number of phonemes of the word to be synthesized, and to determine the estimated synthesis time of a phrase according to the historical synthesis time and the number of short phonemes of the phrase to be synthesized;
[0157] The judgment submodule is executed preferentially, and is used to determine the corresponding phoneme according to the participle to be synthesized or the phrase to be synthesized according to the relationship between the estimated synthesis time length of the participle or the estimated synthesis time length of the phrase and the second time length.
[0158] In a specific implementation, the historical synthesis duration acquisition submodule includes:
[0159] A first history duration acquisition unit, used to acquire a first history duration for converting a history number of history phonemes into corresponding history Mel-spectrum spectra;
[0160] A second historical duration acquisition unit, used to acquire a second historical duration of synthesizing the historical Mel-frequency spectrum into the corresponding historical audio data;
[0161] The historical synthesis duration acquisition unit is used to determine the historical synthesis duration according to the first historical duration and the second historical duration.
[0162] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0163] The technicians in the relevant field 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 for illustration. In practical applications, the above-mentioned function allocation can be 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. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0164] Figure 4 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Figure 4 As shown, the terminal device 400 of this embodiment includes a memory 401, a processor 402, and a computer program 403 stored in the memory 401 and executable on the processor 402; when the processor 402 executes the computer program 403, the steps in the above-mentioned speech synthesis method embodiments are implemented; or when the processor 402 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0165] Exemplarily, the computer program 403 may be divided into one or more modules / units, one or more modules / units are stored in the memory 401, and are executed by the processor 402 to implement the method of the embodiment of the present application. One or more modules / units may be a series of computer program instruction segments that can perform specific functions, and the instruction segments are used to describe the execution process of the computer program 403 in the terminal device 400. For example, the computer program 403 may be divided into a word component module, a phoneme determination module, a first conversion module, and a second conversion module, and the specific functions of each module are as follows:
[0166] A word segmentation module is used to obtain the text to be synthesized and perform word segmentation on the text to be synthesized to obtain the word segmentation to be synthesized and the phrase to be synthesized;
[0167] A phoneme determination module, used to determine corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase respectively;
[0168] A first conversion module is configured to determine a corresponding Mel spectrum according to a phoneme if the first data amount of the Mel spectrum in the first preset storage space is less than or equal to a first quantity threshold; otherwise, stop the step of determining the corresponding Mel spectrum according to the phoneme;
[0169] The second conversion module is used to determine the corresponding audio data according to the Mel spectrum if the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold; otherwise, stop the step of determining the corresponding audio data according to the Mel spectrum.
[0170] In application, the terminal device 400 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device 400 may include but is not limited to a memory 401 and a processor 402. Those skilled in the art will appreciate that Figure 4 It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.; among which, the input and output devices may include cameras, audio acquisition / playback devices, display screens, etc.; the network access device may include a communication module for wireless communication with external devices.
[0171] In applications, the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0172] In applications, the memory can be an internal storage unit of a terminal device, such as a hard disk or memory of the terminal device; it can also be an external storage device of the terminal device, such as a plug-in hard disk equipped on the terminal device, a smart media card (SMC), a secure digital (SD) card, a flash card, etc.; it can also include both the internal storage unit and the external storage device of the terminal device. The memory is used to store operating systems, applications, boot loaders, data, and other programs, such as program codes of computer programs. The memory can also be used to temporarily store data that has been output or is about to be output.
[0173] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0174] The present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying the computer program code to a terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk.
[0175] A computer-readable storage medium provided in an embodiment of the present application has the same beneficial effects as the above-mentioned speech synthesis method.
[0176] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0177] Those of ordinary skill in the art will appreciate that the devices and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0178] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of devices, which can be electrical, mechanical or other forms.
[0179] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person 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 application, and should all be included in the protection scope of the present application.
Claims
1. A speech synthesis method, characterized in that: The method comprises: Acquire a text to be synthesized, and perform word segmentation processing on the text to be synthesized to obtain word segments to be synthesized and phrases to be synthesized; Determine corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase respectively; If the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, determining the corresponding Mel spectrum according to the phoneme; otherwise, stopping the step of determining the corresponding Mel spectrum according to the phoneme; If the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, the corresponding audio data is determined according to the Mel spectrum; otherwise, the step of determining the corresponding audio data according to the Mel spectrum is stopped.
2. The method according to claim 1, characterized in that Determining the corresponding Mel spectrum according to the phoneme includes: The phoneme is input into a pre-trained acoustic feature model, and the corresponding Mel spectrum is determined using the acoustic feature model.
3. The method according to claim 1, characterized in that: The determining corresponding audio data according to the Mel spectrum includes: The Mel spectrum is input into a vocoder, and the vocoder is used to convert the Mel spectrum into corresponding audio data.
4. The method according to claim 1, characterized in that: If the first data amount of the Mel spectrum in the first preset storage space is less than or equal to the first quantity threshold, determining the corresponding Mel spectrum according to the phoneme includes: Determine a corresponding first time length according to a first data amount of the Mel spectrum in the first preset storage space; If the first time length is less than or equal to a first time length threshold, a corresponding Mel spectrum is determined according to the phoneme.
5. The method according to claim 1, characterized in that If the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold, determining the corresponding audio data according to the Mel spectrum includes: Determine a corresponding second time length according to a second data amount of the audio data in the second preset storage space; If the second time length is less than or equal to a second time length threshold, the corresponding audio data is determined according to the Mel spectrum.
6. The method according to claim 5, characterized in that After determining the corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase, the method further includes: Get the historical synthesis duration; Determine the estimated synthesis time of the word segmentation according to the historical synthesis time and the number of the word segmentation phonemes of the to-be-synthesized word segmentation, and determine the estimated synthesis time of the phrase according to the historical synthesis time and the number of the short phonemes of the to-be-synthesized phrase segmentation; According to the relationship between the estimated synthesis time length of the word segment or the estimated synthesis time length of the phrase and the second time length, the corresponding phoneme is determined according to the to-be-synthesized word segment or the to-be-synthesized phrase.
7. The method according to claim 6, characterized in that The obtaining of the historical synthesis duration includes: Obtain the first historical duration for converting the historical number of historical phonemes into the corresponding historical Mel-spectrograms; Obtaining a second historical duration of synthesizing the historical Mel-spectrograms into corresponding historical audio data; The historical synthesis duration is determined according to the first historical duration and the second historical duration.
8. A speech synthesis device, characterized in that: The device comprises: A word segmentation module is used to obtain the text to be synthesized, and perform word segmentation processing on the text to be synthesized to obtain the word segments to be synthesized and the phrases to be synthesized; A phoneme determination module, used to determine corresponding phonemes according to the to-be-synthesized participle and the to-be-synthesized phrase respectively; a first conversion module, configured to determine a corresponding Mel spectrum according to the phoneme if the first data amount of the Mel spectrum in the first preset storage space is less than or equal to a first quantity threshold; otherwise, stop the step of determining the corresponding Mel spectrum according to the phoneme; The second conversion module is used to determine the corresponding audio data according to the Mel spectrum if the second data amount of the audio data in the second preset storage space is less than or equal to the second quantity threshold; otherwise, stop the step of determining the corresponding audio data according to the Mel spectrum.
9. A terminal 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 method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
