Script template generation method and device, electronic equipment and storage medium

By acquiring the corpus content of preset dialogue templates, generating similar sentences, and splicing and filtering them, the problems of monotonous dialogue processes and large manual workload are solved, realizing the intelligent expansion and diversified generation of dialogue templates.

CN116541496BActive Publication Date: 2026-08-04VOICEAI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
VOICEAI TECH CO LTD
Filing Date
2023-04-24
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

Existing technologies often involve monotonous scripts and processes with a large amount of manual configuration work, resulting in a tedious and labor-intensive training process.

Method used

By acquiring the corpus content from the preset dialogue template, generating similar sentences and splicing them together, filtering and dividing them into modules, automatically expanding the dialogue flow, and generating the target dialogue template.

Benefits of technology

It enables intelligent expansion of the script process, generates diverse script templates, reduces the need for manual configuration, and improves the diversity and smoothness of the training process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116541496B_ABST
    Figure CN116541496B_ABST
Patent Text Reader

Abstract

The application provides a dialogue template generation method and device, electronic equipment and a storage medium. The dialogue template generation method can obtain corpus content of each preset dialogue module in a preset dialogue template, generate similar sentences corresponding to the corpus content in each preset dialogue module, splice the similar sentences according to the positions of the corresponding preset dialogue modules in the preset dialogue template to obtain an initial dialogue segment, obtain a target dialogue segment after screening the initial dialogue segment, divide the target dialogue segment into a target dialogue module including at least one sub-module, and thus realize intelligent expansion of the preset dialogue template without manual configuration, and solve the problems of single dialogue process content in the preset dialogue template and excessive manual workload.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a method, apparatus, electronic device, and storage medium for generating script templates. Background Technology

[0002] Human-computer interaction (HCI), as a fundamental technology for information exchange between humans and computers in the information age, has received widespread attention from academia and industry. In recent years, the field of HCI has developed rapidly, giving rise to many products, such as voice assistants, smart speakers, and voice-activated robots.

[0003] In projects with dialogue flows, the dialogue flow is usually configured first. Like a flow... Figure 1 This approach involves configuring pre-set dialogue routes based on the flow of the script. While this method can indeed achieve certain dialogue rules and processes, it also has significant limitations. Firstly, it requires a large amount of manual configuration; secondly, the scripts are relatively fixed and lack variety. For example, in a debt collection script training process, multiple people may practice this process during training, and each person may practice it more than once. If only one or a few pre-set scripts are displayed, the training process becomes too monotonous and tedious; if more possibilities are to be configured, the workload becomes too great. Summary of the Invention

[0004] In view of the above problems, this application provides a method, device, electronic device and storage medium for generating script templates, which can intelligently expand the content of the script process to address the problem of monotonous script flow, intelligently generate similar scripts, and combine them to generate more script flow, thereby realizing the generation of different script flow according to different business needs, solving problems such as monotonous script flow or excessive manual workload.

[0005] In a first aspect, embodiments of this application provide a method for generating a script template, the method comprising:

[0006] Obtain a preset dialogue template, which includes at least one preset dialogue module, and each preset dialogue module stores corpus content; generate similar sentences corresponding to the corpus content in each preset dialogue module; based on the position of the preset dialogue module in the preset dialogue template, concatenate the similar sentences to obtain an initial dialogue segment; filter the initial dialogue segment to obtain a target dialogue segment; divide the target dialogue segment into modules to obtain a target dialogue module including at least one sub-module.

[0007] Optionally, generating similar sentences corresponding to the corpus content in each of the preset dialogue modules includes: extracting semantic features from the corpus content of the preset dialogue modules; and generating similar sentences corresponding to the corpus content of the preset dialogue modules based on the semantic features.

[0008] Optionally, generating similar sentences corresponding to the corpus content in each of the preset dialogue modules includes: extracting target words from the corpus content of the preset dialogue modules; generating similar words corresponding to the target words; replacing the target words in the corpus content of the preset dialogue modules with the similar words, and generating similar sentences corresponding to the corpus content of the preset dialogue modules.

[0009] Optionally, the step of splicing the similar sentences based on the position of the preset dialogue module in the preset dialogue template to obtain an initial dialogue segment includes: calculating the similarity of similar sentences corresponding to the corpus content of the preset dialogue module based on the corpus content in the preset dialogue module, and obtaining the similarity corresponding to each similar sentence; obtaining target similar sentences with similarity exceeding a preset similarity threshold; and splicing the corresponding target similar sentences based on the position of each preset dialogue module in the preset dialogue template to obtain an initial dialogue segment.

[0010] Optionally, the step of concatenating the similar sentences based on the position of the preset dialogue module in the preset dialogue template to obtain an initial dialogue segment includes: generating tag information corresponding to the similar sentences, the tag information including the correspondence information between the similar sentences and the preset dialogue module, and the position information of the preset dialogue module in the preset dialogue template; adding the tag information to the corresponding similar sentences; and concatenating the similar sentences based on the tag information to obtain the initial dialogue segment.

[0011] Optionally, the method for generating tag information corresponding to the similar sentences includes a preset script module number and a similar sentence number. The method includes: generating a preset script module number based on the position of the preset script module in the preset script template; and generating a similar sentence number based on the position of the similar sentences in the same preset script module.

