Voice response method and device based on knowledge base, equipment and storage medium
Through the knowledge base-based voice response method, combining emotional information and large language models to generate reply text, the problem of unable to provide targeted feedback in the prior art is solved, and the generation of personalized response voice is realized, which improves the user experience and the reliability of reply text.
Patent Information
- Application Number
- CN202411522522.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-28
AI Technical Summary
The existing voice response system cannot provide targeted feedback based on the actual situation of the user and cannot meet the specific needs and preferences of users, resulting in a decrease in user experience and satisfaction.
The speech response method based on the knowledge base is adopted, and the target speech is obtained and converted into text content, and the question statement is encoded to generate sentence vectors. The answer information is obtained using the knowledge base, and the response text is generated based on the emotional information, which is finally generated by the target speaker's response voice.
It realizes personalized response voice based on user specific needs and emotions, improves user experience and satisfaction, and improves the reliability of reply text.
Smart Images

Figure CN119541497A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent voice technology in artificial intelligence, and can be applied to the field of voice interaction. The present invention particularly relates to a knowledge base-based voice response method, device, equipment and storage medium. Background Art
[0002] The target speaker's response voice plays an important role for users because it provides emotional feedback and social demonstrations for users, especially in the fields of self-service, elderly companionship, and children's education and companionship. The elderly can vent their emotions through the intelligent companionship interactive device, and children can imitate and learn the correct voice through interaction with the target speaker, thereby enriching and improving their own language expression ability.
[0003] However, existing voice response systems rely on standardized reply templates, ignoring individual differences and specific needs among users. Therefore, when users ask questions, voice response methods can only provide general answers, but cannot provide targeted feedback based on the user's actual situation. Therefore, the response voice provided by the existing voice response system cannot meet the user's specific needs and preferences, thereby reducing the user's experience and satisfaction. Therefore, how to generate the target speaker's response voice is an urgent problem to be solved. Summary of the invention
[0004] The present invention provides a knowledge base-based voice response method, device, computer equipment and storage medium to solve the technical problem of how to generate a target speaker's response voice.
[0005] In a first aspect, a knowledge base-based voice response method is provided, comprising:
[0006] Acquire target speech, and convert the target speech into text content;
[0007] Obtaining a question sentence in the text content, encoding the question sentence, and generating a sentence vector;
[0008] A knowledge base storing target user group data is selected as a target knowledge base, and answer information is obtained in the target knowledge base through the sentence vector;
[0009] Selecting the answer information as a prompt word template to obtain the emotional information of the target speech;
[0010] Inputting the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model;
[0011] Based on a preset processing method, the target speaker's voice sample and the reply text are processed to generate the target speaker's response voice, and the response voice is played.
[0012] Furthermore, the step of obtaining a question sentence in the text content, encoding the question sentence, and generating a sentence vector includes:
[0013] Obtain a question sentence in the text content, and obtain each word in the question sentence;
[0014] The word embedding vector corresponding to each of the words is input into a preset encoder to obtain the sentence vector output by the encoder.
[0015] Furthermore, the step of selecting a knowledge base storing target user group data as a target knowledge base, and obtaining answer information in the target knowledge base through the sentence vector, includes:
[0016] Obtain target user group data, split the target user group data into multiple segments, convert the segments into vector data, import the vector data into a knowledge base through a data import interface provided by a preset LangChain framework, and select the knowledge base into which the vector data is imported as a target knowledge base;
[0017] Obtain a query instruction for the sentence vector, send the query instruction to the target knowledge base, obtain a query result returned after the target knowledge base executes the query instruction, and select the query result as the answer information.
[0018] Furthermore, the selecting the answer information as a prompt word template to obtain the emotional information of the target speech includes:
[0019] Selecting the answer information as a prompt word template to obtain the speech features of the target speech;
[0020] The emotion information of the target speech is determined according to the speech features and a preset emotion recognition model.
[0021] Furthermore, the step of inputting the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model includes:
[0022] Inputting the prompt word template, the text content, and the emotional information into the encoding layer of a preset large language model;
[0023] Through the attention mechanism of the encoding layer, the text features of the prompt word template, the text features of the text content and the text features of the emotional information are fused to generate target features, and the target features are input into the generator of the large language model to obtain the reply text generated by the generator.
[0024] Further, the processing of the target speaker's voice sample and the reply text based on a preset processing method, generating the target speaker's response voice, and playing the response voice includes:
[0025] Acquire a voice sample of a target speaker, perform feature extraction on the voice sample, and generate a first feature vector;
[0026] The third feature vector is decoded into a mel-spectrogram, the mel-spectrogram is input into a vocoder of a speech synthesis engine, the mel-spectrogram is processed for speech synthesis by the vocoder, a response speech of the target speaker is generated, and the response speech is played.
[0027] Furthermore, in the preset processing method, the target speaker's voice sample and the reply text are processed to generate the target speaker's response voice, and after the response voice is played, the voice response method includes:
[0028] Get a push instruction, and push the reply text and the answer voice to a preset monitoring system.
[0029] In a second aspect, a knowledge base-based voice response device is provided, comprising:
[0030] A first acquisition module, used to acquire a target voice and convert the target voice into text content;
[0031] A second acquisition module is used to acquire question sentences in the text content, encode the question sentences, and generate sentence vectors;
[0032] A third acquisition module is used to select a knowledge base storing target user group data as a target knowledge base, and obtain answer information in the target knowledge base through the sentence vector;
[0033] A fourth acquisition module, used for selecting the answer information as a prompt word template to acquire the emotional information of the target speech;
[0034] An input module, used to input the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model;
[0035] The answering module is used to process the voice sample of the target speaker and the reply text based on a preset processing method, generate the answering voice of the target speaker, and play the answering voice.
[0036] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned voice response method when executing the computer program.
[0037] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned voice response method are implemented.
[0038] The present application provides a knowledge base-based voice response method, device, computer equipment and storage medium, which obtain a target voice and convert the target voice into text content; obtain a question sentence in the text content, encode the question sentence and generate a sentence vector; select a knowledge base storing target user group data as a target knowledge base, and obtain answer information in the target knowledge base through the sentence vector; select the answer information as a prompt word template to obtain the emotional information of the target voice; input the prompt word template, the text content and the emotional information into a preset large language model to obtain a reply text generated by the large language model; based on a preset processing method, process the voice sample of the target speaker and the The invention relates to a method for generating a reply text, generating a response voice of the target speaker, and playing the response voice. The beneficial effects are in two aspects. On the one hand, based on a preset processing method, the sound sample of the target speaker and the reply text are processed to generate the response voice of the target speaker, and the response voice is played, which solves the problem of how to generate the response voice of the target speaker and is beneficial to improving the efficiency of obtaining the response voice of the target speaker. On the other hand, the answer information is selected as a prompt word template to obtain the emotional information of the target voice, and the prompt word template, the text content, and the emotional information are input into a preset large language model to obtain the reply text generated by the large language model, thereby helping to improve the reliability of the obtained reply text. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0040] Figure 1 is a schematic diagram of an application environment of a voice response method in one embodiment of the present invention;
[0041] Figure 2 A flow chart of a voice response method provided by an embodiment of the present invention;
[0042] Figure 3 yes Figure 1 A schematic flow chart of a specific implementation of step S23;
[0043] Figure 4 yes Figure 1 A schematic flow chart of a specific implementation of step S25;
[0044] Figure 5 yes Figure 1 A schematic flow chart of a specific implementation of step S26;
[0045] Figure 6 is a structural schematic diagram of a voice response device in one embodiment of the present invention;
[0046] Figure 7 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;
[0047] Figure 8 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] See also Figure 1 , Figure 1 FIG. 1 is a schematic diagram of an application environment of a voice response method according to an embodiment of the present invention. The voice response method provided by the embodiment of the present invention can be applied in the following embodiments: Figure 1 In an application environment, a client communicates with a server through a network.
[0050] The server obtains the target voice through the client and converts the target voice into text content;
[0051] Obtaining a question sentence in the text content, encoding the question sentence, and generating a sentence vector;
[0052] A knowledge base storing target user group data is selected as a target knowledge base, and answer information is obtained in the target knowledge base through the sentence vector;
[0053] Selecting the answer information as a prompt word template to obtain the emotional information of the target speech;
[0054] Inputting the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model;
[0055] Based on a preset processing method, the target speaker's voice sample and the reply text are processed to generate the target speaker's response voice, and the response voice is played.
[0056] In the scheme implemented by the above-mentioned voice response method, device, equipment and medium, the beneficial effects are in two aspects. On the one hand, based on a preset processing method, the sound sample of the target speaker and the reply text are processed to generate the response voice of the target speaker, and the response voice is played, which solves the problem of how to generate the response voice of the target speaker and is conducive to improving the efficiency of obtaining the response voice of the target speaker; on the other hand, the answer information is selected as a prompt word template to obtain the emotional information of the target voice, and the prompt word template, the text content, and the emotional information are input into a preset large language model to obtain the reply text generated by the large language model, thereby helping to improve the reliability of the obtained reply text.
[0057] The device running the client is referred to as a client device.
[0058] The device running the server is referred to as the server device.
[0059] The client devices may include but are not limited to various personal computers, laptops, smart phones, tablet computers, and portable wearable devices.
[0060] The server device can be implemented with an independent task database or a task database cluster composed of multiple task databases. The present invention is described in detail below through specific embodiments.
[0061] See also Figure 2 , Figure 2 A flow chart of a voice response method provided in one embodiment of the present invention includes the following steps:
[0062] S21, acquiring a target voice, and converting the target voice into text content;
[0063] Exemplarily, the acquiring the target speech and converting the target speech into text content includes:
[0064] The audio collected by the microphone is obtained, and when the acoustic features of the audio are the sound features of a child speaking, the audio is selected as the target voice, and the target voice is converted into text content.
[0065] S22, obtaining a question sentence in the text content, encoding the question sentence, and generating a sentence vector;
[0066] The step of obtaining a question sentence in the text content, encoding the question sentence, and generating a sentence vector includes:
[0067] Obtain a question sentence in the text content, and obtain each word in the question sentence;
[0068] The word embedding vector corresponding to each of the words is input into a preset encoder to obtain the sentence vector output by the encoder.
[0069] S23, selecting a knowledge base storing target user group data as a target knowledge base, and obtaining answer information in the target knowledge base through the sentence vector;
[0070] Among them, a knowledge base storing target user group data is selected as the target knowledge base. In the target knowledge base, answer information is obtained through the sentence vector, which can meet the user's specific needs and preferences, and is conducive to improving the user's usage experience and satisfaction.
[0071] Among them, the target user group data includes but is not limited to the companion corpus of the target user group, the mental health data of the target user group, and the books of the target user group.
[0072] For example, when the target user group is the elderly, the companion corpus of the target user group is the companion corpus of the elderly, the mental health data of the target user group is the mental health data of the elderly, and the books of the target user group are health books.
[0073] For example, when the target user group is children, the companion corpus for the target user group is the children's companion corpus, the mental health data for the target user group is the children's mental health data, and the books for the target user group are children's encyclopedia books. Among them, the children's companion corpus refers to those text or voice materials that are designed to promote parent-child interaction, emotional communication and language development. The children's companion corpus provides children with a rich language environment through vivid and interesting stories, daily conversation examples and educational games, helping them grow happily in love and understanding.
[0074] Among them, children's mental health data is collected and collated based on scientific research, and contains information about the psychological problems, development patterns and intervention measures that children may face at different ages. Children's mental health data provides valuable reference for parents, educators and mental health professionals, enabling them to more accurately identify children's mental states, take appropriate measures in a timely manner to prevent or solve potential psychological problems, and ensure that children's mental health is properly taken care of.
[0075] Among them, the Children's Encyclopedia is a comprehensive popular science book designed for children, which brings together basic knowledge in many fields such as natural sciences, social sciences, humanities and arts. Through easy-to-understand text descriptions and vivid illustrations, the Children's Encyclopedia transforms complex scientific principles, historical events, cultural phenomena, etc. into information that is easy for children to understand and accept.
[0076] S24, selecting the answer information as a prompt word template to obtain the emotional information of the target speech;
[0077] The step of selecting the answer information as a prompt word template to obtain the emotional information of the target speech includes:
[0078] Selecting the answer information as a prompt word template to obtain the speech features of the target speech;
[0079] The emotion information of the target speech is determined according to the speech features and a preset emotion recognition model.
[0080] Among them, the emotion recognition model refers to a model used to identify the emotional state of human beings. The emotion recognition model automatically identifies the emotional state of the target speech, such as happiness, sadness, anger, surprise, fear, etc., by analyzing and processing the target speech.
[0081] S25, inputting the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model;
[0082] Among them, the large language model includes but is not limited to the ChatGLM language model and the GPT model.
[0083] The Chinese name of the ChatGLM language model is Chat Generative Language Model, and the English name of the ChatGLM language model is Chat Generative Language Model. The ChatGLM language model is an open source conversational language model that supports both Chinese and English.
[0084] The Chinese name of the GPT model is: Generative Pre-Trained Transformer Model, and the English name is: Generative Pre-Trained Transformer. The GPT model is a natural language processing model based on deep learning.
[0085] S26, based on a preset processing method, processing the target speaker's voice sample and the reply text, generating the target speaker's response voice, and playing the response voice.
[0086] When the target user group is the elderly, the target speakers include but are not limited to sons and daughters.
[0087] Among them, when the target user group is the elderly, based on the preset processing method, the voice sample of the target speaker and the reply text are processed to generate the response voice of the target speaker, and the response voice is played. It can not only effectively alleviate the loneliness of the elderly and improve their mental health level, but also imitate human dialogue and emotional communication, provide companionship and comfort for the elderly, and make the elderly feel warmth and care.
[0088] When the target user group is children, the target speakers include but are not limited to parents, grandfathers, grandmothers, and teachers.
[0089] Among them, when the target user group is children, based on a preset processing method, the voice sample of the target speaker and the reply text are processed to generate the response voice of the target speaker, and the response voice is played, which can ensure that children receive continuous care and guidance when parents are busy or teacher resources are limited.
[0090] For the sake of illustration, an example is given below:
[0091] For example, when the target speaker is a parent, when the system detects that a child is asking questions about space exploration, it quickly retrieves relevant scientific knowledge through the knowledge base, identifies the child's excitement, uses the parent's pre-recorded voice samples, synthesizes a response voice, and plays the response voice. This not only conveys accurate scientific knowledge, but also strengthens the emotional connection between parents and children.
[0092] For example, when the target speaker is a grandfather, when the system detects that a child asks a question about the sun, it quickly retrieves relevant scientific knowledge through the knowledge base, identifies the child's excitement, uses the grandfather's pre-recorded voice sample, synthesizes a response voice, and plays the response voice. This not only conveys accurate scientific knowledge, but also strengthens the emotional connection between the child and the grandfather.
[0093] For example, if the target speaker is a grandmother, when the system detects that a child is asking questions about lunar exploration, it quickly retrieves relevant scientific knowledge through the knowledge base, identifies the child's excitement, uses the grandmother's pre-recorded voice sample, synthesizes a response voice, and plays the response voice. This not only conveys accurate scientific knowledge, but also strengthens the emotional connection between the child and the grandmother.
[0094] Wherein, in the preset processing mode, the target speaker's voice sample and the reply text are processed to generate the target speaker's reply voice, and after the reply voice is played, the voice reply method includes:
[0095] Get a push instruction, and push the reply text and the answer voice to a preset monitoring system.
[0096] Among them, the reply text and the response voice are pushed to a preset monitoring system, which is helpful for the target speaker to view the reply text and the response voice.
[0097] In the embodiment of the present invention, the beneficial effects lie in two aspects. On the one hand, based on a preset processing method, the sound sample of the target speaker and the reply text are processed to generate the response voice of the target speaker, and the response voice is played, which solves the problem of how to generate the response voice of the target speaker and is beneficial to improving the efficiency of obtaining the response voice of the target speaker. On the other hand, the answer information is selected as a prompt word template to obtain the emotional information of the target voice, and the prompt word template, the text content, and the emotional information are input into a preset large language model to obtain the reply text generated by the large language model, thereby helping to improve the reliability of the obtained reply text.
[0098] See also Figure 3 , Figure 3 yes Figure 1 A specific implementation flow diagram of step S23 is described in detail as follows:
[0099] S31, obtaining target user group data, splitting the target user group data into multiple segments, converting the segments into vector data, importing the vector data into a knowledge base through a data import interface provided by a preset LangChain framework, and selecting the knowledge base into which the vector data is imported as a target knowledge base;
[0100] Among them, the LangChain framework is an AI engineering development framework based on an open source large language model, designed for researchers and developers to simplify the interaction process with large language models.
[0101] S32, obtaining a query instruction for the sentence vector, sending the query instruction to the target knowledge base, obtaining a query result returned after the target knowledge base executes the query instruction, and selecting the query result as the answer information.
[0102] In an embodiment of the present invention, the query result is selected as the answer information. Since the target knowledge base stores a large amount of target user group data, it can meet the learning needs of children of different ages and development stages. In addition, the powerful search function of the database makes information retrieval fast and efficient. Parents and educators can quickly locate information suitable for the child’s current learning level and interests, thereby saving a lot of screening and sorting time.
[0103] See also Figure 4 , Figure 4 yes Figure 1 A specific implementation flow diagram of step S25 is described in detail as follows:
[0104] S41, inputting the prompt word template, the text content, and the emotional information into the encoding layer of a preset large language model;
[0105] S42, through the attention mechanism of the encoding layer, the text features of the prompt word template, the text features of the text content and the text features of the emotional information are integrated to generate a target feature, and the target feature is input into the generator of the large language model to obtain the reply text generated by the generator.
[0106] In an embodiment of the present invention, the text features of the prompt word template, the text features of the text content and the text features of the emotional information are fused through the attention mechanism of the encoding layer to generate a target feature. Since the target feature carries emotional information, the generator can learn the emotional information. Based on this way of learning the emotional information, the generator can generate an emotion-rich reply text, making the response voice more realistic.
[0107] See also Figure 5 , Figure 5 yes Figure 1 A specific implementation flow diagram of step S26 is described in detail as follows:
[0108] S51, obtaining a voice sample of a target speaker, performing feature extraction on the voice sample, and generating a first feature vector;
[0109] S52, decoding the third feature vector into a mel-spectrogram, inputting the mel-spectrogram into a vocoder of a speech synthesis engine, performing speech synthesis processing on the mel-spectrogram through the vocoder to generate a response speech of the target speaker, and playing the response speech.
[0110] In the embodiment of the present invention, the mel-spectrogram is subjected to speech synthesis processing by the vocoder to generate the response speech of the target speaker, and the response speech is played, thereby solving the problem of how to generate the response speech of the target speaker and improving the efficiency of obtaining the response speech of the target speaker. In addition, the response speech can simulate the tone and intonation of the target speaker, so that children feel a sense of intimacy and security when hearing it, which is conducive to increasing the authenticity of the response speech.
[0111] See also Figure 6 , Figure 6 FIG. 1 is a schematic diagram of a structure of a voice response device in an embodiment of the present invention. Figure 6As shown, the voice response device includes a first acquisition module 101, a second acquisition module 102, a third acquisition module 103, a fourth acquisition module 104, an input module 105, and a response module 106. The detailed description of each functional module is as follows:
[0112] The first acquisition module 101 is used to acquire a target speech and convert the target speech into text content;
[0113] The second acquisition module 102 is used to acquire the question sentence in the text content, encode the question sentence, and generate a sentence vector;
[0114] A third acquisition module 103 is used to select a knowledge base storing target user group data as a target knowledge base, and obtain answer information in the target knowledge base through the sentence vector;
[0115] A fourth acquisition module 104 is used to select the answer information as a prompt word template to obtain the emotional information of the target speech;
[0116] An input module 105 is used to input the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model;
[0117] The answering module 106 is used to process the voice sample of the target speaker and the reply text based on a preset processing method, generate the answering voice of the target speaker, and play the answering voice.
[0118] In one embodiment, the second acquisition module 102 includes:
[0119] A first acquisition subunit is used to acquire a question sentence in the text content, and acquire each word in the question sentence;
[0120] The second acquisition subunit is used to input the word embedding vector corresponding to each of the words into a preset encoder to obtain the sentence vector output by the encoder.
[0121] In one embodiment, the third acquisition module 103 includes:
[0122] A subunit is selected to obtain target user group data, split the target user group data into multiple segments, convert the segments into vector data, import the vector data into a knowledge base through a data import interface provided by a preset LangChain framework, and select the knowledge base into which the vector data is imported as a target knowledge base;
[0123] The third acquisition subunit is used to obtain the query instruction of the sentence vector, send the query instruction to the target knowledge base, obtain the query result returned after the target knowledge base executes the query instruction, and select the query result as the answer information.
[0124] In one embodiment, the fourth acquisition module 104 includes:
[0125] A fourth acquisition subunit, configured to select the answer information as a prompt word template to acquire the speech feature of the target speech;
[0126] The determination subunit is used to determine the emotion information of the target speech according to the speech features and a preset emotion recognition model.
[0127] In one embodiment, the input module 105 includes:
[0128] An input subunit, used for inputting the prompt word template, the text content, and the emotional information into an encoding layer of a preset large language model;
[0129] A generating subunit is used to fuse the text features of the prompt word template, the text features of the text content and the text features of the sentiment information through the attention mechanism of the encoding layer to generate a target feature, input the target feature into the generator of the large language model, and obtain the reply text generated by the generator.
[0130] In one embodiment, the response module 106 includes:
[0131] An extraction subunit, configured to obtain a voice sample of a target speaker, perform feature extraction on the voice sample, and generate a first feature vector;
[0132] The answering subunit is used to decode the third feature vector into a mel-spectrogram, input the mel-spectrogram into a vocoder of a speech synthesis engine, perform speech synthesis processing on the mel-spectrogram through the vocoder, generate a response speech of the target speaker, and play the response speech.
[0133] In one embodiment, the voice response device further includes:
[0134] The push module is used to obtain a push instruction and push the reply text and the answer voice to a preset monitoring system.
[0135] In the embodiment of the present invention, the beneficial effects lie in two aspects. On the one hand, based on a preset processing method, the sound sample of the target speaker and the reply text are processed to generate the response voice of the target speaker, and the response voice is played, which solves the problem of how to generate the response voice of the target speaker and is beneficial to improving the efficiency of obtaining the response voice of the target speaker. On the other hand, the answer information is selected as a prompt word template to obtain the emotional information of the target voice, and the prompt word template, the text content, and the emotional information are input into a preset large language model to obtain the reply text generated by the large language model, thereby helping to improve the reliability of the obtained reply text.
[0136] For the specific limitations on the voice response device, please refer to the limitations on the voice response method above, which will not be repeated here.
[0137] Each module in the above-mentioned voice response device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0138] See also Figure 7 , Figure 7 is a schematic diagram of a computer device in one embodiment of the present invention. In one embodiment, a computer device is provided. The computer device may be a server device, and its internal structure diagram may be as shown in FIG. Figure 7 The computer device includes a processor, a memory, a network interface and a database connected through a system bus.
[0139] The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client through a network connection. When the computer program is executed by the processor, the functions or steps of a voice response method based on a knowledge base can be implemented on the server device.
[0140] See also Figure 8 , Figure 8 is another structural diagram of a computer device in one embodiment of the present invention. In one embodiment, a computer device is provided. The computer device may be a client device, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external task database through a network connection. When the computer program is executed by the processor, the functions or steps of a knowledge base-based voice response method can be implemented on the client device.
[0141] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor.
[0142] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant description in the aforementioned method embodiment. In order to avoid repetition, they will not be described one by one here.
[0143] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0144] The above description and accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. Parts and subsamples of some embodiments may be included in or replace parts and subsamples of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of a stated sub-sample, whole, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other sub-samples, wholes, steps, operations, elements, components and / or groups of these. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0145] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0146] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some sub-samples can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.
[0147] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A knowledge base-based voice response method, characterized in that: include: Acquire target speech, and convert the target speech into text content; Obtaining a question sentence in the text content, encoding the question sentence, and generating a sentence vector; A knowledge base storing target user group data is selected as a target knowledge base, and answer information is obtained in the target knowledge base through the sentence vector; Selecting the answer information as a prompt word template to obtain the emotional information of the target speech; Inputting the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model; Based on a preset processing method, the target speaker's voice sample and the reply text are processed to generate the target speaker's response voice, and the response voice is played.
2. The voice response method according to claim 1, characterized in that: The obtaining of the question sentence in the text content, encoding the question sentence, and generating a sentence vector includes: Obtain a question sentence in the text content, and obtain each word in the question sentence; The word embedding vector corresponding to each of the words is input into a preset encoder to obtain the sentence vector output by the encoder.
3. The voice response method according to claim 1, characterized in that: The step of selecting a knowledge base storing target user group data as a target knowledge base, and obtaining answer information in the target knowledge base through the sentence vector, includes: Obtain target user group data, split the target user group data into multiple segments, convert the segments into vector data, import the vector data into a knowledge base through a data import interface provided by a preset LangChain framework, and select the knowledge base into which the vector data is imported as a target knowledge base; Obtain a query instruction for the sentence vector, send the query instruction to the target knowledge base, obtain a query result returned after the target knowledge base executes the query instruction, and select the query result as the answer information.
4. The voice response method according to claim 1, characterized in that: The step of selecting the answer information as a prompt word template to obtain the emotional information of the target speech includes: Selecting the answer information as a prompt word template to obtain the speech features of the target speech; The emotion information of the target speech is determined according to the speech features and a preset emotion recognition model.
5. The voice response method according to claim 1, characterized in that: The step of inputting the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model includes: Inputting the prompt word template, the text content, and the emotional information into the encoding layer of a preset large language model; Through the attention mechanism of the encoding layer, the text features of the prompt word template, the text features of the text content and the text features of the emotional information are fused to generate target features, and the target features are input into the generator of the large language model to obtain the reply text generated by the generator.
6. The voice response method according to claim 1, characterized in that: The method of processing the target speaker's voice sample and the reply text based on a preset processing method, generating the target speaker's reply voice, and playing the reply voice includes: Acquire a voice sample of a target speaker, perform feature extraction on the voice sample, and generate a first feature vector; The third feature vector is decoded into a mel-spectrogram, the mel-spectrogram is input into a vocoder of a speech synthesis engine, the mel-spectrogram is processed for speech synthesis by the vocoder, a response speech of the target speaker is generated, and the response speech is played.
7. The voice response method according to any one of claims 1 to 6, characterized in that: In the preset processing method, the target speaker's voice sample and the reply text are processed to generate the target speaker's reply voice, and after the reply voice is played, the voice reply method includes: Get a push instruction, and push the reply text and the answer voice to a preset monitoring system.
8. A voice response device based on a knowledge base, characterized in that: include: A first acquisition module, used to acquire a target voice and convert the target voice into text content; A second acquisition module is used to acquire question sentences in the text content, encode the question sentences, and generate sentence vectors; A third acquisition module is used to select a knowledge base storing target user group data as a target knowledge base, and obtain answer information in the target knowledge base through the sentence vector; A fourth acquisition module, used for selecting the answer information as a prompt word template to acquire the emotional information of the target speech; An input module, used to input the prompt word template, the text content, and the emotional information into a preset large language model to obtain a reply text generated by the large language model; The answering module is used to process the voice sample of the target speaker and the reply text based on a preset processing method, generate the answering voice of the target speaker, and play the answering voice.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the voice response method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the voice response method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Voice interaction method and device, computer equipment and storage medium
CN119993216A
Man-machine conversation implementation method and device, electronic equipment and computer storage medium
CN121256005A