A text processing method and apparatus
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2026-08-14
AI Technical Summary
[0003]但是,现有技术在进行文本拆分时,通常采用静态长度截断法,即采用静态的数值设定拆分长度,再依次将各个截断的句子输入TTS模型转换为语音,但是这种方法可能会使语音在一个不应停顿之处产生停顿,例如文本可能在一个固定词汇或语义连续的句子之中达到静态长度触发截断,从而导致模型无法获取有效的上下文信息,降低语音的自然度;或者,现在技术在进行文本拆分时,仅在标点符号处截断,但是该方式无法处理标点符号稀疏或无标点符号的文本
[0015]本申请实施例提供的一种文本处理方法及装置,应用于将文本通过文字转换语音模型转换为语音的场景中,所述文本处理方法包括:根据文本获取场景类型以及当前文本处理阶段中的至少一者,确定当前文本拆分长度的至少一个约束条件;根据确定出的至少一个约束条件,确定本次文本分割的目标拆分长度;从当前文本起始位置开始,截取所述目标拆分长度的文本,得到目标文本。
Smart Images

Figure CN120913538B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text-to-speech processing technology, and in particular to a text processing method and apparatus. Background Technology
[0002] With the development of deep learning, end-to-end neural network TTS systems (such as Tacotron, FastSpeech, and VITS) have achieved significant breakthroughs in speech naturalness and expressiveness. However, in practical applications, TTS engines cannot process excessively long input texts at once due to limitations in GPU memory capacity and model computational complexity. Taking mainstream models as an example, the number of characters that can be processed in a single inference is usually limited to a certain number. Therefore, splitting long texts into continuous segments (text segments) that meet the model's input length limit has become a necessary preprocessing step in the TTS pipeline.
[0003] However, existing technologies typically employ static length truncation when segmenting text. This involves setting a static numerical value for the segmentation length and then sequentially inputting each truncated sentence into a TTS model for speech conversion. However, this method may cause pauses in speech where they shouldn't occur. For example, the text might reach the static length within a sentence with fixed words or semantic continuity, triggering truncation. This would prevent the model from acquiring effective contextual information and reduce the naturalness of the speech. Alternatively, current technologies may truncate only at punctuation marks during text segmentation, but this approach cannot handle text with sparse or no punctuation. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a text processing method and apparatus that dynamically determines the target segmentation length of the text based on the text acquisition scenario type and the current text processing stage, thereby minimizing the loss of context caused by text segmentation and improving the naturalness of the converted speech.
[0005] This application provides a text processing method applied to scenarios where text is converted into speech using a text-to-speech model. The text processing method includes: Determine at least one constraint on the current text split length based on at least one of the text acquisition scenario type and the current text processing stage. The target split length for this text segmentation is determined based on at least one of the identified constraints. Starting from the current text start position, extract the text of the target split length to obtain the target text.
[0006] Optionally, the constraints include at least one of the following: the language type of the current text, the speech reading time of the previous text conversion to speech, the punctuation information contained in the text, the initial split length, the total text length, and the split length threshold.
[0007] Optionally, when the current text processing stage is the first text split, determining the target split length for this text split based on at least one determined constraint includes: Based on the language type of the current text and the mapping relationship between the language and the basic segmentation length of the text, the initial segmentation length is corrected to obtain the first candidate segmentation length; Identify whether there are punctuation marks in the text starting from the current text start position and with a text length equal to the first candidate split length; If punctuation marks are present, the first candidate split length is determined as the target split length for this text segmentation; if punctuation marks are not present, it is determined whether the second candidate split length of the text from the current text start position to the end of the text when the first punctuation mark appears is greater than the split length threshold. If the second candidate split length is greater than the split length threshold, the first candidate split length is determined as the target split length for this text segmentation; if the second candidate split length is less than or equal to the split length threshold, it is determined whether there are unpaired punctuation marks in the text within the second candidate split length. If there are no unpaired punctuation marks, the second candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the third candidate split length of the text from the current text start position to the end of the unpaired punctuation mark's corresponding pair of punctuation marks in this split is greater than the split length threshold. If the third candidate split length is greater than the split length threshold, the second candidate split length is determined as the target split length for this text segmentation; if the third candidate split length is less than or equal to the split length threshold, the third candidate split length is determined as the target split length for this text segmentation.
[0008] Optionally, determining at least one constraint condition for the current text split length based on at least one of the text acquisition scenario type and the current text processing stage includes: When the text acquisition scenario type is a streaming output scenario and the current text processing stage is the first text split, at least one constraint condition for determining the current text split length includes: initial split length, language type of the current text, split length threshold, and punctuation information contained in the text; When the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, at least one constraint condition for determining the current text splitting length includes: a splitting length threshold, the speech reading time of the previous text converted to speech, and the punctuation information contained in the text.
[0009] Optionally, when the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, determining the target splitting length for this text segmentation based on at least one determined constraint includes: Based on the speech reading time of the previous text-to-speech conversion, the maximum text length that can be obtained within the speech reading time is determined as the fourth candidate split length; Identify whether there are punctuation marks in the text starting from the current text start position and with a length equal to the fourth candidate split length; If punctuation marks are present, the fourth candidate split length is determined as the target split length for this text segmentation; if punctuation marks are not present, it is determined whether the fifth candidate split length of the text from the current text start position to the end of the text when the first punctuation mark appears is greater than the split length threshold. If the fifth candidate split length is greater than the split length threshold, the fourth candidate split length is determined as the target split length for this text segmentation; if the fifth candidate split length is less than or equal to the split length threshold, it is identified whether there are unpaired punctuation marks in the text within the fifth candidate split length. If there are no unpaired punctuation marks, the fifth candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the sixth candidate split length of the text from the current text start position to the end of the unpaired punctuation mark's corresponding pair of punctuation marks in this split is greater than the split length threshold. If the sixth candidate split length is greater than the split length threshold, the fifth candidate split length is determined as the target split length for this text segmentation; if the sixth candidate split length is less than or equal to the split length threshold, the sixth candidate split length is determined as the target split length for this text segmentation.
[0010] Optionally, determining the maximum text length obtainable within the speech reading time after the previous text-to-speech conversion as the fourth candidate splitting length includes: Get the text conversion speed (converting text to speech), the speech output speed (outputting the converted speech), and the text acquisition speed (acquiring text). The overall processing speed is determined based on the text conversion speed, speech output speed, and text acquisition speed. The largest integer value determined by dividing the speech reading time by the overall processing speed is used as the fourth candidate split length.
[0011] Optionally, the step of determining at least one constraint condition for the current text split length based on the text acquisition scenario type and the current text processing stage includes: When the text acquisition scenario type is a non-streaming output scenario, at least one constraint condition for determining the current text split length includes: the language type of the current text, the punctuation information contained in the text, the total text length, and the split length threshold.
[0012] Optionally, when the text acquisition scenario type is a non-streaming output scenario, determining the target split length for this text segmentation based on at least one determined constraint includes: The initial split length is determined based on the language type of the current text and the total length of the text, and it is identified whether the length of the first text from the beginning of the current text to the first punctuation mark is less than the initial split length. If the length of the first text is greater than or equal to the initial split length, identify whether the length of the first text is greater than the split length threshold. If the length of the first text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the first text is not greater than the split length threshold, it is identified whether the first punctuation mark is an unpaired paired punctuation mark. If it is not an unpaired paired punctuation mark, the first text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the second text length is determined from the current text start position to the time when the paired punctuation mark corresponding to the unpaired paired punctuation mark appears in this split. Determine whether the length of the second text is greater than the split length threshold; If the length of the second text is greater than the splitting length threshold, the length of the first text is determined as the target splitting length for this text segmentation; if the length of the second text is less than or equal to the splitting length threshold, the length of the second text is determined as the target splitting length for this text segmentation.
[0013] Optionally, when the length of the first text from the current text start position to the first occurrence of a punctuation mark is less than the initial split length, the text processing method further includes: Determine the third text length from the current text start position to the end of the target punctuation mark, where the text length first exceeds the initial split length; Identify whether the length of the third text is greater than the split length threshold; If the length of the third text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the third text is less than or equal to the split length threshold, it is identified whether the ending punctuation mark corresponding to the length of the third text is an unpaired paired punctuation mark. If it is not an unpaired paired punctuation mark, the third text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the fourth text length is determined as the text length from the current text start position to the end of the paired punctuation mark corresponding to the unpaired paired punctuation mark in this segmentation. Determine whether the length of the fourth text is greater than the split length threshold; If the length of the fourth text is greater than the splitting length threshold, the length of the third text is determined as the target splitting length for this text segmentation; if the length of the fourth text is less than or equal to the splitting length threshold, the length of the fourth text is determined as the target splitting length for this text segmentation.
[0014] This application also provides a text processing device for use in scenarios where text is converted into speech using a text-to-speech model. The text processing device includes: The first determining module is used to determine at least one constraint condition for the current text split length based on at least one of the text acquisition scenario type and the current text processing stage. The second determining module is used to determine the target splitting length of the text segmentation based on at least one determined constraint condition. The splitting module is used to extract the target split length of text starting from the current text start position to obtain the target text.
[0015] This application provides a text processing method and apparatus, applied in a scenario where text is converted into speech using a text-to-speech model. The text processing method includes: determining at least one constraint condition for the current text segmentation length based on at least one of the text acquisition scenario type and the current text processing stage; determining the target segmentation length for this text segmentation based on the determined at least one constraint condition; and extracting text of the target segmentation length starting from the current text start position to obtain the target text. Thus, for text-to-speech processing scenarios that require text segmentation, this application determines the target segmentation length of the text based on the text acquisition scenario type and the current text processing stage, then determines the text length for this segmentation based on the determined target constraints, and finally performs text segmentation processing based on the determined text length. This allows the segmented text determined by this scheme to minimize the loss of context caused by text segmentation and improve the naturalness of the converted speech.
[0016] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A flowchart illustrating a text processing method provided in an embodiment of this application; Figure 2 This is one of the structural schematic diagrams of a text processing device provided in the embodiments of this application; Figure 3 This is a second schematic diagram of the structure of a text processing device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.
[0020] First, the applicable scenarios for this application will be introduced. This application can be applied to the field of text-to-speech processing technology.
[0021] Research has shown that with the development of deep learning, end-to-end neural network TTS systems (such as Tacotron, FastSpeech, and VITS) have achieved significant breakthroughs in speech naturalness and expressiveness. However, in practical applications, TTS engines are limited by GPU memory capacity and model computational complexity, making it impossible to process excessively long input texts at once. For example, the number of characters that mainstream models can process in a single inference iteration is typically limited to a certain length. Therefore, splitting long texts into continuous segments (text segments) that meet the model's input length limitations becomes a necessary preprocessing step for speech synthesis.
[0022] However, existing technologies typically employ static length truncation when segmenting text. This involves setting a static numerical value for the segmentation length and then sequentially inputting each truncated sentence into a TTS model for speech conversion. However, this method may cause pauses in speech where they shouldn't occur. For example, the text might reach the static length within a sentence with fixed words or semantic continuity, triggering truncation. This would prevent the model from acquiring effective contextual information and reduce the naturalness of the speech. Alternatively, current technologies may truncate only at punctuation marks during text segmentation, but this approach cannot handle text with sparse or no punctuation.
[0023] Based on this, embodiments of this application provide a text processing method and apparatus that dynamically determines the target split length of the text based on the text acquisition scenario type and the current text processing stage, thereby minimizing the loss of context caused by text splitting and improving the naturalness of the converted speech.
[0024] Please see Figure 1 , Figure 1 This is a flowchart illustrating a text processing method provided in an embodiment of this application. This text processing method is applied in scenarios where text is converted into speech using a text-to-speech model, such as... Figure 1 As shown in the embodiments of this application, the text processing method includes: S101. Determine at least one constraint condition for the current text split length based on at least one of the text acquisition scenario type and the current text processing stage.
[0025] S102. Determine the target split length for this text segmentation based on at least one determined constraint.
[0026] S103. Starting from the current text start position, extract the text of the target split length to obtain the target text.
[0027] The exemplary steps of the embodiments of this application are described below: For step S101, the step may include: when text splitting is required, determining at least one of the acquisition scenario type of the current text to be split and the current processing stage of the current text (current text processing stage), and then determining at least one constraint condition to be referenced for the current text splitting based on the at least one of them.
[0028] Here, the text acquisition scenario type can be a streaming output scenario or a non-streaming output scenario, and the current text processing stage can be the initial text splitting stage or a non-initial text splitting stage.
[0029] It's important to note that streaming output typically involves generating output text while simultaneously providing real-time, continuous feedback on the generated portions (even if it's just a small segment, a single word, or even a few characters). Non-streaming output, on the other hand, typically involves generating and processing all the output text required for the entire request all at once.
[0030] The constraints determine the final length of the text segmentation. In one embodiment provided in this application, the constraints include at least one of the following: the language type of the current text, the speech reading time of the previous text conversion to speech, the punctuation information contained in the target text, the initial segmentation length, the total text length, and the segmentation length threshold.
[0031] The splitting length threshold can be determined based on the conversion capability of the text-to-speech model.
[0032] Continuing with step S101, in one embodiment provided in this application, determining at least one constraint condition for the current text split length based on at least one of the text acquisition scenario type and the current text processing stage includes: when the text acquisition scenario type is a streaming output scenario and the current text processing stage is the first text split, the determination of at least one constraint condition for the current text split length includes: initial split length, language type of the current text, split length threshold, and punctuation information contained in the text.
[0033] When the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, at least one constraint condition for determining the current text splitting length includes: a splitting length threshold, the speech reading time of the previous text converted to speech, and the punctuation information contained in the text.
[0034] When the text acquisition scenario is a non-streaming output scenario, at least one constraint for determining the current text split length includes: the language type of the current text, the punctuation information contained in the text, the total text length, and the split length threshold. The split length threshold represents the maximum text length that the TTS model's resources can process.
[0035] For step S102, the target split length for this text segmentation is determined based on at least one constraint condition and related calculation rules.
[0036] To better understand the target split length for each text segmentation, this application provides the following implementation methods.
[0037] For example, in one embodiment provided in this application, when the current text processing stage is the first text split, determining the target split length for this text split based on at least one determined constraint includes: S10211. Based on the language type of the current text and the mapping relationship between the language and text basic segmentation lengths, the initial segmentation length is corrected to obtain the first candidate segmentation length; S10212. Identify whether there are punctuation marks in the text starting from the current text start position and with a text length equal to the first candidate split length; S10213. If punctuation marks exist, the first candidate split length is determined as the target split length for this text segmentation; if punctuation marks do not exist, it is determined whether the second candidate split length of the text from the current text start position to the end of the first appearance of a punctuation mark is greater than the split length threshold. S10214. If the second candidate split length is greater than the split length threshold, the first candidate split length is determined as the target split length for this text segmentation; if the second candidate split length is less than or equal to the split length threshold, it is identified whether there are unpaired punctuation marks in the text within the second candidate split length. S10215. If there are no unpaired punctuation marks, the second candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the third candidate split length of the text from the current text start position to the end of the unpaired punctuation mark corresponding to the paired punctuation mark in this split is greater than the split length threshold. S10216. If the third candidate split length is greater than the split length threshold, the second candidate split length is determined as the target split length for this text segmentation; if the third candidate split length is less than or equal to the split length threshold, the third candidate split length is determined as the target split length for this text segmentation. In this implementation, only the current text processing stage is considered when determining the constraints.
[0038] For step S10211, this step may include: determining the basic text segmentation length corresponding to the language type to which the current text belongs based on the mapping relationship between the language type to which the current text belongs and the language-text basic segmentation length; replacing the initial segmentation length with the determined basic text segmentation length to obtain a first candidate segmentation length (i.e., the first candidate segmentation length is equal to the basic text segmentation length).
[0039] Here, the initial split length can be predetermined, and the initial split length can be set to a small value.
[0040] The mapping relationship between language and text base segment length can be predetermined, and the text base segment length corresponding to different languages is not necessarily the same. For example, for languages that use specific characters, such as Chinese, Korean, and Japanese, the text base segment length can be set to any length between 15 and 25. For languages that use letters to form different words, such as English, the text base segment length can be set to a longer length, such as any length between 200 and 300.
[0041] Regarding step S10212, since the current text processing stage in this embodiment is the first text split, the current text starting position is the starting position of the total text.
[0042] Regarding step S10213, if the text with the first candidate split length contains punctuation marks, the target split length for this text segmentation is directly determined, and subsequent steps are not executed. If the text with the first candidate split length does not contain punctuation marks, subsequent steps are executed. Here, the second candidate split length is greater than the first candidate split length; the split length threshold is determined based on the text-to-speech model.
[0043] Regarding step S10214, if the extended second candidate split length exceeds the maximum length that the model can convert (splitting length threshold), then the first candidate split length is still used to determine the target split length for this text segmentation, and subsequent steps are not executed. If the second candidate split length does not exceed the maximum length that the model can convert (splitting length threshold), then subsequent steps are executed.
[0044] Here, paired punctuation marks refer to punctuation marks that must appear in pairs in written language to correspond with each other, such as double quotation marks “”, single quotation marks '’, book title marks 【」, 《》, <>, etc. They are usually used to indicate a specific scope, express a specific relationship, or for emphasis. The absence of any one of them will result in an incomplete sentence structure, unclear meaning, or grammatical errors.
[0045] Regarding step S10215, if there are no unpaired punctuation marks, meaning the ending symbol of the text in the second candidate segmentation length is generally a comma or period, then the second candidate segmentation length can be directly determined as the target segmentation length for this text segmentation, and subsequent steps are not executed. However, if there are unpaired punctuation marks (generally only the first and last characters exist), to avoid the subsequent model being unable to obtain effective contextual information and reducing the naturalness of the speech, subsequent steps are executed, i.e., text extension is performed.
[0046] Here, the length of the third candidate split is greater than the length of the second candidate split.
[0047] To better understand the scheme of this application, an example is provided below: For instance, when the text identified within the second candidate segmentation length includes: "Xiaoming said: 'Good morning.'", this text only contains the quotation marks "". To ensure the semantic integrity of the converted speech and to avoid abrupt transitions between segments, the second candidate segmentation length is extended to the third candidate segmentation length. The text corresponding to the third candidate segmentation length is: "Xiaoming said: 'Good morning.'". If the third candidate segmentation length does not exceed the segmentation length threshold, the text input to the TTS model is "Xiaoming said: 'Good morning.'"; if the third candidate segmentation length exceeds the segmentation length threshold, the text input to the TTS model is: "Xiaoming said: 'Good morning.'". Through the judgments in S10211~S10216, the maximum naturalness of the speech is achieved with limited TTS model resources.
[0048] Furthermore, to make the text processing method proposed in this application more adaptable to different scenarios, corresponding processing methods are proposed for both streaming and non-streaming output scenarios.
[0049] In another embodiment provided in this application, when the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, determining the target splitting length of this text segmentation based on at least one determined constraint includes: S10221. Based on the speech reading time of the previous text-to-speech conversion, the maximum text length that can be obtained within the speech reading time is determined as the fourth candidate split length. S10222. Identify whether there are punctuation marks in the text starting from the current text start position and with a text length of the fourth candidate split length; S10223. If punctuation marks exist, the fourth candidate split length is determined as the target split length for this text segmentation; if punctuation marks do not exist, it is determined whether the fifth candidate split length of the text from the current text start position to the end of the text when the first punctuation mark appears is greater than the split length threshold. S10224. If the fifth candidate split length is greater than the split length threshold, the fourth candidate split length is determined as the target split length for this text segmentation; if the fifth candidate split length is less than or equal to the split length threshold, it is identified whether there are unpaired punctuation marks in the text within the fifth candidate split length. S10225. If there are no unpaired punctuation marks, the fifth candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the sixth candidate split length of the text from the current text start position to the end of the unpaired punctuation mark corresponding to the paired punctuation mark is greater than the split length threshold. S10226. If the sixth candidate split length is greater than the split length threshold, the fifth candidate split length is determined as the target split length for this text segmentation; if the sixth candidate split length is less than or equal to the split length threshold, the sixth candidate split length is determined as the target split length for this text segmentation.
[0050] This embodiment illustrates the process of determining the target split length in a scenario where the text acquisition scenario is a streaming output scenario and the current text processing stage is a non-first text splitting scenario.
[0051] Regarding step S10221, the speech reading time of the previous text-to-speech conversion can be determined based on the text-to-speech model. The text-to-speech model can be a TTS model.
[0052] Regarding this step, in one embodiment provided in this application, determining the maximum text length that can be obtained within the speech reading time after the previous text-to-speech conversion as the fourth candidate splitting length includes: obtaining the text conversion speed for converting text to speech, the speech output speed for outputting the converted speech, and the text acquisition speed for acquiring text; determining the comprehensive processing speed based on the text conversion speed, speech output speed, and text acquisition speed; and determining the maximum integer value determined by dividing the speech reading time by the comprehensive processing speed as the fourth candidate splitting length.
[0053] Here, the text conversion speed for converting text to speech and the speech output speed for outputting the converted speech can be predetermined based on the performance of the text-to-speech model.
[0054] When determining the overall processing speed based on the text conversion speed, speech output speed, and text acquisition speed, the specific method can be: the sum of the text conversion speed, speech output speed, and text acquisition speed is determined as the overall processing speed.
[0055] Here, the fourth candidate segment length is determined based on the voice reading time in order to ensure that the next voice segment can be connected immediately after the previous voice segment is finished, so that the user does not feel a pause between each text segment, while minimizing the number of text segments and avoiding the loss of context caused by text segmentation.
[0056] Regarding step S10222, since the current text processing stage is not the first text split, the current text start position in this step is the end position of the text split in the previous step. The descriptions of steps S10223-S10226 can be found in the descriptions of S10213-S10216, and the same technical effect can be achieved, so they will not be elaborated further.
[0057] Among them, the sixth candidate split length is greater than the fifth split length, and the fifth split length is greater than the fourth split length.
[0058] Furthermore, in another embodiment provided in this application, when the text acquisition scenario type is a non-streaming output scenario, determining the target splitting length of this text segmentation based on at least one determined constraint includes: S10231. Determine the initial split length based on the language type of the current text and the total length of the text, and identify whether the length of the first text from the beginning of the current text to the first occurrence of a punctuation mark is less than the initial split length. S10232. If the length of the first text is greater than or equal to the initial split length, identify whether the length of the first text is greater than the split length threshold. S10233. If the length of the first text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the first text is not greater than the split length threshold, it is identified whether the first punctuation mark is an unpaired paired punctuation mark. S10234. If it is not an unpaired paired punctuation mark, the first text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the second text length is determined from the current text start position to the time when the paired punctuation mark corresponding to the unpaired paired punctuation mark appears in this split. S10235. Determine whether the length of the second text is greater than the split length threshold; S10236. If the length of the second text is greater than the splitting length threshold, the length of the first text is determined as the target splitting length for this text segmentation; if the length of the second text is less than or equal to the splitting length threshold, the length of the second text is determined as the target splitting length for this text segmentation.
[0059] Regarding step S10231, when determining the initial split length based on the language type of the current text and the total length of the text, examples may include: determining length 1 based on the language type of the current text; determining the number of splits based on the total length of the text, dividing the total length by the number of splits to obtain the integer value of length 2; and determining length 1 or length 2 as the initial split length according to a preset selection rule.
[0060] Here, the initial split length is determined based on the total text length because the more times the text is split, the greater the possibility that the speech will not be natural due to the inability to obtain context. In addition, the more times the TTS model is called, the lower the resource utilization. Therefore, for non-streaming scenarios with a long total text length, the splitting parameters can be appropriately increased.
[0061] The current text start position can be either the start position of the total text or the end position after the previous split.
[0062] Continuing with step S10231, when identifying the first text length from the current text start position to the first occurrence of a punctuation mark, it can specifically be: identifying the first text length from the current text start position to the first occurrence of a punctuation mark of the target level.
[0063] Here, all punctuation marks can be pre-classified into different levels, and the target level can be pre-specified.
[0064] For example, symbols that signify the end of a sentence, such as periods, line breaks, exclamation marks, question marks, and paragraph breaks, can be identified as first-level symbols, while commas, pause marks, semicolons, and colons can be identified as second-level symbols. The determined first text length can be defined as the length of the text from the beginning of the current text until the first occurrence of a first-level symbol.
[0065] For step S10232, the initial split length is less than or equal to the split length threshold.
[0066] Regarding step S10233, if it is determined that the length of the first text is greater than the split length threshold, the initial split length is determined as the target split length, and the subsequent judgment steps are not executed.
[0067] Regarding step S10234, the paired punctuation mark corresponding to the unpaired paired punctuation mark refers to the other symbol of the paired punctuation mark.
[0068] For example, when the paired punctuation marks are double quotes, and when only the first quote exists in the text of the first text length, the end position of the determined text of the second text length is the position of the last quote corresponding to the first quote.
[0069] The second text is longer than the first text.
[0070] Furthermore, in another embodiment provided in this application, when the length of the first text from the current text start position to the first appearance of a punctuation mark is less than the initial split length, the text processing method further includes: S10241. Determine the third text length from the current text start position to the end of the target punctuation mark, where the text length is first greater than the initial split length; S10242. Identify whether the length of the third text is greater than the split length threshold; S10243. If the length of the third text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the third text is less than or equal to the split length threshold, it is identified whether the end punctuation mark corresponding to the length of the third text is an unpaired paired punctuation mark. S10244. If it is not an unpaired paired punctuation mark, the third text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the fourth text length is determined from the current text start position to the end of the paired punctuation mark corresponding to the unpaired paired punctuation mark in this segmentation. S10245. Determine whether the length of the fourth text is greater than the split length threshold; S10246. If the length of the fourth text is greater than the splitting length threshold, the length of the third text is determined as the target splitting length for this text segmentation; if the length of the fourth text is less than or equal to the splitting length threshold, the length of the fourth text is determined as the target splitting length for this text segmentation.
[0071] Regarding step S10241, the target punctuation mark can be predetermined. For example, a punctuation mark that meets a certain level can be determined as the target punctuation mark, or a certain punctuation mark can be directly designated as the target punctuation mark, or any punctuation mark can be directly determined as the target punctuation mark.
[0072] For example, assuming that the first-level punctuation mark is determined as the target punctuation mark, step S10241 can be as follows: determine the text length from the current text start position to each first-level punctuation mark, and determine whether the text length is greater than the initial split length; if so, determine the text length as the third text length and stop the comparison; if not, continue to perform length recognition (recognize the text length from the current text start position to the next first-level punctuation mark) until the third text length is obtained.
[0073] The reason for redetermining the length of the first text and determining the length of the third text is mainly for long texts with many and dense punctuation marks. If the text is split every time a punctuation mark appears, the number of splits will be too many, and the model's input and output operations will be too many, which may reduce the processing effect.
[0074] In the example above, the length of the third text is less than the length of the fourth text.
[0075] For step S103, this step includes: starting from the current text start position, extracting text according to the target split length, and determining the extracted text fragment as the target text.
[0076] Furthermore, the processing method provided in this application supports parallel task execution in both streaming and non-streaming scenarios. For example, while outputting the previous text, the TTS conversion or text transmission of the next text can be performed. However, due to the resource limitations of the TTS model, two texts cannot be converted to speech simultaneously at any given time. This solution can also address this by inserting preset splitting identifiers (e.g., ...) at the splitting points. <break> 、 <pause> / p or other symbols or identifiers that can make the model aware of the symbols or identifiers that need to be truncated, or speech synthesis markup languages, so that the text acquisition module of TTS knows that the text needs to be broken at the location where the split identifier appears.
[0077] In summary, for text-to-speech processing scenarios that require text segmentation, this application determines the target segmentation length of the text based on the text acquisition scenario type and the current text processing stage. Then, it determines the text length for this segmentation based on the determined target constraints, and finally performs text segmentation processing based on the determined text length. This approach ensures that the segmented text determined by this solution can minimize the loss of context caused by text segmentation and improve the naturalness of the converted speech.
[0078] Based on the same inventive concept, this application also provides a text processing device corresponding to the text processing method. Since the principle of the device in this application is similar to that of the text processing method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0079] Please see Figure 2 , Figure 3 , Figure 2 This is one of the structural schematic diagrams of a text processing device provided in the embodiments of this application. Figure 3 This is a second schematic diagram of a text processing device provided in an embodiment of this application. The text processing device 200 includes: The first determining module 210 is used to determine at least one constraint condition for the current text split length based on at least one of the text acquisition scenario type and the current text processing stage. The second determining module 220 is used to determine the target splitting length of the text segmentation based on at least one determined constraint condition; The splitting module 230 is used to extract text of the target splitting length starting from the current text start position to obtain the target text.
[0080] Optionally, the constraints include at least one of the following: the language type of the current text, the speech reading time of the previous text conversion to speech, the punctuation information contained in the text, the initial split length, the total text length, and the split length threshold.
[0081] Optionally, when the current text processing stage is the first text split, when the second determining module 220 is used to determine the target split length of this text split based on at least one determined constraint, the second determining module 220 is used to: Based on the language type of the current text and the mapping relationship between the language and the basic segmentation length of the text, the initial segmentation length is corrected to obtain the first candidate segmentation length; Identify whether there are punctuation marks in the text starting from the current text start position and with a text length equal to the first candidate split length; If punctuation marks are present, the first candidate split length is determined as the target split length for this text segmentation; if punctuation marks are not present, it is determined whether the second candidate split length of the text from the current text start position to the end of the text when the first punctuation mark appears is greater than the split length threshold. If the second candidate split length is greater than the split length threshold, the first candidate split length is determined as the target split length for this text segmentation; if the second candidate split length is less than or equal to the split length threshold, it is determined whether there are unpaired punctuation marks in the text within the second candidate split length. If there are no unpaired punctuation marks, the second candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the third candidate split length of the text from the current text start position to the end of the unpaired punctuation mark's corresponding pair of punctuation marks in this split is greater than the split length threshold. If the third candidate split length is greater than the split length threshold, the second candidate split length is determined as the target split length for this text segmentation; if the third candidate split length is less than or equal to the split length threshold, the third candidate split length is determined as the target split length for this text segmentation.
[0082] Optionally, when the first determining module 210 determines at least one constraint condition for the current text split length based on at least one of the text acquisition scenario type and the current text processing stage, the first determining module 210 is used to: When the text acquisition scenario type is a streaming output scenario and the current text processing stage is the first text split, at least one constraint condition for determining the current text split length includes: initial split length, language type of the current text, split length threshold, and punctuation information contained in the text; When the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, at least one constraint condition for determining the current text splitting length includes: a splitting length threshold, the speech reading time of the previous text converted to speech, and the punctuation information contained in the text.
[0083] Optionally, when the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, the second determining module 220, when determining the target splitting length of this text segmentation based on at least one determined constraint, is used to: Based on the speech reading time of the previous text-to-speech conversion, the maximum text length that can be obtained within the speech reading time is determined as the fourth candidate split length; Identify whether there are punctuation marks in the text starting from the current text start position and with a length equal to the fourth candidate split length; If punctuation marks are present, the fourth candidate split length is determined as the target split length for this text segmentation; if punctuation marks are not present, it is determined whether the fifth candidate split length of the text from the current text start position to the end of the text when the first punctuation mark appears is greater than the split length threshold. If the fifth candidate split length is greater than the split length threshold, the fourth candidate split length is determined as the target split length for this text segmentation; if the fifth candidate split length is less than or equal to the split length threshold, it is identified whether there are unpaired punctuation marks in the text within the fifth candidate split length. If there are no unpaired punctuation marks, the fifth candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the sixth candidate split length of the text from the current text start position to the end of the unpaired punctuation mark's corresponding pair of punctuation marks in this split is greater than the split length threshold. If the sixth candidate split length is greater than the split length threshold, the fifth candidate split length is determined as the target split length for this text segmentation; if the sixth candidate split length is less than or equal to the split length threshold, the sixth candidate split length is determined as the target split length for this text segmentation.
[0084] Optionally, when the second determining module 220 determines the maximum text length obtainable within the speech reading time based on the speech reading time after the previous text-to-speech conversion as the fourth candidate splitting length, the second determining module 220 is used to: Get the text conversion speed (converting text to speech), the speech output speed (outputting the converted speech), and the text acquisition speed (acquiring text). The overall processing speed is determined based on the text conversion speed, speech output speed, and text acquisition speed. The largest integer value determined by dividing the speech reading time by the overall processing speed is used as the fourth candidate split length.
[0085] Optionally, when the first determining module 210 determines at least one constraint condition for the current text split length based on the text acquisition scenario type and the current text processing stage, the first determining module 210 is used to: When the text acquisition scenario type is a non-streaming output scenario, at least one constraint condition for determining the current text split length includes: the language type of the current text, the punctuation information contained in the text, the total text length, and the split length threshold.
[0086] Optionally, when the text acquisition scenario type is a non-streaming output scenario, when the second determining module 220 is used to determine the target splitting length of this text segmentation based on at least one determined constraint, the second determining module 220 is used to: The initial split length is determined based on the language type of the current text and the total length of the text, and it is identified whether the length of the first text from the beginning of the current text to the first punctuation mark is less than the initial split length. If the length of the first text is greater than or equal to the initial split length, identify whether the length of the first text is greater than the split length threshold. If the length of the first text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the first text is not greater than the split length threshold, it is identified whether the first punctuation mark is an unpaired paired punctuation mark. If it is not an unpaired paired punctuation mark, the first text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the second text length is determined from the current text start position to the time when the paired punctuation mark corresponding to the unpaired paired punctuation mark appears in this split. Determine whether the length of the second text is greater than the split length threshold; If the length of the second text is greater than the splitting length threshold, the length of the first text is determined as the target splitting length for this text segmentation; if the length of the second text is less than or equal to the splitting length threshold, the length of the second text is determined as the target splitting length for this text segmentation.
[0087] Optional, such as Figure 3 As shown, the text processing device 200 further includes a third determining module 240, which is used for: When the length of the first text from the current text start position to the first occurrence of a punctuation mark is less than the initial split length, determine the length of the third text from the current text start position to the end of the target punctuation mark, where the text length is greater than the initial split length for the first time. Identify whether the length of the third text is greater than the split length threshold; If the length of the third text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the third text is less than or equal to the split length threshold, it is identified whether the ending punctuation mark corresponding to the length of the third text is an unpaired paired punctuation mark. If it is not an unpaired paired punctuation mark, the third text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the fourth text length is determined as the text length from the current text start position to the end of the paired punctuation mark corresponding to the unpaired paired punctuation mark in this segmentation. Determine whether the length of the fourth text is greater than the split length threshold; If the length of the fourth text is greater than the splitting length threshold, the length of the third text is determined as the target splitting length for this text segmentation; if the length of the fourth text is less than or equal to the splitting length threshold, the length of the fourth text is determined as the target splitting length for this text segmentation.
[0088] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 4 As shown, the electronic device 400 includes a processor 410, a memory 420, and a bus 430.
[0089] The memory 420 stores machine-readable instructions executable by the processor 410. When the electronic device 400 is running, the processor 410 communicates with the memory 420 via the bus 430. When the machine-readable instructions are executed by the processor 410, they can perform the operations described above. Figure 1 The steps in the method embodiment shown are specifically implemented in the method embodiment and will not be repeated here.
[0090] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can perform the above-described actions. Figure 1 The steps in the method embodiment shown are specifically implemented in the method embodiment and will not be repeated here.
[0091] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0092] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0093] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0094] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0095] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0096] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.< / pause> < / break>
Claims
1. A text processing method, applied to scenarios where text is converted into speech using a text-to-speech model, characterized in that, The text processing method includes: Based on the text acquisition scenario type and the current text processing stage, determine at least one constraint condition for the current text split length; The step of determining at least one constraint condition for the current text split length based on the text acquisition scenario type and the current text processing stage includes: When the text acquisition scenario type is a streaming output scenario and the current text processing stage is the first text split, the constraints for determining the current text split length include: the initial split length, the language type of the current text, the split length threshold, and the punctuation information contained in the text; When the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, the constraints for determining the current text splitting length include: the splitting length threshold, the speech reading time of the previous text converted to speech, and the punctuation information contained in the text; Based on at least one determined constraint, determine the target split length for this text segmentation. Starting from the current text start position, extract the text of the target split length to obtain the target text.
2. The text processing method according to claim 1, characterized in that, When the current text processing stage is the first text split, determining the target split length for this text split based on at least one determined constraint includes: Based on the language type of the current text and the mapping relationship between the language and the basic segmentation length of the text, the initial segmentation length is corrected to obtain the first candidate segmentation length; Identify whether there are punctuation marks in the text starting from the current text start position and with a text length equal to the first candidate split length; If punctuation marks are present, the first candidate split length is determined as the target split length for this text segmentation; if punctuation marks are not present, it is determined whether the second candidate split length of the text from the current text start position to the end of the text when the first punctuation mark appears is greater than the split length threshold. If the second candidate split length is greater than the split length threshold, the first candidate split length is determined as the target split length for this text segmentation; if the second candidate split length is less than or equal to the split length threshold, it is determined whether there are unpaired punctuation marks in the text within the second candidate split length. If there are no unpaired punctuation marks, the second candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the third candidate split length of the text from the current text start position to the end of the unpaired punctuation mark's corresponding pair of punctuation marks in this split is greater than the split length threshold. If the third candidate split length is greater than the split length threshold, the second candidate split length is determined as the target split length for this text segmentation; if the third candidate split length is less than or equal to the split length threshold, the third candidate split length is determined as the target split length for this text segmentation.
3. The text processing method according to claim 1, characterized in that, When the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, determining the target splitting length for this text segmentation based on at least one determined constraint includes: Based on the speech reading time of the previous text-to-speech conversion, the maximum text length that can be obtained within the speech reading time is determined as the fourth candidate split length; Identify whether there are punctuation marks in the text starting from the current text start position and with a length equal to the fourth candidate split length; If punctuation marks are present, the fourth candidate split length is determined as the target split length for this text segmentation; if punctuation marks are not present, it is determined whether the fifth candidate split length of the text from the current text start position to the end of the text when the first punctuation mark appears is greater than the split length threshold. If the fifth candidate split length is greater than the split length threshold, the fourth candidate split length is determined as the target split length for this text segmentation; if the fifth candidate split length is less than or equal to the split length threshold, it is identified whether there are unpaired punctuation marks in the text within the fifth candidate split length. If there are no unpaired punctuation marks, the fifth candidate split length is determined as the target split length for this text segmentation; if there are unpaired punctuation marks, it is determined whether the sixth candidate split length of the text from the current text start position to the end of the unpaired punctuation mark's corresponding pair of punctuation marks in this split is greater than the split length threshold. If the sixth candidate split length is greater than the split length threshold, the fifth candidate split length is determined as the target split length for this text segmentation; if the sixth candidate split length is less than or equal to the split length threshold, the sixth candidate split length is determined as the target split length for this text segmentation.
4. The text processing method according to claim 3, characterized in that, The step of determining the maximum text length obtainable within the previous text-to-speech conversion time as the fourth candidate splitting length includes: Get the text conversion speed (converting text to speech), the speech output speed (outputting the converted speech), and the text acquisition speed (acquiring text). The overall processing speed is determined based on the text conversion speed, speech output speed, and text acquisition speed. The largest integer value determined by dividing the speech reading time by the overall processing speed is used as the fourth candidate split length.
5. The text processing method according to claim 1, characterized in that, The step of determining at least one constraint condition for the current text split length based on the text acquisition scenario type and the current text processing stage includes: When the text acquisition scenario type is a non-streaming output scenario, at least one constraint condition for determining the current text split length includes: the language type of the current text, the punctuation information contained in the text, the total text length, and the split length threshold.
6. The text processing method according to claim 5, characterized in that, When the text acquisition scenario type is a non-streaming output scenario, determining the target splitting length of the text segmentation based on at least one determined constraint includes: The initial split length is determined based on the language type of the current text and the total length of the text, and it is identified whether the length of the first text from the beginning of the current text to the first punctuation mark is less than the initial split length. If the length of the first text is greater than or equal to the initial split length, identify whether the length of the first text is greater than the split length threshold. If the length of the first text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the first text is not greater than the split length threshold, it is identified whether the first punctuation mark is an unpaired paired punctuation mark. If it is not an unpaired paired punctuation mark, the first text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the second text length is determined from the current text start position to the time when the paired punctuation mark corresponding to the unpaired paired punctuation mark appears in this split. Determine whether the length of the second text is greater than the split length threshold; If the length of the second text is greater than the splitting length threshold, the length of the first text is determined as the target splitting length for this text segmentation; if the length of the second text is less than or equal to the splitting length threshold, the length of the second text is determined as the target splitting length for this text segmentation.
7. The text processing method according to claim 6, characterized in that, When the length of the first text from the current text start position to the first occurrence of a punctuation mark is less than the initial split length, the text processing method further includes: Determine the third text length from the current text start position to the end of the target punctuation mark, where the text length first exceeds the initial split length; Identify whether the length of the third text is greater than the split length threshold; If the length of the third text is greater than the split length threshold, the initial split length is determined as the target split length; if the length of the third text is less than or equal to the split length threshold, it is identified whether the ending punctuation mark corresponding to the length of the third text is an unpaired paired punctuation mark. If it is not an unpaired paired punctuation mark, the third text length is determined as the target split length for this text segmentation; if it is an unpaired paired punctuation mark, the fourth text length is determined as the text length from the current text start position to the end of the paired punctuation mark corresponding to the unpaired paired punctuation mark in this segmentation. Determine whether the length of the fourth text is greater than the split length threshold; If the length of the fourth text is greater than the splitting length threshold, the length of the third text is determined as the target splitting length for this text segmentation; if the length of the fourth text is less than or equal to the splitting length threshold, the length of the fourth text is determined as the target splitting length for this text segmentation.
8. A text processing apparatus, applied in scenarios where text is converted into speech using a text-to-speech model, characterized in that, The text processing device includes: The first determining module is used to determine at least one constraint condition for the current text split length based on the text acquisition scenario type and the current text processing stage. When the first determining module determines at least one constraint condition for the current text split length based on the text acquisition scenario type and the current text processing stage, the first determining module is used to: When the text acquisition scenario type is a streaming output scenario and the current text processing stage is the first text split, the constraints for determining the current text split length include: the initial split length, the language type of the current text, the split length threshold, and the punctuation information contained in the text; When the text acquisition scenario type is a streaming output scenario and the current text processing stage is a non-first text splitting, the constraints for determining the current text splitting length include: the splitting length threshold, the speech reading time of the previous text converted to speech, and the punctuation information contained in the text; The second determining module is used to determine the target splitting length of the text segmentation based on at least one determined constraint condition. The splitting module is used to extract the target split length of text starting from the current text start position to obtain the target text.
Citation Information
Patent Citations
Text splicing method and device thereof
CN107766325A
Text-to-audio conversion method and device, computer equipment and storage medium
CN111312207A