[0012] Optionally, the step of dividing the target speech segment into modules to obtain a target speech template including at least one sub-module includes: obtaining tag information of each similar sentence in the target speech segment; splitting the corresponding similar sentences in the target speech segment based on the tag information to obtain at least one sub-module, such that at least one sub-module constitutes the target speech template.

[0013] Optionally, the step of filtering the initial speech segments to obtain the determined speech segments includes: calculating the confusion level of the initial speech segments to obtain the confusion level of each initial speech segment; and determining the initial speech segments with a confusion level less than a preset threshold as the target speech segments.

[0014] Optionally, before calculating the perplexity of the initial speech segments to obtain the perplexity of each initial speech segment, the method further includes: deleting the tag information corresponding to the similar sentences from the initial speech segments.

[0015] Secondly, embodiments of this application provide a speech template generation device, comprising: an acquisition module for acquiring a preset speech template and acquiring the corpus content of each preset speech module in the preset speech template; a generation module for generating similar sentences corresponding to the corpus content in each preset speech module; a splicing module for splicing the similar sentences based on the position of the preset speech module in the preset speech template to obtain an initial speech segment; a filtering module for filtering the initial speech segment to obtain a target speech segment; and a splitting module for dividing the target speech segment into modules to obtain a target speech module including at least one sub-module.

[0016] Thirdly, embodiments of this application provide an electronic device, including: one or more processors and a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to perform the above-described script template generation method.

[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing program code, which can be called by a processor to execute the above-described script template generation method.

[0018] Compared to existing technologies, the method, apparatus, electronic device, and storage medium for generating script templates provided in this application can generate similar sentences corresponding to the corpus content of each preset script module in a preset script template by acquiring the corpus content of each preset script module; splice the similar sentences according to the position of the corresponding preset script module in the preset script template to obtain an initial script segment; filter the initial script segment to obtain a target script segment; divide the target script segment into modules to obtain a target script module including at least one sub-module, so that the generated target script template is similar to the preset script template and the generated target script template can be one or more, realizing intelligent expansion of the preset script template and solving the problem of the single script flow content in the preset script template; at the same time, the target script template is automatically generated according to the preset script template, without the need for manual configuration, solving the problem of excessive manual workload.

[0019] These or other aspects of this application will become more apparent in the following description of the embodiments. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a schematic block diagram illustrating the principle of an embodiment of this application.

[0022] Figure 2 This is a flowchart illustrating a method for generating a script template provided in an embodiment of this application.

[0023] Figure 3 These are schematic diagrams of two preset script templates.

[0024] Figure 4 This is provided by the embodiments of this application. Figure 2 A flowchart illustrating step S12.

[0025] Figure 5 This is provided by the embodiments of this application. Figure 2 Another flowchart of step S12.

[0026] Figure 6 This is provided by the embodiments of this application. Figure 2 A flowchart illustrating step S13.

[0027] Figure 7 This is provided by the embodiments of this application. Figure 2 A flowchart illustrating step S14.

[0028] Figure 8 This is provided by the embodiments of this application. Figure 2 Another flowchart of step S14.

[0029] Figure 9 This is provided by the embodiments of this application. Figure 2 A flowchart of step S15.

[0030] Figure 10 This is a flowchart illustrating a speech template generation method provided in another embodiment of this application.

[0031] Figure 11 This is a schematic diagram of a speech template generation device provided in an embodiment of this application.

[0032] Figure 12 This is a schematic diagram of an electronic device provided in an embodiment of this application.

[0033] Figure 13 This is a schematic diagram of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation

[0034] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0035] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.

[0036] Figure 1 A schematic block diagram illustrating the principle of an embodiment of this application is provided.

[0037] like Figure 1 As shown, this embodiment generates at least one target speech template based on a pre-configured preset speech template. By acquiring the corpus content of each preset speech module in the preset speech template, similar sentences corresponding to the corpus content in each preset speech module are generated. These similar sentences are then concatenated according to the position of the corresponding preset speech module in the preset speech template to obtain an initial speech segment. The initial speech segment is then filtered to obtain a target speech segment. The target speech segment is then divided into modules to obtain a target speech module including at least one sub-module. This achieves the generation of at least one target speech template based on the preset speech template, and the generated target speech template is similar to the preset speech template. This realizes intelligent expansion of the preset speech template, solves the problem of the speech flow content being too simple in the preset speech template, and the target speech template is automatically generated based on the preset speech template, eliminating the need for manual configuration and solving the problem of excessive manual workload.

[0038] Since there is at least one generated target dialogue template, multiple target dialogue templates can be configured for the same trigger condition, so that one of the multiple target dialogue templates can be called each time, thereby increasing the richness of dialogue template calls; different trigger conditions can also be configured for the multiple generated target dialogue templates, thereby calling different target dialogue templates according to different trigger conditions, improving the richness of trigger scenarios.

[0039] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0040] Firstly, such as Figure 2 As shown, Figure 2 This application provides an embodiment of a method for generating a script template, which includes:

[0041] S11. Obtain a preset dialogue template. The preset dialogue template includes at least one preset dialogue module, and each preset dialogue module stores corpus content.

[0042] Among them, a preset dialogue template refers to a dialogue template composed of at least one preset dialogue module, which forms different dialogue flows based on different trigger conditions. The preset dialogue template can be invoked by setting trigger conditions; the dialogue flow refers to the order in which the preset dialogue modules are executed.

