Generation method of verbal skill template, verbal skill generation method and related products
By obtaining and analyzing session data, determining intent key statements to generate matching speech templates, the problem of mismatch between conversation roles and intentions in speech robots is solved, and the quality and usage effect of speech templates are improved.
Patent Information
- Application Number
- CN202411061307.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-12-17
AI Technical Summary
In the prior art, when a voice robot uses a speech template, the conversation role does not match the conversation intention, resulting in poor use of the speech template.
By obtaining the session data of the session role in the first time period, the session intention of each session statement is determined, and the intent key statement is determined from the session statement corresponding to the intent, and a speech template matching the session intention is generated.
Ensure that the generated speech template matches the conversation intentions of the conversation character, improves the quality and practicality of the speech template and improves the effect of intelligent conversation.
Smart Images

Figure CN119150829A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method for generating a speech template, a speech generation method, and related products. Background Art
[0002] In recent years, more and more artificial intelligence products have begun to appear, and voice robots have been used more and more widely in various industries, such as the automotive industry, education industry, and Internet industry, which use telephone sales. The autonomous dialogue method of voice robots can shorten the cycle of answering customer questions and improve business service efficiency. Voice robots usually use speech templates for dialogue. The quality of speech templates (such as whether the semantics are smooth and whether they can solve customer problems, etc.) plays a vital role. Therefore, how to build high-quality speech templates has become one of the urgent problems to be solved in the field of intelligent dialogue. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a method for generating a speech template, a speech generation method and related products, so as to solve the problem that the speech template of the conversation role does not match the conversation intention, resulting in poor use effect of the speech template.
[0004] To solve the above technical problems, the embodiments of the present application are implemented as follows:
[0005] On the one hand, an embodiment of the present application provides a method for generating a speech template, including:
[0006] Acquire conversation data of the conversation role in a first time period; the conversation data includes a plurality of conversation statements;
[0007] Determining a conversation intention of each conversation statement in the conversation data;
[0008] For each conversation intention, determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention;
[0009] According to the key sentences of the intention, a speech template of the conversation intention corresponding to the conversation role is generated.
[0010] On the other hand, an embodiment of the present application provides a method for generating speech, including:
[0011] Obtain the conversation statement of the first user;
[0012] determining a first conversation intention of the first user according to the conversation statement and the role information of the first user;
[0013] Determine a first speech template that matches the first conversation intention; wherein the first speech template is generated according to the speech template generation method described in the above aspect;
[0014] Based on the conversation sentence and the first speech template, generate a speech text corresponding to the conversation sentence.
[0015] On the other hand, the embodiment of the present application provides a device for generating a speech template, including:
[0016] An acquisition module, configured to acquire the conversation data of the conversation role in a first time period; the conversation data includes a plurality of conversation statements;
[0017] A determination module, configured to determine the conversation intention of each conversation sentence in the conversation data; for each conversation intention, determine the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention;
[0018] A generation module is used to generate a speech template of the conversation intention corresponding to the conversation role according to the key sentence of the intention.
[0019] On the other hand, the embodiment of the present application provides a speech generation device, including:
[0020] An acquisition module, used to acquire a conversation statement of the first user;
[0021] a determination module, configured to determine a first conversation intention of the first user according to the conversation statement and the role information of the first user; and determine a first speech template matching the first conversation intention; wherein the first speech template is generated according to the speech template generation method described in the above aspect;
[0022] A generation module is used to generate a speech text corresponding to the conversation sentence based on the conversation sentence and the first speech template.
[0023] On the other hand, an embodiment of the present application provides an electronic device, including a processor and a memory electrically connected to the processor, the memory storing a computer program, the processor being used to call and execute the computer program from the memory to implement the above-mentioned method for generating a speech template, or the processor being used to call and execute the computer program from the memory to implement the above-mentioned method for generating a speech template.
[0024] On the other hand, an embodiment of the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program can be executed by a processor to implement the above-mentioned method for generating a speech template, or the computer program can be executed by a processor to implement the above-mentioned method for generating a speech template.
[0025] On the other hand, an embodiment of the present application provides a computer program product, including a computer program, wherein the computer program is executed by a processor to implement the above-mentioned method for generating a speech template, or the computer program is executed by a processor to implement the above-mentioned method for generating a speech template.
[0026] By adopting the technical solution of the embodiment of the present application, the conversation data of the conversation role in the first time period is obtained, the conversation intention of each conversation sentence in the conversation data is determined, and for each conversation intention, the intention key sentence of the conversation intention is determined from the conversation sentence corresponding to the conversation intention, and then the speech template of the conversation intention corresponding to the conversation role is generated according to the intention key sentence. It can be seen that the speech template is generated based on the conversation intention of the conversation role and the intention key sentence of the conversation intention. Since the intention key sentence has a strong directional effect on the conversation intention, that is, it can reflect the conversation intention of the conversation role from the intention key sentence, it can ensure that the generated speech template matches the conversation intention of the conversation role, thereby improving the template quality and practicality of the speech template. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate one or more embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 is a schematic flow chart of a method for generating a speech template according to an embodiment of the present application;
[0029] Figure 2 is a schematic principle diagram of a training method for an intent recognition model according to an embodiment of the present application;
[0030] Figure 3 is a schematic flow chart of a method for generating a speech template according to another embodiment of the present application;
[0031] Figure 4 is a schematic flow chart of a method for generating speech according to an embodiment of the present application;
[0032] Figure 5 is a schematic block diagram of a device for generating a speech template according to an embodiment of the present application;
[0033] Figure 6 is a schematic block diagram of a speech generation device according to an embodiment of the present application;
[0034] Figure 7It is a schematic block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0035] The embodiments of the present application provide a speech template generation method, a speech generation method and related products, which are used to solve the problem that the speech template of the conversation role does not match the conversation intention, resulting in poor use effect of the speech template.
[0036] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0037] In the field of artificial intelligence technology, voice robots usually use speech templates for intelligent dialogue to replace manual processing of related business, improve business processing efficiency and save human resources. The quality of speech templates directly affects the dialogue effect of voice robots. One of the quality performances of speech templates is whether the conversation intention of the conversation role can be clearly characterized. For example, the conversation role is a seat that handles customer service business, and the conversation intention of the seat includes "asking about the relationship between the caller and the customer". If the quality of the pre-generated speech template is poor, for example, the speech template is "Excuse me, are you handling (Class A) business?" Obviously, the speech template cannot characterize the conversation intention of the seat "asking about the relationship between the caller and the customer". If the voice robot uses the speech template to talk to the customer, it will result in poor business processing effect and affect the user's experience of handling business. The method for generating speech templates provided in the present application obtains the conversation data of the conversation role in the first time period (for example, the conversation data of the last month), determines the conversation intention of each conversation sentence in the conversation data, and for each conversation intention, determines the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention, and then generates the speech template of the conversation intention corresponding to the conversation role according to the intention key sentence. It can be seen that in the present application, the speech template is generated based on the conversation intention of the conversation role and the intention key sentence of the conversation intention. Since the intention key sentence has a strong directional effect on the conversation intention, that is, the conversation intention of the conversation role can be reflected from the intention key sentence, it can ensure that the generated speech template matches the conversation intention of the conversation role, thereby improving the template quality and practicality of the speech template. When using the speech template for conversation, since the conversation template can clearly characterize the conversation intention of the conversation role, the speech generated using the speech template is a conversation sentence that is highly matched with the conversation intention of the conversation role, which greatly improves the effect of using the speech template for intelligent conversation.
[0038] The speech template generation method and speech generation method provided in the embodiments of the present application can be executed by an electronic device, or by software installed in the electronic device. Specifically, the electronic device can be a terminal device or a server device. Among them, the terminal device can include a smart phone, a laptop computer, a smart wearable device, a vehicle terminal, etc., and the server device can include an independent physical server, a server cluster composed of multiple servers, or a cloud server capable of cloud computing.
[0039] Figure 1 is a schematic flow chart of a method for generating a speech template according to an embodiment of the present application, such as Figure 1 As shown, the method includes the following steps S102 to S108:
[0040] S102, obtaining conversation data of a conversation role in a first time period, where the conversation data includes a plurality of conversation statements.
[0041] Among them, the first time period can be any time period in the past. To ensure the accuracy of the determined conversation intent, the first time period can be selected as a time period close to the current time, such as the last month, the last week, etc. The conversation data includes multiple conversation statements of the conversation role. In addition, it can also include the conversation statements of the opposite user who has a conversation with the conversation role. For example, the conversation role is an agent who handles customer service business. When generating a speech template corresponding to the conversation role, the acquired conversation data can include only the conversation statements of the agent, or it can also include the conversation statements of the agent and the conversation statements of the customer who has a conversation with the agent. The speech template corresponding to the conversation role refers to the speech template for each conversation intent corresponding to the conversation role.
[0042] In order to make the generated speech templates have a wide range of applicability, historical conversation data in as many scenarios as possible can be obtained. Different scenarios have different conversation roles. For example, in the customer service business scenario, the conversation roles include agents and / or customers; in the company front desk business scenario, the conversation roles include front desk staff and / or visitors; in the medical business scenario, the conversation roles include medical guides and / or patients; and so on.
[0043] S104, determining the conversation intention of each conversation sentence in the conversation data.
[0044] Optionally, the conversation intent of the conversation sentence is determined by a pre-trained intent recognition model. Specifically, for each conversation sentence, the conversation sentence is input into the pre-trained intent recognition model, and the conversation sentence is recognized by the intent recognition model to obtain the conversation intent of the conversation sentence.
[0045] Before determining the conversation intent of each conversation sentence in the conversation data, an intention recognition model is pre-trained. The intention recognition model can be trained based on sample conversation sentences and sample conversation intents of the sample conversation sentences. Figure 2 is a schematic diagram of a training method for an intent recognition model according to an embodiment of the present application, such as Figure 2 As shown, the training method of the intent recognition model includes the following steps A1-A3:
[0046] Step A1: input sample conversation sentences and sample conversation intents into the intent recognition model to be trained.
[0047] In this step, the sample conversation role corresponding to the sample conversation sentence can be carried in the sample conversation sentence, so that the intent recognition model to be trained can learn the sample conversation role based on the sample conversation sentence. Optionally, the sample conversation role and the sample conversation sentence are directly concatenated together, and the sample text and sample conversation intent obtained after concatenation are Figure 1 Input the intent recognition model to be trained.
[0048] Optionally, the sample conversation intent is the label information of the sample conversation sentence. For example, after the sample conversation role "customer" and the sample conversation sentence "Are you a real person or a robot" are concatenated, the following sample text is obtained: "Customer: Are you a real person or a robot". Assuming that the sample conversation intent corresponding to the sample conversation sentence "Are you a real person or a robot" is "Customer asks whether it is a robot", the input form of the sample text and the sample conversation intent can be exemplarily characterized as follows:
[0049] “text=Customer: Are you a real person or a robot?
[0050] label = "Customer asks if it is a robot"
[0051] “text=Agent: Excuse me, could you please repeat it again?
[0052] label = The agent did not hear clearly and requested to repeat"
[0053] Among them, text represents sample text and label represents label.
[0054] Step A2: perform intent recognition on the sample conversation sentence through the intent recognition model to obtain the predicted conversation intent of the sample conversation sentence.
[0055] Step A3: Adjust the model parameters of the intent recognition model to be trained according to the predicted session intent and the sample session intent.
[0056] When the intent recognition model recognizes the intent of the sample conversation sentence, it can classify the conversation intent of the sample conversation sentence based on the pre-set training task-classification task, and the classification result is the predicted conversation intent. The sample conversation intent can be characterized by the intention category of the predetermined conversation intent, and the intention category can be characterized by at least one information such as the intention category identification information, the intention name, and the intention description information. The difference (or similarity) between the predicted conversation intent and the sample conversation intent is used as the basis for whether to continue to adjust the model parameters. Optionally, if the difference between the predicted conversation intent and the sample conversation intent is greater than or equal to the preset difference threshold, the model parameters are adjusted, and the model is trained for the next iteration; if the difference between the predicted conversation intent and the sample conversation intent is less than the preset difference threshold, the model parameters are stopped from being adjusted, and the next iteration training is not required.
[0057] S106, for each conversation intention, determining the intention key sentence of the conversation intention from the conversation sentences corresponding to the conversation intention.
[0058] After determining the conversation intention of each conversation sentence in S104, before executing S106, the conversation sentences corresponding to each conversation intention may be counted. For example, the conversation sentences include conversation sentence A, conversation sentence B, and conversation sentence C. In S104, it is determined that the conversation intention corresponding to conversation sentence A is intention Figure 1 , the conversation intentions corresponding to conversation sentences B and C are both Figure 2 Based on this, the statistics show Figure 1 The corresponding conversation sentence is conversation sentence A, meaning Figure 2 The corresponding conversational statements are conversational statement B and conversational statement C.
[0059] For each conversation intent, the key sentence of intent refers to the conversation sentence that has a strong directional effect on the conversation intent. In simple terms, the key sentence of intent can reflect the conversation intent.
[0060] S108, generating a speech template of the conversation intention corresponding to the conversation role according to the key sentences of the intention.
[0061] Since other conversation sentences except the key sentences of intent cannot strongly represent the conversation intent, these conversation sentences will not be used as the basis for generating speech templates and can be deleted. Generate corresponding speech templates only based on the key sentences of the conversation intent, so as to ensure that the generated speech templates can clearly represent the conversation intent of the conversation role, that is, the conversation intent of the conversation role can be directly determined from the speech template. For example, the speech template is "Please complete (processing / operation) before (time)", and the conversation intent can be directly determined from the speech template as: remind the customer of the time point to complete the processing / operation.
[0062] By adopting the technical solution of the embodiment of the present application, the conversation data of the conversation role in the first time period is obtained, the conversation intention of each conversation sentence in the conversation data is determined, and for each conversation intention, the intention key sentence of the conversation intention is determined from the conversation sentence corresponding to the conversation intention, and then the speech template of the conversation intention corresponding to the conversation role is generated according to the intention key sentence. It can be seen that the speech template is generated based on the conversation intention of the conversation role and the intention key sentence of the conversation intention. Since the intention key sentence has a strong directional effect on the conversation intention, that is, it can reflect the conversation intention of the conversation role from the intention key sentence, it can ensure that the generated speech template matches the conversation intention of the conversation role, thereby improving the template quality and practicality of the speech template.
[0063] In the above embodiment, when executing step S106, multiple methods can be used to determine the key sentences of the conversation intention. Two methods of determining the key sentences of the intention are schematically described below.
[0064] In one embodiment, when determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention, the following steps B1-B3 may be performed:
[0065] Step B1, determining a first sentence vector of a conversation sentence corresponding to the conversation intention.
[0066] Among them, each conversation intention corresponds to multiple conversation sentences, and the first sentence vector of each conversation sentence can be determined by a text vector conversion tool. For example, the text vector conversion tool includes a mapping relationship between each word segment and the word segmentation vector. The word segmentation vector corresponding to each word segment in the conversation sentence is determined according to the mapping relationship, and then the word segmentation vectors corresponding to each word segment are spliced according to the position information of each word segment in the conversation sentence to obtain the first sentence vector of the conversation sentence.
[0067] Alternatively, the first sentence vector of each conversation sentence is determined using the text steering function of the pre-trained language model. The pre-trained language model can be any existing model with a text steering function, such as a BERT (Bidirectional Encoder Representations from Transformers) model, a Roberta model, etc. The conversation sentence is input into the pre-trained language model, and the conversation sentence is vectorized using the text steering function of the pre-trained language model to obtain the first sentence vector of the conversation sentence.
[0068] Step B2, the first sentence vectors of the plurality of conversation sentences are combined into a sentence matrix, and singular value decomposition is performed on the sentence matrix to obtain a singular value of each conversation sentence.
[0069] In this step, the process of performing singular value decomposition on the sentence matrix is already a prior art, so it will not be repeated here. After performing singular value decomposition on the sentence matrix, the elements on the diagonal of the obtained diagonal matrix are the singular values of the conversational sentences. The number of elements on the diagonal of the diagonal matrix is the same as the number of the first sentence vectors. According to the position information of the first sentence vector in the sentence matrix, the singular value corresponding to the first sentence vector can be determined as the singular value of the conversational sentence corresponding to the first sentence vector. For example, on the diagonal of the diagonal matrix, the elements located in the first row are the singular values of the conversational sentences corresponding to the first sentence vector located in the first row in the sentence matrix.
[0070] Step B3, according to the singular value of each conversation sentence, determine at least one conversation sentence that meets the preset screening condition from multiple conversation sentences as the intention key sentence.
[0071] The singular value of at least one conversation statement that meets the preset screening condition satisfies one or more of the following: the singular value of the conversation statement is less than or equal to a preset threshold, and the singular value of the conversation statement is located in the first N positions after the singular values of multiple conversation statements are sorted from small to large, or in the last N positions after the singular values of multiple conversation statements are sorted from large to small. N is an integer greater than or equal to 1.
[0072] In this embodiment, the smaller the singular value of a conversational sentence is, the more clearly the conversational sentence can characterize the conversational intention of the conversational role. Conversely, the larger the singular value of a conversational sentence is, the more vague the conversational intention that the conversational sentence can characterize is. Therefore, a conversational sentence with a smaller singular value (such as less than or equal to a preset threshold) is determined as a key sentence of intention; or, after sorting the singular values of multiple conversational sentences from small to large, the conversational sentence corresponding to the singular value ranked at the front (such as the front N bits) is determined from the sorted singular values as the key sentence of intention; or, after sorting the singular values of multiple conversational sentences from large to small, the conversational sentence corresponding to the singular value ranked at the back (such as the back N bits) is determined from the sorted singular values as the key sentence of intention.
[0073] In another embodiment, when determining the intention key sentence of the conversation intention from the conversation sentences corresponding to the conversation intention, the following steps C1-C3 may be performed:
[0074] Step C1, obtaining preset intention key sentences of conversation intention.
[0075] The preset intention key sentence refers to a pre-set conversation sentence that can clearly represent the conversation intention. The preset intention key sentence can be determined from the conversation sentences corresponding to the conversation intention, and the determination standard is the conversation sentence that can clearly represent the conversation intention.
[0076] Step C2, for each conversation sentence corresponding to the conversation intent, calculate the first sentence vector of the conversation sentence and the second sentence vector of the preset intent key sentence.
[0077] The method for determining the second sentence vector of the preset intention key sentence is the same as the method for determining the first sentence vector of the conversation sentence, which will not be repeated here.
[0078] Step C3: If the calculation result between the first sentence vector and the second sentence vector meets the preset calculation condition, the conversation sentence is determined to be an intention key sentence. The preset calculation condition includes at least one of the following: the first sentence vector is a preset calculation result of the second sentence vector and a fixed value, and the first sentence vector is a preset calculation result of multiple second sentence vectors.
[0079] In this embodiment, the preset operation result may be an operation result obtained after multiplication. When calculating the first sentence vector and the second sentence vector, the calculation may be performed according to a preset calculation function.
[0080] An optional calculation function can be expressed as the following formula:
[0081] f(X)=P1 / P2
[0082] Among them, P1 represents the first statement vector, P2 represents the second statement vector, if the calculation result f(X) satisfies f(X)=P1 / P2=T, T is a preset fixed value, then it means that the calculation results of the first statement vector and the second statement vector meet the preset calculation conditions: the first statement vector P1 is the product of the second statement vector P2 and the fixed value T.
[0083] Another optional calculation function can be expressed as the following formula:
[0084] f(X)=P1 / (P2*P3*……Pn)
[0085] Wherein, P1 represents the first sentence vector, and P2, P3, ..., Pn represent different second sentence vectors. If the calculation result f(X) satisfies f(X) = P1 / (P2*P3* ..., Pn) = 1, it means that the calculation results of the first sentence vector and the second sentence vector meet the preset calculation conditions: the first sentence vector P1 is the product of multiple second sentence vectors (P2, P3 ..., Pn).
[0086] In one embodiment, generating a speech template of a conversation intention corresponding to a conversation role according to the intention key sentence includes the following steps D1-D4:
[0087] Step D1, determine the fixed speech elements and variable speech elements of the conversation intent based on the key sentences of the intent.
[0088] Optionally, the intention key sentences include multiple ones. When determining the fixed speech elements and variable speech elements of the conversation intention, the multiple intention key sentences may be compared, and the matching words in the multiple intention key sentences may be determined as fixed speech elements, and the non-matching words may be determined as variable speech elements. The matching words may include at least one of the following: the same words, words with the same meaning, and words with similar meanings.
[0089] For example, for the conversation intent "department introduction", the corresponding intent key sentences include the following three: We are the sales department of Company A; We are the product department of Company B; We are the operations department of Company C. By comparing these three intent key sentences, it can be determined that the fixed speech elements include "we are", "company", and "department", and the variable speech elements include the elements in the position of "A, B, C" and the elements in the position of "product, operation, sales".
[0090] Optionally, a fixed speech element library is pre-set, and the fixed speech element library includes multiple fixed speech elements. When determining the fixed speech elements and variable speech elements of the conversation intention, the intention key sentence is matched with the fixed speech element library, so as to determine the fixed speech elements and variable speech elements according to the matching result. Specifically, the intention key sentence can be processed by word segmentation to obtain multiple word segments, and then the multiple word segments are matched with the fixed speech elements in the fixed speech element library. If the fixed speech element library includes a word segmentation, the word segmentation is determined to be a fixed speech element of the conversation intention. If the fixed speech element library does not include a word segmentation, the word segmentation is determined to be a variable speech element of the conversation intention.
[0091] Step D2, determining the combination order of fixed speech elements and variable speech elements according to the sentence information of the key sentence of the intention; the sentence information includes at least one of the following: grammar, sentence pattern, and word segmentation structure.
[0092] The participle structure may include the participle and the position of the participle in the key sentence of the intent.
[0093] Step D3, combining the fixed speech elements and the variable speech elements in the combination order to obtain the combined speech elements.
[0094] Step D4, replace the variable speech elements in the combined speech elements with the elements to be filled in to obtain a speech template.
[0095] The element to be filled can be represented by any symbol that can be filled, such as brackets, underscores, etc. For example: (), {}, [], __, etc. In addition, the element to be filled can also include filling element prompt information, the purpose of which is to prompt the information content to be filled in the element to be filled when the speech template is used to generate the speech. The filling element prompt information can be determined by performing semantic analysis on the variable speech element.
[0096] Continuing with the above example, the fixed speech elements of the conversation intent "department introduction" include "we are", "company", and "department", and the variable speech elements include the elements where "A, B, C" are located and the elements where "product, operation, sales" are located. Combine the fixed speech elements and variable speech elements of the conversation intent, and replace the variable speech elements with the element to be filled in "()", and you will get the following speech template: We are () company () department. In addition, if you add the filling element prompt information to the element to be filled in "()", you will get the following speech template: We are (company name) company (department name) department.
[0097] For another example, the speech template for the conversation intent "remind users to perform operations on schedule" can be: Please complete (processing / operation) before (time), and we will check it after (time).
[0098] It should be noted that the same conversation intent can correspond to multiple speech templates, and the semantics of the multiple speech templates are the same, but the difference lies in the sentence structure (i.e., the text expression method). For example, the speech template of the conversation intent "remind the user to operate on schedule" can also include: The latest time for (processing / operation) is (time), please complete it on time.
[0099] In this embodiment, the fixed speech elements and variable speech elements of the conversation intention are determined by the intention key sentence, and the combination order of the fixed speech elements and the variable speech elements is determined according to the sentence information of the intention key sentence, and then the fixed speech elements and the variable speech elements are combined according to the combination order, and the variable speech elements are replaced with the elements to be filled to obtain the speech template, so that the fixed speech elements and the variable speech elements in the generated speech template are matched with the sentence information of the intention key sentence, including the matching of grammar, sentence pattern, word segmentation structure and other information, so that the speech template matches the conversation intention of the conversation role, ensuring the template quality and practicality of the speech template. When using the speech template to generate speech, it can ensure that the sentence information of the speech matches the sentence information of the corresponding intention key sentence, thereby ensuring the semantic accuracy of the speech, which is conducive to the efficient processing of conversation-related services.
[0100] In one embodiment, after generating a speech template of the conversation intention corresponding to the conversation role according to the intention key sentence, the speech template can be quality evaluated. First, the evaluation index of the speech template is determined, and the evaluation index may include template coverage and / or semantic matching. Second, according to the evaluation index, the quality of the speech template is evaluated to obtain the quality evaluation result of the speech template.
[0101] If the evaluation index includes template coverage, determining the evaluation index of the speech template may include the following steps:
[0102] First, obtain the set of optional elements corresponding to the conversation intent, which includes optional elements that match the variable speech elements in the speech template. The optional elements match the variable speech elements, which means that the optional elements match the fill-in element prompt information carried by the variable speech elements. For example, if the fill-in element prompt information of the variable speech element is "company name", then the optional element that matches the variable speech element is the specific company name. In the speech template, each variable speech element corresponds to an optional element set.
[0103] Secondly, based on the optional element set and the speech template, generate the conversation sentences to be tested corresponding to the conversation intent.
[0104] Select an optional element from the optional element set to replace the corresponding variable speech element in the speech template. After all variable speech elements are replaced by their corresponding optional elements, the conversation sentence to be tested corresponding to the conversation intent can be generated.
[0105] For example, for the speech template "We are the (department name) department of (company name) company", obtain the optional element set of the variable speech element "(company name)" and the optional element set of the variable speech element "(department name)". Assume that the optional element set of the variable speech element "(company name)" is: {A, B, C}, where A, B, C are the names of different companies respectively. The optional element set of the variable speech element "(department name)" is: {operation, sales, product}. Select an optional element from the optional element set {A, B, C} to replace the variable speech element "(company name)" in the speech template, and select an optional element from the optional element set {operation, sales, product} to replace the variable speech element "(department name)" in the speech template, and you can get the conversation sentence to be tested corresponding to the conversation intent.
[0106] Next, sentence evaluation parameters of the conversation sentence to be tested are determined, and the template coverage of the speech template is determined based on the sentence evaluation parameters. The sentence evaluation parameters include sentence confusion and / or sentence fluency.
[0107] A high template coverage rate means that the speech template does not need to be adjusted at all during the change of the variable speech elements. If the speech template needs to be partially adjusted during the change of the variable speech elements, it means that the template coverage rate of the speech template is low. If the speech template needs to be adjusted continuously with the change of the variable speech elements, it means that the template coverage rate of the speech template is too low.
[0108] When determining the sentence perplexity and / or sentence fluency of the conversation sentence to be tested, the conversation sentence to be tested may be input into a pre-trained language model, and the pre-trained language model outputs the sentence perplexity and / or sentence fluency of the conversation sentence to be tested by analyzing the semantic information of the conversation sentence to be tested. The pre-trained language model may be any existing model with semantic analysis capability, such as the Roberta model.
[0109] Sentence perplexity is the PPL (Perplexity) indicator, which is essentially the probability of calculating a sentence. Sentence perplexity is related to the sentence probability on the test set. The basic idea is that if the sentences in the test set are all normal sentences, the higher the probability of the conversation sentence to be tested on the test set, the better. In this embodiment, the key sentences of the conversation intention can be used as the test set. Sentence fluency means that the sentence is correct in terms of grammar, sentence pattern, word segmentation structure, etc. Since the calculation method of sentence fluency is already a prior art, it will not be repeated here.
[0110] Optionally, when determining the template coverage of a speech template based on sentence perplexity and / or sentence fluency, the template coverage is inversely proportional to the sentence perplexity, that is, the higher the sentence perplexity, the lower the template coverage, indicating that the template quality of the speech template is low. The template coverage is directly proportional to the sentence fluency, that is, the higher the sentence fluency, the higher the template coverage, indicating that the template quality of the speech template is high. In the case where the sentence evaluation parameters include sentence perplexity and sentence fluency, the weights corresponding to the sentence perplexity and sentence fluency can be determined in advance, and then the template coverage of the speech template is calculated according to the sentence perplexity, sentence fluency and the weights corresponding to the two. The calculation method of the template coverage can be represented by the following formula:
[0111] P(X)=a*P1+b*P2
[0112] Among them, P(X) represents the template coverage, a and b are the weights corresponding to sentence perplexity and sentence fluency respectively, P1 represents the sentence perplexity of the speech template, and P2 represents the sentence fluency of the speech template.
[0113] In one embodiment, the evaluation index includes semantic matching, and the conversation data includes: conversation sentences of the conversation role, and associated conversation sentences having a conversation relationship with multiple conversation sentences of the conversation role. For example, if the conversation role is an agent who handles customer service, then the conversation sentence of the conversation role is the conversation sentence of the agent, and the associated conversation sentence is the conversation sentence of the customer who has a conversation with the agent.
[0114] When determining the semantic matching degree of the speech template, the following steps can be performed:
[0115] First, based on the associated conversation sentences having a conversation relationship with the conversation sentences of the conversation role, an associated conversation intention having an intention association with the conversation intention is determined.
[0116] Among them, having an intention association with the conversation intention refers to the conversation intention corresponding to the sentence having a conversation relationship with the conversation sentence corresponding to the conversation intention. That is, if there is a conversation relationship between the conversation sentence and its associated conversation sentence, then there is an intention association between the conversation intention of the conversation sentence and the conversation intention of the associated conversation sentence, and the conversation intention of the associated conversation sentence can be called the associated conversation intention.
[0117] For example, a conversation is as follows: User A1: Who are you?
[0118] Company employee B1: I am the customer service manager of Company X;
[0119] User A2: Why do you keep calling me?
[0120] In the above conversation, user A1, employee B1 and user A2 have a conversation relationship. For any conversation statement, other conversation statements are all related conversation statements of the conversation statement, and the conversation intentions of other conversation statements are all related conversation intentions of the conversation intention of the conversation statement. Specifically, the conversation intention of employee B1 (i.e., the conversation intention of employee B1's conversation statement) is the previous intention of user A2's conversation intention.
[0121] Secondly, the semantic matching degree of the speech template is determined based on the semantic matching information between the associated conversation intention and the speech template.
[0122] Semantic matching can also be understood as semantic understanding, which refers to the semantic matching and problem-solving degree of the semantic center of gravity and hidden semantics of the speech template to the previous intention, similar to the function of a key opening a lock. The previous intention refers to the intention before the conversation intention corresponding to the currently calculated speech template.
[0123] The semantic matching information between the associated conversation intent and the speech template can be determined in the following manner: the associated conversation intent and the speech template are input into the pre-trained language model as a text pair, and the text matching task is used to perform text analysis to determine the matching degree between the associated conversation intent and the speech template. The higher the matching degree between the associated conversation intent and the speech template, the higher the semantic matching degree of the speech template.
[0124] After determining the evaluation indicators of the speech template (including template coverage and / or semantic matching), the quality of the speech template is evaluated. The quality evaluation result can be represented in various forms such as quality evaluation score and evaluation grade. Optionally, the quality evaluation score can be calculated by the following formula:
[0125] Quality assessment score = template coverage * semantic matching
[0126] It can be seen that the quality evaluation score of the speech template is directly proportional to the template coverage and semantic matching degree. The higher the template coverage and / or semantic matching degree, the higher the quality evaluation score of the speech template, which further indicates that the template quality of the speech template is better.
[0127] In this embodiment, the quality of the speech template is evaluated by template coverage and / or semantic matching, so that the quality evaluation result of the speech template can directly reflect the template coverage and / or semantic matching of the speech template. According to the quality evaluation result of the speech template, the level of template coverage and semantic matching can be quickly known, which is beneficial to improve the template quality of the speech template from the two aspects of template coverage and semantic matching.
[0128] The speech template in the above embodiment is generated for a plurality of generalized scenarios. When executing step S102, conversation data in as many scenarios as possible is obtained. Therefore, the generated speech template can be widely applicable to a plurality of scenarios.
[0129] In one embodiment, after generating a speech template of a conversation intention corresponding to a conversation role according to a key sentence of intention, in order to make the speech template more adaptable to a specific scene (or a designated scene), the speech template may be subjected to scenario processing or scenario migration processing.
[0130] Figure 3 is a schematic flow chart of a method for generating a speech template according to another embodiment of the present application. In this embodiment, the generation of a speech template refers to the generation process of a speech template in a specific scenario (or specified scenario). Figure 3 As shown, the method for generating a speech template includes the following steps S302 to S308:
[0131] S302, obtaining the scenario words that match the conversation intention in the target scenario.
[0132] The target scenario is the scenario in which the speech template is to be scenario-based or migrated. Optionally, multiple scenario speech of the target scenario is obtained, for example, multiple conversations under the target scenario are obtained, and each conversation sentence (or part of the conversation sentence) in the multiple conversations can be used as the scenario speech of the target scenario. Then, the scenario speech of the target scenario is matched with the pre-generated speech template to determine which speech template each scenario speech of the target scenario matches.
[0133] For each scenario speech, when determining the speech template that matches the scenario speech, the scenario speech is surface-text matched with each speech template. Based on the result of the text matching, the overlapping part (i.e., the part with the same text) of the scenario speech and the speech template can be determined. If the overlapping rate of the scenario speech and the speech template reaches a preset threshold, the scenario speech is determined to match the speech template. If the overlapping rate of the scenario speech and the speech template is lower than the preset threshold, the scenario speech is determined to not match the speech template.
[0134] S304, matching the scenario speech that matches the conversation intention with the speech template of the conversation intention, and determining the elements to be changed in the speech template according to the matching result.
[0135] The elements to be changed include at least one of the following: grammar, sentence structure, participle, and language block.
[0136] In this step, after surface text matching of the scenario speech that matches the conversation intent and the speech template of the conversation intent, the overlapping parts are elements that do not need to be changed, and the non-overlapping parts (i.e., the parts with different text content) are elements to be changed.
[0137] S306: Obtain a scene element corresponding to the element to be changed in the target scene.
[0138] The scene elements corresponding to the elements to be changed in the target scene refer to grammar, sentence patterns, participles and / or language blocks applicable to the target scene.
[0139] S308, changing the elements to be changed into scene elements, and obtaining the migration speech template of the conversation intention in the target scene. In this embodiment, by matching the scene speech with the speech template of the conversation intention, the elements to be changed in the speech template are determined, and then the elements to be changed are changed into scene elements adapted to the target scene, so as to obtain the migration speech template in the target scene. Since the migration speech template contains the grammar, sentence structure, participle, language block, etc. suitable for the target scene, it can be better adapted to the target scene, ensuring the accuracy of the speech template when applied to the target scene.
[0140] Figure 4 is a schematic flow chart of a method for generating speech according to an embodiment of the present application, such as Figure 4As shown, the speech generation method includes the following steps S402 to S408:
[0141] S402: Acquire the conversation statement of the first user.
[0142] S404: Determine a first conversation intention of the first user according to the conversation statement and the role information of the first user.
[0143] In this step, the conversation sentence and the role information of the first user can be input into a pre-trained intention recognition model, and the conversation sentence is recognized by the intention recognition model to obtain the first conversation intention of the first user. The training method and principle of the intention recognition model have been described in detail in the above embodiment and will not be repeated here.
[0144] Optionally, when the intent recognition model recognizes the intent of a conversation statement, it may first determine a conversation intent set corresponding to the role information based on the role information of the first user, and then determine the first conversation intent of the first user based on the multiple conversation intentions included in the conversation intent set and the conversation statement of the first user. Among them, conversation intent sets corresponding to multiple conversation roles may be generated in advance, and each conversation intent set includes multiple conversation intentions corresponding to the conversation role. The conversation intent in the conversation intent set may be represented in at least one of the following ways: identification information of the conversation intent, description information of the conversation intent, name of the conversation intent, etc.
[0145] For example, if the role information of the first user is an agent, the intent recognition model can determine the agent's first conversation intention based on the conversation intention set corresponding to the agent. In other words, when determining the first conversation intention, the intent recognition model does not consider the conversation intention set that does not match the user's role information, thereby improving the accuracy and efficiency of conversation intention determination.
[0146] Optionally, the role information of the first user may be carried in the conversation sentence of the first user, so that the intention recognition model can obtain the role information of the first user based on the conversation sentence of the first user. For example, the role information and the conversation sentence of the first user are directly spliced together, and the conversation text obtained after splicing is input into the intention recognition model, and the conversation text is analyzed by the intention recognition model to obtain the first conversation intention.
[0147] S406, determining a first speech template that matches the first conversation intention.
[0148] Among them, the first speech template is generated according to the speech template generation method provided in any of the above embodiments.
[0149] S408: Generate a speech text corresponding to the conversation sentence according to the first speech template.
[0150] When generating the speech text corresponding to the conversation sentence according to the first speech template, it is only necessary to replace the variable speech element in the speech template with the specific text content. Optionally, the text content used to replace the variable speech element is determined according to the filling element prompt information carried by the variable speech element.
[0151] In this embodiment, a filling element library can be pre-configured, and the filling element library includes multiple filling elements, and each filling element is stored corresponding to the corresponding filling element prompt information. For example, the filling element corresponding to the filling element prompt information "Company Name" is "A", the filling element corresponding to the filling element prompt information "Department Name" is "Marketing", the filling element corresponding to the filling element prompt information "Point Time" is "5 pm", and so on. Based on the filling element library, the filling element prompt information carried by the variable speech element in the speech template can be matched with the filling element library, and the filling element corresponding to the filling element prompt information is matched, and the filling element is the text content used to replace the variable speech element.
[0152] In the filling element library, one filling element prompt information may correspond to multiple filling elements. In order to ensure that the text content used to replace the variable speech element can be accurately determined, the multiple filling elements can be distinguished. Optionally, each filling element corresponds to the storage of keywords, and the role of the keywords is to distinguish multiple filling elements corresponding to the same filling element prompt information. When matching the filling element prompt information carried by the variable speech element with the filling element library, if multiple filling elements are matched, the speech template is further matched with the keywords corresponding to the multiple filling elements. If the speech template includes a keyword corresponding to a filling element, it means that the filling element is the filling element that matches the speech template and is used to replace the variable speech element in the speech template.
[0153] For example, the following data is stored in the filling element library: {'time': before 6 o'clock}. The data in "{}" indicates that the filling element corresponding to the filling element prompt information 'time' is "before 6 o'clock".
[0154] For another example, the following data is stored: {'point time': (repayment, before 6 o'clock); (application, before 1 o'clock)}. The data in "{}" indicates that the filling elements corresponding to the filling element prompt information 'point time' include "before 6 o'clock" and "before 1 o'clock", and the keyword corresponding to the filling element "before 6 o'clock" is "repayment", and the keyword corresponding to the filling element "before 1 o'clock" is "application", which means that if the speech template includes the keyword "repayment", the filling element used to replace the variable speech element is "before 6 o'clock"; if the speech template includes the keyword "application", the filling element used to replace the variable speech element is "before 1 o'clock".
[0155] Taking an intelligent robot as an example, the speech generation method provided in this embodiment can achieve the following intelligent conversation effects:
[0156] Speaker A: Okay, I'll go and return it.
[0157] The intelligent robot replied: Please complete the repayment process before 1 pm. We will conduct a follow-up verification after 6 pm.
[0158] In this example, the intelligent robot's reply is generated according to the speech template "Please complete (business name) (processing / operation) before (time), and we will verify it after (time)."
[0159] If there are multiple first speech templates matching the first conversation intention, a speech text can be generated according to each of the multiple first speech templates to obtain multiple speech texts corresponding to the conversation sentences of the first user. Afterwards, a speech text can be randomly selected from the multiple speech texts for output, or, according to the sentence fluency and / or sentence confusion of each speech text, a speech text with the highest sentence fluency and / or sentence confusion can be selected from the multiple speech templates for output.
[0160] The speech generation method provided in this embodiment can be implemented by a speech generation big model, that is, the conversation sentence of the first user is input into the speech generation big model, and the speech generation big model automatically executes the above steps S402 to S408 according to the conversation sentence of the first user, and outputs the speech text corresponding to the conversation sentence. Optionally, when executing step S404, the speech generation big model can call an external intention recognition model to determine the first conversation intention of the first user.
[0161] By adopting the technical solution of the embodiment of the present application, the first conversation intention of the first user is determined according to the conversation sentence and the role information of the first user, and the first speech template matching the first conversation intention is determined, and then the speech text corresponding to the conversation sentence is generated according to the conversation sentence and the first speech template. Since the speech template generation method provided in the embodiment of the present application can generate a speech template with high quality and high practicality, the speech text generated based on the speech template has a high degree of matching with the conversation sentence of the first user, thereby achieving the effect of efficiently and intelligently processing conversation-related services and saving a lot of labor costs.
[0162] In one embodiment, the speech templates matching the first conversation intention include multiple ones. Based on this, when determining the first speech template matching the first conversation intention, the following method can be performed:
[0163] First, the intent importance level of the first conversation intent is determined.
[0164] Each session intent has its own intent importance level. The intent importance level corresponding to the session intent can be predetermined. Optionally, the intent importance level depends on the degree of advancement of the session intent for the business (i.e., the degree of benefit to the business advancement). The higher the degree of advancement of the session intent for the business, the higher the corresponding intent importance level.
[0165] Secondly, according to the intention importance level and the quality evaluation result of each speech template in the multiple speech templates, the first speech template is determined from the multiple speech templates matching the first conversation intention.
[0166] There are many ways to determine the first speech template, and two methods are schematically listed below:
[0167] Method 1: pre-set the corresponding relationship between the intention importance level and the speech template screening threshold. The speech template screening threshold refers to the threshold that the quality assessment score (ie, the quality assessment result) of the speech template should reach.
[0168] For example, the intent importance level can be divided into level 1, level 2, and level 3. The quality assessment score of the speech template is a value between 0 and 10. The larger the value, the better the template quality of the speech template. Assume that the speech template screening threshold corresponding to the intent importance level "level 1" is 8, the speech template screening threshold corresponding to the intent importance level "level 2" is 6, and the speech template screening threshold corresponding to the intent importance level "level 3" is 4.
[0169] Based on the correspondence between the above-mentioned intent importance level and the speech template screening threshold, if the intent importance level of the first conversation intent is level one, then the speech template with a quality assessment score of 8 can be determined as the first speech template from the multiple speech templates that match the first conversation intent. Similarly, if the intent importance level of the first conversation intent is level two, then the speech template with a quality assessment score of 6 can be determined as the first speech template from the multiple speech templates that match the first conversation intent. If the intent importance level of the first conversation intent is level three, then the speech template with a quality assessment score of 4 can be determined as the first speech template from the multiple speech templates that match the first conversation intent.
[0170] Method 2: pre-set the correspondence between the level of intent importance and the number of required speech templates. According to the correspondence, after determining the level of intent importance of the first conversation intent, further determine the number of speech templates corresponding to the level of intent importance. Then, according to the determined number of speech templates, from multiple speech templates matching the first conversation intent, in the order of the quality evaluation score of each speech template from high to low, obtain the first speech templates that match the number of speech templates.
[0171] Assume that the number of speech templates corresponding to the "first level" of the intention importance level is 3, the number of speech templates corresponding to the "second level" of the intention importance level is 2, and the number of speech templates corresponding to the "third level" of the intention importance level is 1. Based on the correspondence between the intention importance level and the number of speech templates, if the intention importance level of the first conversation intention is first level, then three speech templates can be selected in sequence from the multiple speech templates matching the first conversation intention in the order of high to low quality evaluation scores, and the three selected speech templates are determined to be the first speech template. Similarly, if the intention importance level of the first conversation intention is second level, then two speech templates can be selected in sequence from the multiple speech templates matching the first conversation intention in the order of high to low quality evaluation scores, and the two selected speech templates are determined to be the first speech template. If the intention importance level of the first conversation intention is level three, then from multiple speech templates matching the first conversation intention, a speech template with the highest quality evaluation score can be determined as the first speech template in descending order of quality evaluation scores.
[0172] In some embodiments, the conversation intention of the speaker may not be known. In this case, the speech template can be input into the speech generation model as prompt information for speech generation. The speech generation model can generate the corresponding speech text according to the speech template.
[0173] For example, participant A: OK, I will return it; speech template (i.e. the prompt information generated by the speech): Please complete (business name) (processing / operation) before (time), and we will check it after (time).
[0174] The output of the large model generated by the speech script is: Please complete the repayment process before 1 pm, and we will conduct verification after 6 pm.
[0175] In summary, specific embodiments of the present subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recorded in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing can be advantageous.
[0176] The above is a method for generating a speech template and a method for generating speech provided in the embodiments of the present application. Based on the same idea, the embodiments of the present application also provide a device for generating a speech template and a device for generating speech.
[0177] Figure 5 is a schematic block diagram of a device for generating a speech template according to an embodiment of the present application, such as Figure 5 As shown, the device comprises:
[0178] An acquisition module 51 is used to acquire the conversation data of the conversation role in the first time period; the conversation data includes a plurality of conversation statements;
[0179] A determination module 52 is used to determine the conversation intention of each conversation sentence in the conversation data; for each conversation intention, determine the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention;
[0180] The generation module 53 is used to generate a speech template of the conversation intention corresponding to the conversation role according to the intention key sentence.
[0181] In one embodiment, when the determining module 52 determines the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention, the determining module 52 performs the following steps:
[0182] Determine a first sentence vector of a conversation sentence corresponding to the conversation intention;
[0183] The first sentence vectors of the plurality of conversation sentences are combined into a sentence matrix, and the sentence matrix is subjected to singular value decomposition to obtain a singular value of each conversation sentence;
[0184] According to the singular value of each conversation sentence, determining at least one conversation sentence satisfying a preset screening condition from the multiple conversation sentences as the intention key sentence;
[0185] Among them, the singular value of at least one conversation statement that meets the preset screening condition satisfies one or more of the following: the singular value of the conversation statement is less than or equal to a preset threshold, and the singular value of the conversation statement is located in the first N positions after the singular values of multiple conversation statements are sorted from small to large or in the last N positions after the singular values of multiple conversation statements are sorted from large to small.
[0186] In one embodiment, when the determining module 52 determines the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention, the determining module 52 performs the following steps:
[0187] Obtaining a preset intention key sentence of the conversation intention;
[0188] For each conversation sentence corresponding to the conversation intention, calculating a first sentence vector of the conversation sentence and a second sentence vector of the preset intention key sentence;
[0189] If the calculation result between the first sentence vector and the second sentence vector meets the preset calculation condition, determining that the conversation sentence is the intention key sentence;
[0190] Among them, the preset calculation condition includes at least one of the following: the first statement vector is a preset operation result of the second statement vector and a fixed value, and the first statement vector is a preset operation result of multiple second statement vectors.
[0191] In one embodiment, when the generating module 53 generates the speech template of the conversation intention corresponding to the conversation role according to the intention key sentence, the generating module 53 performs the following steps:
[0192] Determine the fixed speech elements and the variable speech elements of the conversation intention according to the key sentence of the intention;
[0193] Determine the combination order of the fixed speech elements and the variable speech elements according to the sentence information of the key sentence of the intention; the sentence information includes at least one of the following: grammar, sentence pattern, and participle structure;
[0194] Combining the fixed speech element and the variable speech element according to the combination order to obtain a combined speech element;
[0195] The variable speech elements in the combined speech elements are replaced with the elements to be filled in to obtain the speech template.
[0196] In one embodiment, the determination module 52 is further configured to determine an evaluation index of the speech template after generating the speech template of the conversation intention corresponding to the conversation role according to the intention key sentence;
[0197] The device also includes:
[0198] The quality assessment module is used to perform quality assessment on the speech template according to the assessment index to obtain the quality assessment result of the speech template.
[0199] In one embodiment, the evaluation index includes template coverage;
[0200] When determining the evaluation index of the speech template, the determination module 52 performs the following steps:
[0201] Acquire a set of optional elements corresponding to the conversation intention; the set of optional elements includes optional elements that match the variable speech elements in the speech template;
[0202] Generate a conversation sentence to be tested corresponding to the conversation intention according to the optional element set and the speech template;
[0203] Determine sentence evaluation parameters of the conversation sentence to be tested, and determine the template coverage of the speech template according to the sentence evaluation parameters; the sentence evaluation parameters include sentence confusion and / or sentence fluency.
[0204] In one embodiment, the evaluation index includes a semantic match; the conversation data also includes associated conversation statements having a conversation relationship with the plurality of conversation statements of the conversation role;
[0205] When determining the evaluation index of the speech template, the determination module 52 performs the following steps:
[0206] Determining, according to the associated conversation statement, an associated conversation intention having an intention association with the conversation intention;
[0207] The semantic matching degree of the speech template is determined based on the semantic matching information between the associated conversation intention and the speech template.
[0208] In one embodiment, the device further comprises: a matching module and a changing module;
[0209] The acquisition module 51 is further configured to acquire a scenario speech matching the conversation intent in a target scenario after generating a speech template of the conversation intent corresponding to the conversation role according to the intention key sentence;
[0210] The matching module is used to match the scenario speech with the speech template of the conversation intention, and determine the elements to be changed in the speech template according to the matching result; the elements to be changed include at least one of the following: grammar, sentence structure, participle, and language block;
[0211] The acquisition module 51 is further used to acquire the scene element corresponding to the element to be changed in the target scene;
[0212] The changing module is used to change the element to be changed into the scene element, and obtain the migration speech template of the conversation intention in the target scene.
[0213] The device of the embodiment of the present application is used to obtain the conversation data of the conversation role in the first time period, determine the conversation intention of each conversation sentence in the conversation data, and for each conversation intention, determine the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention, and then generate the speech template of the conversation intention corresponding to the conversation role according to the intention key sentence. It can be seen that the speech template is generated based on the conversation intention of the conversation role and the intention key sentence of the conversation intention. Since the intention key sentence has a strong directional effect on the conversation intention, that is, it can reflect the conversation intention of the conversation role from the intention key sentence, it can ensure that the generated speech template matches the conversation intention of the conversation role, thereby improving the template quality and practicality of the speech template.
[0214] Those skilled in the art should understand that Figure 5The speech template generation device in the text can be used to implement the speech template generation method described above, and the detailed description thereof should be similar to the description of the method part above. To avoid tediousness, it will not be repeated here.
[0215] Figure 6 is a schematic block diagram of a speech generation device according to an embodiment of the present application, such as Figure 6 As shown, the device comprises:
[0216] An acquisition module 61 is used to acquire a conversation statement of a first user;
[0217] A determination module 62 is used to determine a first conversation intention of the first user according to the conversation statement and the role information of the first user; and determine a first speech template matching the first conversation intention; wherein the first speech template is generated according to the speech template generation method provided in any of the above embodiments;
[0218] The generation module 63 is used to generate the speech text corresponding to the conversation sentence according to the first speech template.
[0219] In one embodiment, when determining the first speech template matching the first conversation intention, the determination module 62 performs the following steps:
[0220] determining an intent importance level of the first conversation intent;
[0221] According to the intention importance level and the quality assessment result of each speech template in the multiple speech templates, the first speech template is determined from the multiple speech templates matching the first conversation intention.
[0222] The device of the embodiment of the present application is used to determine the first conversation intention of the first user according to the conversation sentence and the role information of the first user, and determine the first speech template that matches the first conversation intention, and then generate the speech text corresponding to the conversation sentence according to the conversation sentence and the first speech template. Since the speech template generation method provided in the embodiment of the present application can generate a speech template with high quality and high practicality, the speech text generated based on the speech template has a high degree of match with the conversation sentence of the first user, thereby achieving the effect of efficiently and intelligently processing conversation-related services and saving a lot of labor costs.
[0223] Those skilled in the art should understand that Figure 6 The speech generation device in the text can be used to implement the speech generation method described above, and the detailed description thereof should be similar to the description of the method part above. To avoid tediousness, it will not be repeated here.
[0224] Based on the same idea, the embodiment of the present application also provides an electronic device, such as Figure 7As shown. The electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors 701 and memory 702, and the memory 702 may store one or more storage applications or data. Among them, the memory 702 can be a temporary storage or a permanent storage. The application stored in the memory 702 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 701 can be configured to communicate with the memory 702 to execute a series of computer executable instructions in the memory 702 on the electronic device. The electronic device may also include one or more power supplies 703, one or more wired or wireless network interfaces 704, one or more input and output interfaces 705, and one or more keyboards 706.
[0225] Specifically in this embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs are configured to be executed by one or more processors, including the following computer executable instructions:
[0226] Acquire conversation data of the conversation role in a first time period; the conversation data includes a plurality of conversation statements;
[0227] Determining a conversation intention of each conversation statement in the conversation data;
[0228] For each conversation intention, determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention;
[0229] According to the key sentences of the intention, a speech template of the conversation intention corresponding to the conversation role is generated.
[0230] By adopting the technical solution of the embodiment of the present application, the conversation data of the conversation role in the first time period is obtained, the conversation intention of each conversation sentence in the conversation data is determined, and for each conversation intention, the intention key sentence of the conversation intention is determined from the conversation sentence corresponding to the conversation intention, and then the speech template of the conversation intention corresponding to the conversation role is generated according to the intention key sentence. It can be seen that the speech template is generated based on the conversation intention of the conversation role and the intention key sentence of the conversation intention. Since the intention key sentence has a strong directional effect on the conversation intention, that is, it can reflect the conversation intention of the conversation role from the intention key sentence, it can ensure that the generated speech template matches the conversation intention of the conversation role, thereby improving the template quality and practicality of the speech template.
[0231] Specifically in another embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions in the electronic device, and the one or more programs are configured to be executed by one or more processors, including computer executable instructions for performing the following:
[0232] Obtain the conversation statement of the first user;
[0233] determining a first conversation intention of the first user according to the conversation statement and the role information of the first user;
[0234] Determine a first speech template that matches the first conversation intention; wherein the first speech template is generated according to the speech template generation method described in the above aspect;
[0235] Based on the conversation sentence and the first speech template, generate a speech text corresponding to the conversation sentence.
[0236] By adopting the technical solution of the embodiment of the present application, the first conversation intention of the first user is determined according to the conversation sentence and the role information of the first user, and the first speech template matching the first conversation intention is determined, and then the speech text corresponding to the conversation sentence is generated according to the conversation sentence and the first speech template. Since the speech template generation method provided in the embodiment of the present application can generate a speech template with high quality and high practicality, the speech text generated based on the speech template has a high degree of matching with the conversation sentence of the first user, thereby achieving the effect of efficiently and intelligently processing conversation-related services and saving a lot of labor costs.
[0237] The embodiment of the present application further proposes a computer-readable storage medium, which stores one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by an electronic device including multiple application programs, the electronic device can perform each process of the embodiment of the method for generating a speech template, and is specifically used to perform:
[0238] Acquire conversation data of the conversation role in a first time period; the conversation data includes a plurality of conversation statements;
[0239] Determining a conversation intention of each conversation statement in the conversation data;
[0240] For each conversation intention, determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention;
[0241] According to the key sentences of the intention, a speech template of the conversation intention corresponding to the conversation role is generated.
[0242] By adopting the technical solution of the embodiment of the present application, the conversation data of the conversation role in the first time period is obtained, the conversation intention of each conversation sentence in the conversation data is determined, and for each conversation intention, the intention key sentence of the conversation intention is determined from the conversation sentence corresponding to the conversation intention, and then the speech template of the conversation intention corresponding to the conversation role is generated according to the intention key sentence. It can be seen that the speech template is generated based on the conversation intention of the conversation role and the intention key sentence of the conversation intention. Since the intention key sentence has a strong directional effect on the conversation intention, that is, it can reflect the conversation intention of the conversation role from the intention key sentence, it can ensure that the generated speech template matches the conversation intention of the conversation role, thereby improving the template quality and practicality of the speech template.
[0243] The present application also provides another computer-readable storage medium, which stores one or more computer programs. The one or more computer programs include instructions. When the instructions are executed by an electronic device including multiple application programs, the electronic device can perform various processes of the above-mentioned speech generation method embodiment, and are specifically used to perform:
[0244] Obtain the conversation statement of the first user;
[0245] determining a first conversation intention of the first user according to the conversation statement and the role information of the first user;
[0246] Determine a first speech template that matches the first conversation intention; wherein the first speech template is generated according to the speech template generation method described in the above aspect;
[0247] Based on the conversation sentence and the first speech template, generate a speech text corresponding to the conversation sentence.
[0248] By adopting the technical solution of the embodiment of the present application, the first conversation intention of the first user is determined according to the conversation sentence and the role information of the first user, and the first speech template matching the first conversation intention is determined, and then the speech text corresponding to the conversation sentence is generated according to the conversation sentence and the first speech template. Since the speech template generation method provided in the embodiment of the present application can generate a speech template with high quality and high practicality, the speech text generated based on the speech template has a high degree of matching with the conversation sentence of the first user, thereby achieving the effect of efficiently and intelligently processing conversation-related services and saving a lot of labor costs.
[0249] An embodiment of the present application provides a computer program product, including a computer program, wherein the computer program is executed by a processor to implement the various processes of the embodiment of the method for generating a speech template as described above, or the computer program is executed by a processor to implement the various processes of the embodiment of the method for generating a speech template as described above, and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0250] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0251] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0252] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0253] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0254] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0255] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0256] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0257] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0258] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0259] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0260] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0261] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0262] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for generating a speech template, characterized in that: include: Obtaining session data of the session role in the first time period; The conversation data includes a plurality of conversation statements; Determining a conversation intention of each conversation statement in the conversation data; For each conversation intention, determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention; According to the key sentences of the intention, a speech template of the conversation intention corresponding to the conversation role is generated.
2. The method according to claim 1, characterized in that The step of determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention includes: Determine a first sentence vector of a conversation sentence corresponding to the conversation intention; The first sentence vectors of the plurality of conversation sentences are combined into a sentence matrix, and the sentence matrix is subjected to singular value decomposition to obtain a singular value of each conversation sentence; According to the singular value of each conversation sentence, determining at least one conversation sentence satisfying a preset screening condition from the multiple conversation sentences as the intention key sentence; Among them, the singular value of at least one conversation statement that meets the preset screening condition satisfies one or more of the following: the singular value of the conversation statement is less than or equal to a preset threshold, and the singular value of the conversation statement is located in the first N positions after the singular values of multiple conversation statements are sorted from small to large or in the last N positions after the singular values of multiple conversation statements are sorted from large to small.
3. The method according to claim 1, characterized in that The step of determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention includes: Obtaining preset intention key sentences of the conversation intention; For each conversation sentence corresponding to the conversation intention, calculating a first sentence vector of the conversation sentence and a second sentence vector of the preset intention key sentence; If the calculation result between the first sentence vector and the second sentence vector meets the preset calculation condition, determining that the conversation sentence is the intention key sentence; Among them, satisfying the preset calculation conditions includes at least one of the following: the first statement vector is a preset operation result of the second statement vector and a fixed value, and the first statement vector is a preset operation result of multiple second statement vectors.
4. The method according to claim 1, characterized in that: The step of generating a speech template for the conversation intention corresponding to the conversation role according to the intention key sentence includes: Determine the fixed speech elements and the variable speech elements of the conversation intention according to the intention key sentence; Determine the combination order of the fixed speech elements and the variable speech elements according to the sentence information of the key sentence of the intention; the sentence information includes at least one of the following: grammar, sentence pattern, and participle structure; Combining the fixed speech element and the variable speech element according to the combination order to obtain a combined speech element; The variable speech elements in the combined speech elements are replaced with the elements to be filled in to obtain the speech template.
5. The method according to claim 4, characterized in that After generating the speech template of the conversation intention corresponding to the conversation role according to the intention key sentence, the method further includes: Determining evaluation indicators of the speech template; According to the evaluation index, the quality of the speech template is evaluated to obtain a quality evaluation result of the speech template.
6. The method according to claim 5, characterized in that The evaluation index includes template coverage; the evaluation index for determining the speech template includes: Acquire a set of optional elements corresponding to the conversation intention; the set of optional elements includes optional elements that match the variable speech elements in the speech template; Generate a conversation sentence to be tested corresponding to the conversation intention according to the optional element set and the speech template; Determine sentence evaluation parameters of the conversation sentence to be tested, and determine the template coverage of the speech template according to the sentence evaluation parameters; the sentence evaluation parameters include sentence confusion and / or sentence fluency.
7. The method according to claim 5, characterized in that The evaluation index includes semantic matching degree; the conversation data also includes associated conversation statements having a conversation relationship with the multiple conversation statements of the conversation role; The step of determining the evaluation index of the speech template includes: Determining, according to the associated conversation statement, an associated conversation intention having an intention association with the conversation intention; The semantic matching degree of the speech template is determined based on the semantic matching information between the associated conversation intention and the speech template.
8. The method according to claim 1, characterized in that After generating the speech template of the conversation intention corresponding to the conversation role according to the intention key sentence, the method further includes: Obtaining scenario-specific words that match the conversation intent in the target scenario; Matching the scenario speech with the speech template of the conversation intention, and determining the elements to be changed of the speech template according to the matching result; the elements to be changed include at least one of the following: grammar, sentence pattern, participle, and language block; Acquire a scene element corresponding to the element to be changed in the target scene; The element to be changed is changed into the scene element to obtain a migration speech template of the conversation intention in the target scene.
9. A method for generating speech, characterized in that: include: Obtain the conversation statement of the first user; determining a first conversation intention of the first user according to the conversation statement and the role information of the first user; Determine a first speech template that matches the first conversation intention; wherein the first speech template is generated according to the speech template generation method according to any one of claims 1 to 8; According to the first speech template, generate the speech text corresponding to the conversation sentence.
10. The method according to claim 9, characterized in that The determining of a first speech template matching the first conversation intention includes: determining an intent importance level of the first conversation intent; According to the intention importance level and the quality assessment result of each speech template in the multiple speech templates, a first speech template is determined from the multiple speech templates matching the first conversation intention.
11. A device for generating speech templates, characterized in that: include: An acquisition module, used for acquiring session data of a session role in a first time period; The conversation data includes a plurality of conversation statements; A determination module, used to determine the conversation intention of each conversation sentence in the conversation data; For each conversation intention, determining the intention key sentence of the conversation intention from the conversation sentence corresponding to the conversation intention; A generation module is used to generate a speech template of the conversation intention corresponding to the conversation role according to the key sentence of the intention.
12. A speech generating device, characterized in that: include: An acquisition module, used to acquire a conversation statement of the first user; a determination module, configured to determine a first conversation intention of the first user according to the conversation statement and the role information of the first user; Determine a first speech template that matches the first conversation intention; wherein the first speech template is generated according to the speech template generation method according to any one of claims 1 to 8; A generation module is used to generate a speech text corresponding to the conversation sentence based on the first speech template.
13. An electronic device, characterized in that: It includes a processor and a memory electrically connected to the processor, the memory stores a computer program, and the processor is used to call and execute the computer program from the memory to implement the method for generating a speech template as described in any one of claims 1-8, or the processor is used to call and execute the computer program from the memory to implement the method for generating a speech template as described in any one of claims 9-10.
14. A computer-readable storage medium, characterized in that: The storage medium is used to store a computer program, which can be executed by a processor to implement the method for generating a speech template as described in any one of claims 1-8, or the computer program can be executed by a processor to implement the method for generating a speech template as described in any one of claims 9-10.
15. A computer program product, characterized in that It comprises a computer program, which is executed by a processor to implement the method for generating a speech template as described in any one of claims 1-8, or the computer program is executed by a processor to implement the method for generating a speech template as described in any one of claims 9-10.