[0043] The preset dialogue module may include corpus content and configuration file. The corpus content includes a complete dialogue segment, which can be a single sentence or a segment composed of multiple sentences. The configuration file is used to configure each preset dialogue module. For example, the configuration file can configure the broadcast speed and tone of the corpus content in the preset dialogue module, or the response time of the preset dialogue module.

[0044] Obtaining a preset dialogue template may include obtaining the corpus content stored in each preset dialogue module within the preset dialogue template, and may also include obtaining the configuration file of each preset dialogue module; if there are multiple dialogue flows in the preset dialogue template, obtaining the preset dialogue template may also include obtaining the trigger condition configuration file of different dialogue flows in the preset dialogue template.

[0045] In some implementations, the preset script template includes a preset script module, which can form a script flow.

[0046] In other implementations, the preset script template includes multiple preset script modules, which are arranged in the preset script template according to the script flow.

[0047] Within the same pre-set script template, multiple pre-set script modules can form a single script flow or multiple script flows. For example... Figure 3 , Figure 3 Two sample diagrams of preset script templates are provided as examples.

[0048] For example, such as Figure 3-IIn one possible implementation, the preset script template A includes preset script module a, preset script module b, and preset script module c. The three preset script modules form a script flow and are arranged in the preset script template A according to the direction of the script flow. During the execution of the preset script template A, the three preset script modules are executed in sequence according to the order of preset script module a → preset script module b → preset script module c, thereby realizing a complete script flow.

[0049] In another possible implementation, multiple preset modules within the same preset script template can form multiple script flows; for example, such as... Figure 3-II In the preset script template A, there are three preset script modules: preset script module a, preset script module b, and preset script module c. These three preset script modules form two script flows: script flow R and script flow L. Script flow R includes preset script modules a, b, and c, and is executed in the order a→b→c. Script flow L includes preset script modules a and c, and is executed in the order a→c. After preset script module a completes execution, a flow selection is required to choose between script flow R and script flow L, resulting in different flow directions. This flow selection can be achieved by configuring different trigger conditions, which are not specifically limited here.

[0050] S12. Generate similar sentences that correspond to the corpus content in each preset speech module;

[0051] There are several ways to generate similar sentences corresponding to the corpus content in each preset dialogue module. For example, semantic recognition can be performed on the corpus content in each preset dialogue module, and similar sentences with similar semantics can be generated based on the semantic recognition results. Alternatively, keywords in the corpus content in each preset dialogue module can be replaced to generate similar sentences with similar structures.

[0052] In one possible implementation, such as Figure 4 , Figure 4 The embodiments provided in this application are given Figure 2 The flowchart of step S12 is shown below. Step S12 may include steps S121-S122, which include:

[0053] S121. Extract semantic features from the corpus content of the preset dialogue module;

[0054] In particular, the semantic features obtained by extracting features from the corpus content of the preset speech module can be achieved using a feature extractor; the feature extractor can be an RNN (Recurrent Neural Network), a CNN (Convolutional Neural Network), or a Transformer model, etc., without specific limitations.

[0055] For example, semantic features may include feature entities, subordinate features, composite features, etc., without specific limitations here.

[0056] S122. Based on semantic features, generate similar sentences that correspond to the corpus content of the preset speech module.

[0057] For example, when the corpus content of the preset dialogue module is "The weather seems nice today", the corpus content is input into the Transformer model. The Transformer model first segments the corpus content into words, obtaining phrases such as "today", "weather", "seems", and "nice". Then, it extracts semantic features from the above phrases, obtaining semantic features such as "today", "weather", and "nice". Then, it inputs the semantic features such as "today", "weather", and "nice" into the seq2seq model (Sequence to Sequence model) to generate N similar sentences (N is a positive integer), obtaining similar sentences such as "Today is a good day" and "The weather is great today".

[0058] Furthermore, the number of similar sentences generated and the selection threshold can be preset to achieve preliminary screening of the generated similar sentences; for example, the number of similar sentences generated for each corpus content can be preset to 10 and the selection threshold to 3, that is, 10 similar sentences are generated for the same corpus content, and the first three generated similar sentences are selected for retention.

[0059] In another possible implementation, such as Figure 5 , Figure 5 The embodiments provided in this application are given Figure 2 Another flowchart of step S12, which may include steps S123-S125, includes:

[0060] S123. Extract target words from the corpus content of the preset dialogue module;

[0061] Here, target vocabulary refers to the words that are expected to be updated in the corpus content of the preset dialogue module. There are several ways to extract target vocabulary. For example, target vocabulary in the corpus content of the preset dialogue module can be marked with uniform symbols, or specific string conditions can be set, and words that meet the specified string conditions can be used as target vocabulary. The target vocabulary can then be extracted using regular expressions, thereby realizing the extraction of target vocabulary from the corpus content of the preset dialogue module.

[0062] For example, the target words in the corpus content of the preset dialogue module are marked with percent signs, such as "Tomorrow I am going to %Shanghai% on a business trip". In this case, the word "Shanghai" between the two percent signs is the target word. The target word "Shanghai" is extracted from the corpus content of the preset dialogue module by regular expression extraction.

[0063] S124. Generate similar words to the target words;

[0064] There are several ways to generate similar words. For example, one can use a synonym word mapping method to find synonyms that match the target word in the synonym word list, thereby generating similar words; or one can use the BERT model (Bidirectional Encoder Representations from Transformers model, i.e., deep bidirectional pre-trained Transformer based on semantic understanding) to input the target word into the BERT model to generate similar words. No specific limitations are made here.

[0065] S125. Replace the target words in the corpus content of the preset speech module with similar words to generate similar sentences that correspond to the corpus content of the preset speech module.

[0066] Understandably, using similar words to replace target words in the corpus content of the preset discourse module to generate similar sentences does not change the sentence structure of the corpus content. At the same time, when it is not desired to change the sentence structure of the corpus content, compared with semantic analysis of the entire corpus content to generate similar sentences, using similar words to replace target words to generate similar sentences reduces the computational load of the model and improves the generation efficiency of similar sentences.

[0067] For example, when the target word "Shanghai" is input into the BERT model, the place name attribute in the target word "Shanghai" is identified, and similar words such as "Beijing" and "Chengdu" are generated. The target word "Shanghai" in "Tomorrow I am going to %Shanghai% on a business trip" is replaced by similar words such as "Tomorrow I am going to Beijing on a business trip" or "Tomorrow I am going to Chengdu on a business trip". It can be seen that the sentence structure of the generated similar sentences has not changed compared with the corresponding corpus content.

[0068] Furthermore, in some embodiments, the number of similar words generated and the selection threshold can be preset to achieve preliminary screening of similar words; for example, the number of similar words generated for each target word can be preset to 10 and the selection threshold to 3, that is, 10 similar words are generated for the same target word, and the first three similar words are selected to replace the target word to obtain the corresponding three similar sentences.

[0069] S13. Based on the position of the preset speech module in the preset speech template, similar sentences are spliced ​​together to obtain the initial speech segment;

[0070] The position of the preset dialogue module within the preset dialogue template corresponds to the execution order of each preset dialogue module in the dialogue flow. Since the similar sentences in the initial dialogue segment are pieced together based on the positions of the preset dialogue modules within the preset dialogue template, in other words, the order of the similar sentences corresponding to a preset dialogue module in the initial dialogue segment is consistent with the order of the preset dialogue module in the dialogue flow.

[0071] Understandably, since the corpus content of the same preset speech module can generate multiple similar sentences, when splicing together to form an initial speech segment, each initial speech segment needs to extract one of the multiple similar sentences corresponding to each preset speech module for splicing, thereby splicing together at least one initial speech segment.

[0072] In one possible implementation, such as Figure 6 , Figure 6 The embodiments provided in this application are given Figure 2 The flowchart of step S13 is shown below. Step S13 may include steps S131-S133, and steps S131-S133 include:

[0073] S131. Generate tag information corresponding to similar sentences. The tag information includes the correspondence information between similar sentences and preset speech modules, as well as the position information of preset speech modules in preset speech templates.

[0074] The correspondence information between similar sentences and preset dialogue modules includes the subordinate relationship between similar sentences and preset dialogue modules, that is, the similar sentence is generated from the corpus content of a certain preset dialogue module; it also includes the positional relationship of the similar sentence among multiple similar sentences in the same preset dialogue module, that is, the nth similar sentence generated from the corpus content of the corresponding preset dialogue module.

[0075] The position information of the preset dialogue module in the preset dialogue template is also the order in which the preset dialogue modules are executed in the dialogue flow.

[0076] Specifically, the tag information includes the preset script module number and similar sentence number, and the tag information generation steps include:

[0077] Generate preset script module numbers based on the position of the preset script module in the preset script template;

[0078] Similar sentence numbers are generated based on their position within the same preset script module.

[0079] For example, in some implementations, a preset dialogue template A includes three preset dialogue modules. During the execution of preset dialogue template A, the three preset dialogue modules are executed sequentially in the order of preset dialogue module a → preset dialogue module b → preset dialogue module c. Therefore, the preset dialogue module number of preset dialogue template a is set to 1, the preset dialogue module number of preset dialogue template b is set to 2, and the preset dialogue module number of preset dialogue template c is set to 3. For the first similar sentence generated by preset dialogue module a, the similar sentence number is 1, and the similar sentence number of the second similar sentence generated by preset dialogue module a is set to 2. Therefore, the complete tag information of a similar sentence, such as 1-1, which represents the first similar sentence generated by preset dialogue module a, can include the correspondence information between the similar sentence and the preset dialogue module, as well as the position information of the preset dialogue module in the preset dialogue template.

[0080] In other possible implementations, if multiple preset modules in the same preset script template can form multiple script processes, the tag information also needs to include the script process information corresponding to the similar sentence. In this implementation, the script process information is represented in the form of a process number.

[0081] For example, a preset dialogue template A includes preset dialogue module a, preset dialogue module b, and preset dialogue module c. Preset dialogue module a → preset dialogue module b → preset dialogue module c forms a dialogue flow R, and preset dialogue module a → preset dialogue module c forms a dialogue flow L. A complete tag information also needs to be added with a flow number, such as R1-1, which represents the first similar sentence generated by preset dialogue module a in dialogue flow R; L1-2, which represents the second similar sentence generated by preset dialogue module a in dialogue flow L.

[0082] S132. Add the tag information to the corresponding similar sentences;

[0083] It is understandable that the tag information of similar sentences is uniquely determined, and there is a one-to-one correspondence between the tag information and similar sentences. Furthermore, the tag information corresponding to different similar sentences must be different.

[0084] S133. Based on the tag information, similar sentences are spliced ​​together to obtain the initial speech segment.

[0085] Understandably, identifying the tag information can uniquely determine the corresponding similar sentences.

[0086] For example, in some implementations, when splicing multiple similar sentences, if the preset template A has only one uniquely determined speech flow, then the tag information corresponding to the multiple similar sentences is obtained, such as 1-1, 1-2, 2-1, 2-2, and 3-1. Since the three preset speech modules of the preset speech template A only form one speech flow, i.e., 1→2→3, during splicing, the similar sentence with the preset speech module number 1 in the tag information is first obtained, such as 1-1 and 1-2, and then the similar sentence with the preset speech module number 1 in the tag information is obtained. Select a similar sentence from the similar sentences with a value of 1, such as 1-1; similarly, obtain the similar sentences with the preset speech module number 2 in the tag information, such as 2-1 and 2-2, and then select a similar sentence from the similar sentences with the preset speech module number 2 in the tag information, such as 2-2; similarly, obtain 3-1, thus obtaining the initial speech segment formed by splicing the three similar sentences corresponding to 1-1→2-2→3-1, so that each similar sentence in the initial speech segment is spliced ​​according to the position of the corresponding preset speech module in the preset speech template.

[0087] In other possible implementations, if multiple preset modules within the same preset script template form multiple script flows, then when splicing the generated multiple similar sentences, the tag information corresponding to the multiple similar sentences is first obtained, such as R1-1, R1-2, R2-1, R2-2 and R3-1, and L1-1, L1-2 and L3-1. Since the three preset script modules of preset script template A form script flows R and L, script flow R is 1→2→3, and script flow L is 1→3; when splicing to form the initial script segment, the tags are first obtained. The process number in the information, such as L, yields three similar sentences: L1-1, L1-2, and L3-1. Then, the similar sentence with the preset script module number 1 is obtained, resulting in L1-1 and L1-2. Next, a similar sentence is selected from the similar sentences with the preset script module number 1 in the tag information, such as L1-1. Similarly, L3-1 is obtained. Thus, the initial script segment is formed by splicing the two similar sentences corresponding to L1-1→L3-1. This ensures that each similar sentence in the initial script segment is spliced ​​according to the position of the corresponding preset script module in the preset script template.

[0088] S134. Filter the initial script segments to obtain the target script segments;

[0089] There are several ways to screen initial speech segments. One method is to use a language model to detect the fluency of the initial speech segments and obtain the initial speech segments with higher fluency as target speech segments. Another method is to use an external model to calculate the probability of occurrence of keywords in the initial speech segments and the collocation distance between each keyword, and select the initial speech segments with high probability of occurrence of keywords and collocation distance between each keyword within a preset range as target speech segments.

[0090] In one possible implementation, such as Figure 7 , Figure 7 The embodiments provided in this application are given Figure 2 The flowchart of step S14 is shown below. Step S14 includes steps S141-S142, and steps S141-S142 include:

[0091] S141. Calculate the confusion level of the initial speech segments to obtain the confusion level of each initial speech segment;

[0092] Understandably, since each similar sentence in the initial dialogue segment corresponds to the expected content of a different preset dialogue module, and the corpus content of one preset dialogue module can generate multiple similar sentences, the multiple initial dialogue segments obtained by combining and splicing the multiple similar sentences corresponding to each preset dialogue module are different. For the same dialogue flow of the same preset dialogue template, although the splicing order of each generated initial dialogue segment is consistent, the different similar sentences will lead to different fluency of each initial dialogue segment.

[0093] For example, the obtained initial speech segments can be directly fed into a trained language model for calculation to obtain the probability of the initial speech segments. For example, the language model can be a BERT model or an N-gram model. When the trained language model is uniquely determined, the fluency of the initial speech segments can be characterized by calculating the perplexity PPL (perplexity is generally used to evaluate the quality of a language model).

[0094] S142. The initial speech segment with a confusion level less than the preset threshold is identified as the target speech segment.

[0095] Understandably, the lower the confusion score, the higher the fluency of the initial speech segment. Initial speech segments with a confusion score lower than the confusion threshold are identified as target speech segments, thereby obtaining target speech segments with high fluency.

[0096] The perplexity threshold can be preset in the language model or set according to actual needs during each calculation. By determining the initial speech segment with a perplexity less than the preset perplexity threshold as the target speech segment, the fluency of the target speech template is guaranteed. At the same time, since the perplexity value ranges from 1 to positive infinity, the introduction of perplexity makes it easier to set the specific value of the threshold.

[0097] In another possible implementation, such as Figure 8 , Figure 8 The embodiments provided in this application are given Figure 2 Another flowchart of step S14 is shown. Step S14 also includes step S140, which is located before steps S141-S142.

[0098] S140. Delete the tag information corresponding to similar sentences from the initial speech segment.

[0099] The deletion of tag information can be done by directly deleting all tag information in the initial speech segment, or by extracting the tag information from the initial speech segment to obtain a tag information file. The final effect is to ensure that the initial speech segment of the input language model does not contain tag information. The specific method is not limited here.

[0100] It is understandable that, since the label information of each similar sentence only represents the positional information of each similar sentence and has no semantic connection with the content of the corresponding similar sentence, the label information will affect the perplexity result of the initial speech segment when calculating the perplexity. Therefore, deleting the label information contained in the initial speech segment before feeding it into the language model can make the fluency result of the initial speech segment more accurate.

[0101] S15. Divide the target speech segment into modules to obtain a target speech module that includes at least one sub-module.

[0102] Understandably, since the target dialogue template and the preset dialogue template are similar, each sub-module corresponds one-to-one with the preset dialogue module. If the preset dialogue template includes one preset dialogue module, then the target dialogue template includes one corresponding sub-module; if the preset dialogue template has multiple preset dialogue modules, then the target dialogue template includes multiple corresponding sub-modules. Modularizing the target dialogue segment involves finding the preset dialogue modules corresponding to each similar sentence in the target dialogue segment, thereby finding the sub-modules corresponding to those similar sentences. This allows for modularizing each similar sentence in the target dialogue segment, resulting in a target dialogue module that includes at least one sub-module.

[0103] The module division of the target speech segment can be achieved by identifying the correspondence between similar sentences and preset speech modules through tag information, or by performing semantic recognition on each similar sentence and matching the semantic recognition results with preset speech modules.

[0104] In one possible implementation, such as Figure 9 , Figure 9 The embodiments provided in this application are given Figure 2 The flowchart of step S15 is shown below. Step S15 includes steps S151-S152, and steps S151-S152 include:

[0105] S151. Obtain the tag information of each similar sentence in the target speech segment;

[0106] Understandably, if the tag information is completely deleted when filtering the initial speech segment, the tag information needs to be regenerated and added back to the corresponding similar sentences. If the tag information is extracted from the initial speech segment when filtering the initial speech segment, the tag information can be reassigned to the corresponding similar sentences.

[0107] S152. Based on the tag information, the corresponding similar sentences in the target speech segment are split to obtain at least one sub-module, so that at least one sub-module forms the target speech template.

[0108] Specifically, if at least one preset script module of the preset script template forms only one script flow, that is, one preset script module included in the preset script template forms one script flow, or multiple preset script modules included in the preset script template form one script flow; in this case, the tag information of each similar sentence in the target script segment is obtained, specifically, the preset script module number in the tag information is obtained, and the position of the preset script module corresponding to the similar sentence in the preset script template is determined according to the preset script module number. Then, according to the position of the preset script module in the preset script template, the position of the corresponding sub-module is determined, and the similar sentence is split into the sub-module; by splitting each similar sentence in the target script segment, at least one sub-module is obtained, and at least one sub-module constitutes the target script template.

[0109] If multiple preset script modules of a preset script template form multiple script flows, it is also necessary to obtain the script flow number in the tag information, and then determine the script flow corresponding to the target script segment based on the script flow number. Then, the position of the preset script module corresponding to the similar sentence in the script flow is confirmed by the preset script module number in the tag information. Based on the position of the preset script module in the preset script template, the position of the corresponding sub-module is determined, and the similar sentence is split into the sub-module. By splitting each similar sentence in the target script segment, multiple sub-modules are obtained, and multiple sub-modules form the target script template.

[0110] It is understandable that the position of the submodule in the target script template is based on the position of the preset script module in the preset script template. In other words, the target script template and the preset script template have the same script flow.

[0111] Therefore, the speech template generation method provided in this application can generate similar sentences corresponding to the corpus content of each preset speech module in a preset speech template by obtaining the corpus content of each preset speech module; by adding tag information to the generated similar sentences, the similar sentences are spliced ​​together according to the position of the corresponding preset speech module in the preset speech template to obtain an initial speech segment; the initial speech segment is filtered to obtain a target speech segment; and the target speech segment is divided into modules according to the tag information to obtain a target speech module including at least one sub-module, so that the target speech template has the same speech flow as the preset speech template, and the expected content in the sub-module is similar to the corpus content of the corresponding preset speech module. This realizes the intelligent expansion of the preset speech template without manual configuration, and solves the problems of the single speech flow content in the preset speech template and the excessive workload of manual processing.

[0112] like Figure 10 , Figure 10 A flowchart illustrating another embodiment of the speech template generation method provided in this application is given. The following will focus on... Figure 10 The process shown will be explained in detail. The method for generating the script template may specifically include the following steps:

[0113] S21. Obtain a speech template. The preset speech template includes at least one preset speech module, and each preset speech module stores speech content.

[0114] S22. Generate similar sentences that correspond to the corpus content in each of the preset speech modules;

[0115] In this embodiment, steps S21-S22 can refer to the content of steps S11-S12 in the previous embodiment, and will not be repeated here.

[0116] S23. Based on the corpus content in the preset dialogue module, calculate the similarity of similar sentences corresponding to the corpus content of the preset dialogue module, and obtain the similarity of each similar sentence.

[0117] Similarity is used to compare the similarity between two things; it is generally obtained by calculating the distance between the features of the things. If the distance is small, the similarity is large; if the distance is large, the similarity is small.

[0118] It is understandable that the raw material content of the same preset speech module can generate at least one similar sentence. For multiple similar sentences generated by the same preset speech module, it is necessary to calculate the similarity with the corpus content in the corresponding preset speech module.

[0119] There are several ways to calculate the similarity of similar sentences. For example, the corpus content of the preset speech module and a corresponding generated similar sentence can be input into the similarity calculation model to obtain the similarity of the sentence. Specifically, the similarity calculation model can be Jaccard similarity coefficient, COS similarity, or Manhattan distance, etc., without being specifically limited here.

[0120] S24. Obtain target similar sentences with a similarity exceeding a preset similarity threshold;

[0121] The similarity threshold can be pre-set in the similarity calculation model or set according to actual needs for each calculation. Specifically, the higher the similarity, the better the corresponding similar sentence.

[0122] Understandably, by calculating the similarity of similar sentences and then concatenating target similar sentences with similarity exceeding a preset similarity threshold, the number of similar sentences can be reduced; that is, the number of target similar sentences will be less than the number of generated similar sentences. This achieves further filtering of similar sentences.

[0123] S25. Based on the position of each preset speech module in the preset speech template, the corresponding target similar sentences are spliced ​​together to obtain the initial speech segment.

[0124] In this application embodiment, the specific implementation of step S25 can be referred to the content of step S13 in the aforementioned embodiment, and will not be repeated here. The only difference is that step S25 is based on the target similar sentence, while step S13 is based on the similar sentence.

[0125] S26. Filter the initial speech segment to obtain the target speech segment;

[0126] S27. Divide the target speech segment into modules to obtain a target speech module that includes at least one sub-module.

[0127] In this embodiment, steps S26-S27 can refer to the content of steps S14-S15 in the previous embodiment, and will not be repeated here.

[0128] Therefore, the method provided in this embodiment, after filtering out the target similar sentences, performs subsequent splicing on the target similar sentences, which reduces the number of similar sentences that need to be spliced, thus improving the splicing efficiency of similar sentences, i.e. the generation efficiency of the initial speech segment; at the same time, since the number of generated initial speech segments is reduced, it is easier to calculate the confusion degree of the initial speech segments and filter out the target speech segments, thereby improving the generation efficiency of the target speech template.

[0129] Secondly, correspondingly, such as Figure 11 , Figure 11 This application provides an embodiment of a script template generation device 1100. The script template generation device 1100 includes:

[0130] The acquisition module 1110 is used to acquire the preset speech template and the corpus content of each preset speech module in the preset speech template;

[0131] It is understandable that the acquisition module 1110 can also acquire configuration files and trigger condition configurations of preset script modules in each preset script module; furthermore, the acquisition module 1110 can acquire configuration files in each preset script module at the same time, or can acquire configuration files of some preset script modules according to actual needs.

[0132] The generation module 1120 is used to generate similar sentences that correspond to the corpus content in each of the preset speech modules;

[0133] It is understandable that the generation module 1120 can also be used to generate tag information corresponding to the similar sentence and add the tag information to the corresponding similar sentence.

[0134] The splicing module 1130 splices the similar sentences based on the position of the preset speech module in the preset speech template to obtain an initial speech segment;

[0135] Understandably, the splicing module 1130 is used to identify tag information in similar sentences and splice each similar sentence according to the tag information to obtain the initial speech segment.

[0136] The filtering module 1140 is used to filter the initial speech segment to obtain the target speech segment;

[0137] It is understandable that the filtering module 1140 is used to calculate the perplexity of the initial speech segment and select the initial speech segment with a perplexity lower than the perplexity threshold as the target speech segment; the filtering module 1140 can also be used to extract the label information in the initial speech segment as a whole before calculating the perplexity of the initial speech segment, so that the label information is not included when calculating the perplexity of the initial speech segment.

[0138] The splitting module 1150 is used to divide the target speech segment into modules to obtain a target speech module including at least one sub-module.

[0139] Understandably, the splitting module 1150 can obtain the tag information extracted by the filtering module 1140 and reassign the tag information to the corresponding similar sentences. After reassigning the tag information to the corresponding similar sentences, the splitting module 1150 is used to split each similar sentence into modules according to the content of the tag information, split each similar sentence into different sub-modules, and obtain a target speech module including at least one sub-module.

[0140] Thirdly, correspondingly, such as Figure 12 This application also provides an electronic device 1200, which can be a smartphone, tablet computer, smart speaker, or other electronic device capable of running applications. The electronic device 1200 may include one or more processors 1210, a memory 1220, and one or more applications, wherein the one or more applications are stored in the memory 1220 and configured to be executed by the one or more processors 1210, and the one or more applications are configured to perform the aforementioned speech template generation method.

[0141] It is understood that the processor 1210 and the memory 1220 are connected via a communication bus to complete mutual communication. The processor 1210 can call the logical instructions in the memory 1220 to execute the speech template generation method described in any of the foregoing embodiments. For example, the processor 1210 can be implemented using a general-purpose CPU, microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits to execute related programs to implement the technical solution provided in this application. The memory can be implemented in the form of ROM (Read-Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc.

[0142] Fourthly, correspondingly, such as Figure 13This application embodiment also provides a computer-readable storage medium 1300, which stores program code 1310, and the program code 1310 can be called by a processor to execute the above-described speech template generation method.

[0143] It is understood that the logical instructions in the aforementioned memory 1220 can be implemented in the form of software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium 1300.

[0144] Part of this 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 invention. 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.

[0145] The above are merely preferred embodiments of this application and are not intended to limit this application in any way. Although this application has disclosed preferred embodiments as above, it is not intended to limit this application. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the technical solution of this application. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of this application without departing from the scope of the technical solution of this application shall still fall within the scope of the technical solution of this application.

Claims

1. A method for generating a script template, the method comprising: The method includes: A preset dialogue template is obtained, which includes multiple preset dialogue modules, each storing corpus content. The multiple preset dialogue modules are arranged in the preset dialogue template according to a dialogue flow, which reflects the execution order of each preset dialogue module. The corpus content in one preset dialogue module includes a sentence or a sentence segment composed of multiple sentences. Multiple preset dialogue modules in the same preset dialogue template form multiple dialogue flows, and at least one preset dialogue module in one preset dialogue template is located at the intersection of two dialogue flows. Each preset dialogue template corresponds to a trigger condition configuration file, which indicates the trigger conditions for the preset dialogue template to flow to different dialogue flows after passing through the preset dialogue module located at the intersection. Generate similar sentences that correspond to the corpus content in each of the preset speech modules; Generate tag information corresponding to the similar sentences. The tag information includes the correspondence information between the similar sentences and the preset dialogue module, the position information of the preset dialogue module in the preset dialogue template, and the dialogue flow information corresponding to the similar sentences. Add the tag information to the corresponding similar sentence; Based on the tag information, a similar sentence corresponding to each of the preset dialogue modules in the same preset dialogue template is concatenated to obtain an initial dialogue segment; the position of the preset dialogue module in the preset dialogue template refers to the order in which the preset dialogue module is executed in the dialogue flow; the order of similar sentences corresponding to a preset dialogue module in the initial dialogue segment is consistent with the order of the preset dialogue module in the dialogue flow; The initial speech segments are filtered to obtain the target speech segments; Based on the tag information of each similar sentence in the target speech segment, the target speech segment is divided into modules to obtain a target speech module that includes sub-modules that correspond one-to-one with the preset speech module.

2. The method of claim 1, wherein, The generation of similar sentences corresponding to the corpus content in each of the preset speech modules includes: Semantic features are obtained by extracting features from the corpus content of the preset speech module; Based on the semantic features, similar sentences corresponding to the corpus content of the preset speech module are generated.

3. The method of claim 1, wherein, The generation of similar sentences corresponding to the corpus content in each of the preset speech modules includes: Extract target words from the corpus content of the preset speech module; Generate similar words to the target words; The target words in the corpus of the preset speech module are replaced with the similar words to generate similar sentences that correspond to the corpus of the preset speech module.

4. The method of claim 1, wherein, Before concatenating the similar sentences based on the tag information to obtain the initial speech segment, the method further includes: Based on the corpus content in the preset speech module, similarity is calculated for similar sentences corresponding to the corpus content of the preset speech module, and the similarity is obtained for each similar sentence. Obtain target similar sentences with a similarity exceeding a preset similarity threshold; The step of concatenating similar sentences based on the tag information to obtain an initial speech segment includes: Based on the tag information, the corresponding target similar sentences are spliced ​​together to obtain the initial speech segment.

5. The method of claim 1, wherein, The tag information includes a preset script module number and a similar sentence number. Generating tag information corresponding to the similar sentences includes: A preset dialogue module number is generated based on the position of the preset dialogue module in the preset dialogue template; Similar sentence numbers are generated based on the position of the similar sentences within the same preset script module.

6. The method of claim 1, wherein, The process of filtering the initial speech segments to obtain the target speech segments includes: The confusion level of each initial speech segment is calculated. Initial speech segments with a confusion level less than a preset threshold are identified as target speech segments.

7. The method of claim 6, wherein, Before calculating the perplexity of the initial speech segments to obtain the perplexity of each initial speech segment, the method further includes: deleting the tag information corresponding to the similar sentences from the initial speech segments.

8. A speech template generation device, characterized in that, include: The acquisition module is used to acquire a preset dialogue template, which includes multiple preset dialogue modules, and each preset dialogue module stores corpus content. The multiple preset dialogue modules are arranged in the preset dialogue template according to the dialogue flow, and the dialogue flow reflects the order in which each preset dialogue module is executed. The corpus content in one of the preset dialogue modules includes a sentence or a sentence segment composed of multiple sentences; multiple preset dialogue modules in the same preset dialogue template form multiple dialogue processes, and at least one preset dialogue module in one preset dialogue template is located at the intersection of two dialogue processes; Each of the preset script templates has a corresponding trigger condition configuration file, which indicates the trigger conditions for the preset script template to flow to different script processes after passing through the preset script module located at the intersection. A generation module is used to generate similar sentences that correspond to the corpus content in each of the preset speech modules; The splicing module is used to generate tag information corresponding to the similar sentences. The tag information includes the correspondence information between the similar sentences and the preset speech module, the position information of the preset speech module in the preset speech template, and the speech flow information corresponding to the similar sentences. Add the tag information to the corresponding similar sentence; Based on the tag information, the similar sentences corresponding to all preset speech modules in the same preset speech template are spliced ​​together to obtain an initial speech segment; The position of the preset dialogue module in the preset dialogue template refers to the order in which the preset dialogue module is executed in the dialogue flow; the order of similar sentences corresponding to a preset dialogue module in the initial dialogue segment is consistent with the order of the preset dialogue module in the dialogue flow. The filtering module is used to filter the initial speech segment to obtain the target speech segment; The splitting module is used to divide the target speech segment into modules based on the tag information of each similar sentence in the target speech segment, so as to obtain a target speech module that includes sub-modules that correspond one-to-one with the preset speech module.

9. An electronic device, characterized in that, include: One or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications being configured to perform the speech template generation method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains program code, which can be called by a processor to execute the speech template generation method as described in any one of claims 1-7.