Voice reply method and device, electronic equipment and storage medium
By segmenting and splicing text segments in voice interaction, and combining large language models to generate reply text segments, the problem of unreasonable pauses in voice broadcasts is solved, and the fluency and user experience of voice replies are improved.
Patent Information
- Application Number
- CN202410796746.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-09-06
AI Technical Summary
In voice interaction scenarios, existing technology is difficult to achieve real-time text-to-speech (TTS) conversion, resulting in unreasonable pauses when replying to voice broadcasts, affecting user experience.
By segmenting and splicing the generated text segments, determining the segmentation position based on the end information of the text segment, broadcasting the reply voice segment by segment to avoid unreasonable pauses, and using a large language model to generate reply text segments and optimize the text segment cache queue. To improve the smoothness of voice broadcast.
It achieves smoothness of voice broadcast and improvement of user experience, avoids unreasonable pauses, and improves the smoothness of voice replies.
Smart Images

Figure CN118606435A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the field of natural language processing, the field of voice interaction and the field of large models. The present disclosure specifically relates to a voice reply method, device, electronic device and storage medium. Background Art
[0002] In voice interaction scenarios, such as chatbots and intelligent customer service applications, text is generated based on user input and the corresponding content is broadcast. The generated content is returned in a streaming manner, that is, it is returned to the user interface or broadcast to the user segment by segment.
[0003] In order to achieve the real-time performance of TTS (Text To Speech), each generated text segment is passed to the TTS engine, which converts the text segment into a voice signal. Then, the voice signal is broadcast through audio devices such as speakers or headphones, and the user can hear the voice content generated by the system. In this way, the user can interact with the system by listening to the system's voice response. Summary of the invention
[0004] The present disclosure provides a voice reply method, device, electronic device and storage medium.
[0005] According to one aspect of the present disclosure, a voice reply method is provided, comprising:
[0006] When a first text segment in response to the voice question is obtained, the first text segment is segmented based on the ending information of the first text segment to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment;
[0007] If the second text segment is a non-empty text segment, the second text segment is concatenated to the end of the fourth text segment to be broadcasted at the current moment obtained by segmentation at the previous moment, so as to obtain the target text segment to be broadcasted at the current moment;
[0008] Based on the target text segment, a current reply speech segment for the question speech is determined.
[0009] According to another aspect of the present disclosure, there is provided a voice reply method, comprising:
[0010] Determine the corresponding prompt word keyword based on the question text corresponding to the question voice;
[0011] Inputting the prompt word keyword into at least one large language model, wherein the large language model is used to generate a reply text segment for the question voice based on the prompt word keyword;
[0012] When the large language model generates the reply text segment, adding the reply text segment to the text segment cache queue;
[0013] Based on the text segment cache queue, a reply voice for the question voice is determined.
[0014] According to another aspect of the present disclosure, there is provided a voice reply device, comprising:
[0015] A text segment segmentation module is used for, when a first text segment for replying to a question voice is obtained, segmenting the first text segment based on the ending information of the first text segment to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment;
[0016] A text segment concatenation module, for concatenating the second text segment to the end of the fourth text segment to be broadcasted at the current moment obtained by segmentation at the previous moment, when the second text segment is a non-empty text segment, to obtain a target text segment to be broadcasted at the current moment;
[0017] The first speech determination module is used to determine a current reply speech segment for the question speech based on the target text segment.
[0018] According to another aspect of the present disclosure, there is provided a voice reply device, comprising:
[0019] A prompt word determination module, used to determine the corresponding prompt word keyword based on the question text corresponding to the question voice;
[0020] A model processing module, used for inputting the prompt word keyword into at least one large language model, wherein the large language model is used for generating a reply text segment for the question voice based on the prompt word keyword;
[0021] A text segment adding module, configured to add the reply text segment to the text segment cache queue when the reply text segment is generated by the large language model;
[0022] The second voice determination module is used to determine a reply voice for the question voice based on the text segment cache queue.
[0023] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0024] at least one central processing unit; and
[0025] A memory in communication with the at least one central processing unit; wherein,
[0026] The memory stores instructions that can be executed by the at least one central processing unit, and the instructions are executed by the at least one central processing unit so that the at least one central processing unit can execute any voice reply method in the embodiments of the present disclosure.
[0027] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any voice reply method in the embodiments of the present disclosure.
[0028] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements any voice reply method according to the embodiments of the present disclosure when executed by a processor.
[0029] According to the technology disclosed in the present invention, when the first text segment returned for the question voice is obtained, the first text segment is segmented based on the ending information of the first text segment to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment. When the second text segment is a non-empty text segment, the second text segment is spliced to the end of the fourth text segment to be broadcast at the current moment obtained by segmentation at the previous moment to obtain the target text segment that needs to be broadcast at the current moment, thereby broadcasting the current reply voice segment for the question voice based on the target text segment. In this way, each time a text segment is obtained, the text segment is segmented and spliced according to the ending information of the text segment, so that the reply voice pauses accurately according to the ending information, avoiding unreasonable pauses, and thus smoothly broadcasting the reply voice.
[0030] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0032] Figure 1 is a scene diagram of a voice reply method according to an embodiment of the present disclosure;
[0033] Figure 2 is a flow chart of a voice reply method according to another embodiment of the present disclosure;
[0034] Figure 3 is a flow chart of a voice reply method according to an embodiment of the present disclosure;
[0035] Figure 4 is a flow chart of a voice reply method according to another embodiment of the present disclosure;
[0036] Figure 5 is a flow chart of a voice reply method according to another embodiment of the present disclosure;
[0037] Figure 6 is a flowchart of text segment segmentation and splicing according to an embodiment of the present disclosure;
[0038] Figure 7 is a structural block diagram of a voice reply device according to an embodiment of the present disclosure;
[0039] Figure 8 is a structural block diagram of a voice reply device according to another embodiment of the present disclosure;
[0040] Fig. 9 is a structural block diagram of a voice reply device according to another embodiment of the present disclosure;
[0041] Fig.10 is a structural block diagram of a voice reply device according to another embodiment of the present disclosure;
[0042] Fig.11 is a block diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0043] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0044] In order to facilitate understanding of the trajectory planning method provided by the embodiment of the present disclosure, the related technologies of the embodiment of the present disclosure are explained below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiment of the present disclosure as optional solutions, and they all belong to the protection scope of the embodiment of the present disclosure.
[0045] Figure 1 is a scene diagram of a voice interaction method according to an embodiment of the present disclosure. Figure 1As shown, the scenario includes a server 11 and multiple clients 12. The client 12 can be a mobile smart phone, a desktop computer, a wearable electronic device, etc. The user can interact with the client 12 by voice, and the client can upload the user's question voice to the server 11. The server 11 can use a large language model to generate reply text segments for the question voice segment by segment, and return them to the client 12 in a streaming manner. The client 12 uses a TTS engine to convert the received reply text segment into voice, and broadcasts the voice through a speaker or other device so that the user can hear the reply voice. After the client 12 uses the TTS engine to convert the text segment into voice, it can use the embodiment of the present disclosure to perform operations such as segmentation and splicing on the text segment, and then provide the new text segment to the TTS engine for voice conversion, thereby achieving smooth voice broadcasting.
[0046] In some embodiments, a large language model may also be set in the client 12 to generate a reply text for the question voice.
[0047] In some examples, the embodiments of the present disclosure can be applied to in-vehicle voice interaction scenarios, robot voice chat scenarios, etc.
[0048] It should be noted that the voices used in this disclosure are obtained with the authorization of the user, and their storage and application operations comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0049] Figure 2 : is a flowchart of a voice reply method of an embodiment of the present disclosure. The method can be applied to an electronic device. The electronic device is, for example, a terminal, a server or other processing device, wherein the terminal can be a user equipment (UE) such as a desktop computer, a mobile device, a PDA (Personal Digital Assistant), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some implementations, the electronic device can implement the voice reply method of the embodiment of the present disclosure by calling a computer-readable instruction stored in a memory by a central processing unit.
[0050] like Figure 1 As shown, the method may include the following steps:
[0051] S210, when a first text segment in response to a question voice is obtained, the first text segment is segmented based on the ending information of the first text segment to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment;
[0052] S220, when the second text segment is a non-empty text segment, the second text segment is concatenated to the end of the fourth text segment to be broadcasted at the current moment obtained by segmentation at the previous moment, to obtain a target text segment to be broadcasted at the current moment;
[0053] S230: Determine a current reply speech segment for the question speech based on the target text segment.
[0054] It is understandable that the question voice is submitted to the cloud or another client for processing, and the first text segment returned by the cloud or the client in response to the question voice is obtained. The cloud or the client can return the first text segment segment by segment.
[0055] It can be understood that the first text segment refers to any text segment that responds to the question voice.
[0056] It is understandable that the text returned for the question voice may be composed of a plurality of continuous text segments. These text segments may be cached in a text segment cache queue, from which the text segments are extracted one by one to perform the above steps.
[0057] For example, each time a reply text segment is generated or obtained for a question voice, the reply text segment is inserted into the end of the text segment cache queue.
[0058] For another example, each time a text segment is extracted, the text segment can be deleted from the queue. In this way, the text segment that is ranked second in the queue before the first text segment is deleted can be ranked first in the queue after the first text segment is deleted, so that the above steps S210 to S23 are performed for the next first text segment.
[0059] It can be understood that each time a text segment corresponding to the question voice is obtained, the above steps S210 to S230 can be performed once.
[0060] Exemplarily, the ending information may include ending character information of the first text segment and whether the first text segment carries a dialog end mark.
[0061] For example, the ending character information may include punctuation marks or special symbols.
[0062] For example, when the tag carried by the first text segment is 1, it indicates that it carries a dialog end tag, that is, it indicates that the first text segment is the last text segment in the text sequence that responds to the question voice. For another example, when the tag carried by the first text segment is 0, it indicates that it does not carry a dialog end tag, but carries a non-dialog end tag, that is, it indicates that the first text segment is not the last text segment in the text sequence that responds to the question voice.
[0063] Exemplarily, in the above step S210, based on the ending information of the first text segment, it is determined whether the first text segment needs to be segmented. When it is determined that the first text segment needs to be segmented, it is determined whether punctuation marks are included in the first text segment. If there are punctuation marks, the first text segment is segmented at the position where the punctuation mark or the last punctuation mark in the first text segment is located, and two text segments are obtained. The text segment before the segmentation position is the second text segment, which is the text segment that needs to be broadcast at the current moment. The text segment after the segmentation position is the third text segment, which is the text segment to be broadcasted at the next moment. Of course, if the text segment to be broadcasted at the previous moment is a non-empty text segment, the text segment after the segmentation position is spliced with the text segment to be broadcasted at the previous moment, as the text segment to be broadcasted at the next moment.
[0064] Continuing with the above example, if there is no punctuation mark, the first text segment is not segmented, and the first text segment is used as the text segment to be broadcasted at the next moment. Of course, if the text segment to be broadcasted at the previous moment is a non-empty text segment, the first text segment is concatenated with the text segment to be broadcasted at the previous moment, and used as the text segment to be broadcasted at the next moment.
[0065] It can be understood that in the above step S210, when the first text segment is segmented, the first text segment can be segmented into two segments to obtain a second text segment and a third text segment. Alternatively, the first text segment is completely segmented into the second text segment, and the third text segment is an empty text segment. Alternatively, the first text segment is completely segmented into the third text segment, and the second text segment is an empty text segment.
[0066] It can be understood that, based on the segmentation position of the first text segment, the text segment before the segmentation position is the second text segment, and the text segment after the segmentation position is the third text segment.
[0067] It can be understood that the current moment may be the moment when steps S210-S230 are currently being executed, the previous moment is the moment when steps S210-S230 were last executed, and the next moment is the moment when steps S210-S230 are next executed.
[0068] It can be understood that the third text segment is used for the broadcast to be determined at the next moment and may be used for the broadcast at the next moment.
[0069] It can be understood that the fourth text segment is a text segment of the current time to be broadcasted obtained at the last time or when the steps S210-S230 were last executed. The fourth text segment can be a non-empty text segment or an empty text segment.
[0070] It can be understood that, in the above step S220, if the second text segment is a non-empty text segment and the fourth text segment is an empty text segment, the second text segment is the target text segment.
[0071] It can be understood that in the above step S220, if the second text segment is a non-empty text segment and the fourth text segment is a non-empty text segment, the second text segment is concatenated to the end of the fourth text segment to obtain the target text segment.
[0072] It can be understood that an empty text segment does not include any characters, and a non-empty text segment includes at least one character.
[0073] It can be understood that when the second text segment is an empty text segment and the text segment cache queue is a non-empty queue, step S220 and step S230 are not executed, and the process returns to step S210 to execute the operation at the next moment, that is, step S210 to step S230.
[0074] According to the above implementation, each time a first text segment for a question voice is obtained, the first text segment is segmented based on the ending information of the first text segment to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment. When the second text segment is a non-empty text segment, the second text segment is spliced to the end of the fourth text segment to be broadcast at the current moment obtained by segmentation at the previous moment, to obtain the target text segment that needs to be broadcast at the current moment. Thus, based on the target text segment, the current reply voice segment for the question voice is broadcast. In this way, it is possible to segment and splice the text segment according to the ending information of the reply text segment, so that the reply voice pauses accurately according to the ending information, avoiding unreasonable pauses, and thus smoothly broadcasting the reply voice.
[0075] In one embodiment, in the above step S210, based on the ending information of the first text segment, the first text segment is segmented to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment, which may include: based on the ending information of the first text segment, determining the segmentation position in the first text segment; based on the segmentation position, segmenting the first text segment to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment.
[0076] Exemplarily, the segmentation position may include any middle position, the first character position, the last character position, etc. in the first text segment except the first and last characters.
[0077] Exemplarily, if the ending information includes the first character or the dialog end mark, the segmentation position may be the ending character position. It can be understood that the ending character position is located at the end of the ending character.
[0078] Exemplarily, if the ending information does not include the first character and the dialog end mark, the segmentation position may be any middle position in the text segment except the first and last characters, or the first character position. Further, if the first character is included in the non-ending characters of the first text segment, the segmentation position may be the position of the first character, or the position of the last punctuation mark in the non-ending characters. Alternatively, the segmentation position may be the position of the first punctuation mark in the non-ending characters.
[0079] For example, according to the determined segmentation position, the first text segment can be segmented into two segments. Alternatively, the first text segment can be segmented into one segment and the other segment can be an empty text segment. Then, based on the two segmented text segments, the second text segment to be broadcast at the current moment and the third text segment to be broadcast at the next moment are determined.
[0080] For example, a certain text segment obtained by segmentation can be spliced with the text segment of the current moment's pending broadcast determined at the previous moment to obtain a third text segment of the next moment's pending broadcast.
[0081] Alternatively, one of the two text segments obtained by segmentation is used as the second text segment, and the other is used as the third text segment.
[0082] According to the above implementation, the segmentation position of the first text segment is determined according to the ending information of the first text segment, and then the first text segment is segmented according to the segmentation position to obtain the second text segment to be broadcast at the current moment and the third text segment to be broadcast at the next moment. In this way, the pause position of the first text segment can be accurately located by using the ending information, and the pause position is used as the segmentation position, which can improve the smoothness of the voice broadcast.
[0083] In one embodiment, determining the segmentation position in the first text segment based on the ending information of the first text segment includes: when the ending information of the first text segment does not include the first character and the dialogue end mark, determining the segmentation position based on non-ending characters in the first text segment.
[0084] Exemplarily, the ending information of the first text segment does not include the first character, which means that the first text segment is not a complete sentence, and the ending character is not a pause in the text segment. The ending information of the first text segment does not include a dialogue end mark, indicating that the first text segment is not the last text segment in response to the question voice. At this time, the first text segment cannot be directly broadcasted, and the first text segment needs to be segmented. Furthermore, the segmentation position can be determined based on the non-ending characters in the first text segment. Subsequently, the segmentation position can be used to segment the text segment.
[0085] Exemplarily, the first character may be any character or symbol designated to have a pause meaning, such as a punctuation mark or a special symbol.
[0086] For example, punctuation marks may include commas, semicolons, periods, colons, exclamation points, question marks, semicolons, etc.
[0087] For example, special symbols may include a line break character “\n” or a dollar sign “¥”, “#” or other characters.
[0088] Exemplarily, the non-end characters may include text characters, punctuation marks, special symbols, etc. The text characters may be Chinese text characters or English text characters, etc.
[0089] Exemplarily, if the non-end characters include a first character, such as a punctuation mark or a special symbol, the segmentation position is determined based on the position of the first character in the first text segment. For example, the position of the last punctuation mark in the non-end characters is used as the segmentation position. Alternatively, the position of the first punctuation mark in the non-end characters is used as the segmentation position.
[0090] For example, if the non-end characters do not include the first character, it means that the first text segment cannot be segmented from any character in the middle of it, and the entire text segment is used for the next pending report. If the text segment of the pending report determined at the last moment is a non-empty text segment, the first text segment needs to be concatenated with the text segment of the pending report determined at the last moment to obtain the third text segment of the next pending report.
[0091] According to the above-mentioned implementation, when the ending information of the first text segment does not include the first character and the dialogue end mark, the pause position in the text segment can be accurately determined based on the non-ending characters in the first text segment, thereby obtaining an accurate segmentation position so that the pauses in the segmented text segment are reasonable.
[0092] In one embodiment, determining the segmentation position based on the non-end characters in the first text segment may include: determining the first segmentation position based on the position of the first character in the first text segment when the non-end characters in the first text segment include the first character.
[0093] In one embodiment, the above-mentioned segmentation of the first text segment based on the segmentation position to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment includes: when the segmentation position is the first segmentation position, based on the first segmentation position, the first text segment is segmented into two segments to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment; wherein, in the first text segment, the second text segment is located before the third text segment.
[0094] Continuing with the previous example, if the first text segment does not end with the first character, or the first text segment does not carry a dialog end marker, then continue to determine whether the non-end characters of the first text segment include the first character.
[0095] Continuing with the above example, if the non-ending characters of the first text segment include the first character, the position of the last first character in the first text segment can be used as the segmentation position or segmentation boundary, that is, the first segmentation position mentioned above. In this case, the first text segment can be segmented into two segments to obtain the second text segment and the third text segment. Both the second text segment and the third text segment are non-empty text segments.
[0096] Continuing with the above example, if the first text segment does not include the first character, the first text segment is divided into one segment, that is, the first text segment is used for the next pending broadcast. The first text segment is spliced with the fourth text segment of the current pending broadcast determined at the previous moment to obtain the third text segment. Then the second text segment is an empty text segment. At this time, step S220 and step S230 are no longer executed at the current moment, and the first text segment received at the next moment can be waited.
[0097] It can be understood that the first segmentation position can be any middle position in the first text segment except the first and last characters.
[0098] For example, when the ending symbol of the first text segment is not a punctuation mark or a special symbol, and the text segment does not include a dialog end mark, if there are punctuation marks in the text segment, the last punctuation mark is used as the segmentation position to segment the text segment into two segments, the first segment being the second text segment broadcast at the current moment, and the second segment being the third text segment to be broadcast at the next moment. Of course, in other examples, any punctuation mark in the text segment can also be used as the segmentation position to segment the text segment into two segments.
[0099] For example, the first text segment is "is a famous basketball player, and also in the basketball world". Since the last character is neither a punctuation mark nor a special symbol, and the text segment does not carry a dialogue end mark, the end of the sentence of the first text segment is not a reasonable pause point, and the first text segment needs to be segmented. The non-ending characters of the first text segment include the punctuation mark ",". The first text segment is segmented with "," as the segmentation position, and the first text segment is segmented into the second text segment "is a famous basketball player," and the third text segment "is also in the basketball world". Among them, the text segments that need to be broadcast at the current moment include the second text segment "is a famous basketball player," and the text segments to be broadcast at the next moment include the third text segment "is also in the basketball world".
[0100] For example, in combination with the above step S220, if the fourth text segment to be announced at the current moment obtained by segmentation at the previous moment is "Xiao Ming", which is a non-empty text segment, then "Xiao Ming" needs to be concatenated with the second text segment "is a famous basketball player," to obtain the target text segment "Xiao Ming is a famous basketball player." At this time, the target text segment "Xiao Ming is a famous basketball player," is announced in voice accordingly. It can be understood that during voice announcement, punctuation marks at the end of the sentence are not announced.
[0101] It should be noted that the text segment "also the basketball world" is not discarded, and can be applied to the next moment to execute steps S210 to S230, and then be spliced with other text segments and then broadcast.
[0102] According to the above implementation, if the text segment does not end with a character with a pause meaning and does not carry a dialogue end mark, it means that if the voice corresponding to the text segment is directly broadcast, there will be a pause in the broadcasting between the voice corresponding to the next text segment, but the pause is not a reasonable pause. Therefore, it is necessary to divide the text segment into two segments, one of which is used for broadcasting at the current moment, and the other segment is used to splice and broadcast with the next text segment. In this way, the pause after the current moment broadcast is reasonable, and the smoothness of the broadcast reply voice is improved.
[0103] In one embodiment, determining the segmentation position based on the non-end characters in the first text segment also includes: when the first character is not included in the non-end characters of the first text segment, determining the second segmentation position based on the position of the first character in the non-end characters of the first text segment.
[0104] In one embodiment, based on the segmentation position, the first text segment is segmented to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment, including: when the segmentation position is the second segmentation position, the second text segment that needs to be broadcast at the current moment is set to be an empty text segment, and the first text segment is spliced to the end of the fourth text segment to be broadcast at the current moment obtained by segmentation at the previous moment, to obtain the third text segment to be broadcast at the next moment.
[0105] It can be understood that the second segmentation position can be the position of the first character in the first text segment, for example, the position before the first character.
[0106] It can be understood that when the first character is not included in the non-end characters of the first text segment, the second text segment to be broadcast at the current moment is set as an empty text segment, and the first text segment is spliced to the end of the fourth text segment to be broadcast at the current moment obtained by segmentation at the previous moment, so as to obtain the third text segment to be broadcast at the next moment.
[0107] It can be understood that, since the second text segment is an empty text segment at this time, and the condition for executing step S220 is that the second text segment is a non-empty text segment, step S220 is not executed further.
[0108] For example, if the first text segment is "also the most successful player in basketball history", since its last character is neither a punctuation mark nor a special symbol, and the text segment does not carry a dialogue end mark, and the text segment does not include any punctuation marks and special symbols, then at this time, the first text segment cannot be split from any position in the middle, nor can it be used as the second text segment that needs to be broadcast at the current moment. It can be used as the third text segment to be broadcast at the next moment.
[0109] Continuing with the previous example, if the fourth text segment of the pending broadcast at the current moment obtained by segmentation at the previous moment is a non-empty text segment, for example, "Xiao Ming", it is also necessary to splice the first text segment "is also the most successful player in the history of basketball" after "Xiao Ming" to obtain the final third text segment "Xiao Ming is also the most successful player in the history of basketball".
[0110] Continuing with the above example, if the fourth text segment of the pending report at the current moment obtained by segmentation at the previous moment is an empty text segment, the first text segment is directly used as the third text segment of the pending report at the next moment.
[0111] Furthermore, if the text segment cache queue is a non-empty text segment, step S240 is not executed, and the process returns to step S210 to enter the next execution of the process from step S210 to step S240.
[0112] According to the above embodiment, if the non-end characters of the first text segment do not include the first character with a pause meaning, such as a punctuation mark, the first text segment is spliced to the fourth text segment of the pending broadcast at the previous moment to serve as the third text segment of the pending broadcast at the next moment. In this way, the coherence between the text segment for the pending broadcast at the next moment obtained by segmenting from the first text segment and the fourth text segment of the pending broadcast at the current moment obtained by segmenting at the previous moment can be ensured, thereby improving the smoothness of the broadcast reply voice.
[0113] In one embodiment, the above method may also include: when the second text segment is an empty text segment, controlling the timer to start timing; when the next first text segment that responds to the question voice is not obtained within a preset timing period, determining the target text segment that needs to be broadcast at the current moment based on the third text segment.
[0114] It is understandable that if a cache queue is used to store the obtained first text segment, when the cache queue is an empty queue within a preset timing period, the target text segment that needs to be broadcast at the current moment is determined based on the third text segment.
[0115] It can be understood that the third text segment is taken as the target text segment. Then, the process continues to execute step S230.
[0116] It can be understood that when the second text segment intercepted from the first text segment and used for broadcasting at the current moment is an empty text segment, the control timer starts counting from zero.
[0117] For example, if a time length is set to 1 minute or 30 seconds, and the text segment cache queue is still empty after the timeout, the third text segment to be broadcast at the next moment can be used as the target text segment to be broadcast at the current moment.
[0118] Continuing with the previous example, for the third text segment "Xiao Ming is also the most successful player in the history of basketball", if there is no text segment in the text segment cache queue, and there is still no text segment after the waiting time of the start timer expires, then even if the third text segment is not the last text segment in response to the question voice, the text segment will continue to be broadcast to avoid the user waiting for too long.
[0119] According to the above implementation, the timing starts from when the second text segment is determined to be an empty text segment. If the text segment cache queue is still an empty text segment after the timing time expires, the third text segment to be broadcasted at the next time is directly used as the target text segment for broadcasting. Thus, the user is prevented from waiting too long for the voice reply.
[0120] In one embodiment, based on the end information of the first text segment, determining the segmentation position in the first text segment includes: when the end information of the first text segment includes a first character and / or a dialogue end marker, determining a third segmentation position based on the position of the end character of the first text segment.
[0121] In one embodiment, based on the segmentation position, the first text segment is segmented to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment, including: when the segmentation position is the third segmentation position, based on the first text segment, determining the second text segment that needs to be broadcast at the current moment, and setting the third text segment to be broadcast at the next moment to be an empty text segment.
[0122] It can be understood that the third segmentation position is the position of the ending character of the first text segment, for example, the end of the ending character.
[0123] It can be understood that when the ending information of the first text segment includes the first character information and / or the dialog end mark, the first text segment is divided into one segment and the other segment is an empty text segment. At this time, based on the first text segment, the second text segment to be broadcasted at the current moment is determined, and the third text segment to be broadcasted at the next moment is set as an empty text segment.
[0124] For example, if the first text segment is "is a famous basketball player," since the text segment ends with a punctuation mark, the first text segment can be used as the second text segment that needs to be broadcast at the current moment.
[0125] For example, if the first text segment is "This book is 5¥", since the text segment ends with the special symbol "¥", the first text segment can be used as the second text segment that needs to be broadcast at the current moment.
[0126] For example, if the first text segment "This book is 5 blocks" carries the dialogue end mark "1", the first text segment is used as the second text segment that needs to be broadcast at the current moment.
[0127] Then, after the second text segment is determined, since the second text segment is a non-empty text segment, the above steps S220 and S230 are continued to be executed.
[0128] According to the above implementation, when the ending symbol of the first text segment is a character with a pause meaning, such as a punctuation mark or a special symbol, or when the text segment carries a dialog end mark, the first text segment is the second text segment broadcast at the current moment, and the third text segment to be broadcast at the next moment is an empty text segment. In this way, the text segment with complete ending information can be broadcast, and there is no need to split a part of the text segment to enter the splicing process at the next moment, which can improve the smoothness of the broadcast reply voice.
[0129] In one implementation, the first character may include any one of punctuation marks and special symbols.
[0130] For example, punctuation marks may include commas, semicolons, periods, colons, exclamation points, question marks, semicolons, etc.
[0131] For example, special symbols may include line break characters "\n" or dollar signs "¥", "#", and other characters. Special symbols may be classified into mathematical symbols, unit symbols, and tabs, and the like.
[0132] According to the above implementation, punctuation marks and special symbols in the ending information, as well as punctuation marks and special symbols in non-ending characters, are used to determine whether the text segment needs to be segmented to obtain a part for broadcast at the next moment, which can improve the smoothness of the broadcast reply voice.
[0133] Figure 3 The figure is a flow chart of a voice reply method according to an embodiment of the present disclosure.
[0134] like Figure 3 As shown, the voice reply method includes:
[0135] S310, determining a corresponding prompt word keyword based on the question text corresponding to the question voice;
[0136] S320, inputting the prompt word keyword into at least one large language model, wherein the large language model is used to generate a reply text segment for the question voice based on the prompt word keyword;
[0137] S330, when a reply text segment is generated by the large language model, the reply text segment is added to a text segment cache queue;
[0138] S340, determining a reply voice for the question voice based on the text segment cache queue.
[0139] It is understandable that the above method can be applied to the client or the server. The client and the server can also be combined to perform the above method. For example, step S310 is performed in the client, and then the client sends the prompt word keyword to the server, so that the server performs step S320. The server returns the reply text segment to the client, and the client performs steps S330 and S340.
[0140] It is understandable that the execution order of the above steps S310 to 340 is not limited. Step S330 and step S340 can be executed in parallel. Step S330 can be executed multiple times. Step S340 can also be executed multiple times.
[0141] It can be understood that the question speech is subjected to speech recognition to obtain the question text, and then the corresponding prompt word keyword is determined based on the question text. For example, the question speech can be subjected to speech recognition using ASR (Automatic Speech Recognition) technology to obtain the question text. For example, the question text can be processed using a language model to obtain the prompt word keyword.
[0142] It is understandable that the large language model may include one or more. The structures or training methods of different large language models may be the same or different. The network parameters of different large language models are generally different. The network parameter scales of different large language models may be the same or different. The total duration of text sequences generated by different large language models for the same question voice is generally different. Generally speaking, the total duration of the text sequence generated by a large language model with a smaller network parameter scale is faster, but the accuracy of the generated text sequence is lower. Relatively speaking, the total duration of the text sequence generated by a large language model with a larger network parameter scale is slower, and the accuracy of the generated text sequence is higher.
[0143] It can be understood that the large language model generates corresponding reply text segments for the question speech segment by segment, which can form a sequence. In this way, each time a reply text segment is generated or obtained, the reply text segment is added to the text segment cache queue.
[0144] It can be understood that if there is only one large language model, after obtaining the reply text segment generated by the model, the reply text segment is arranged at the end of the text segment cache queue.
[0145] It is understandable that if there are multiple large language models, the adding position can be determined according to the source of the reply text segment, and then the reply text segment is added to the text segment cache queue according to the adding position. Of course, the adding position of the reply text segment can also be determined in combination with the source and arrangement order of each text segment in the text segment cache queue.
[0146] Exemplarily, in the above step S340, when the text segment cache queue has stored all text segments for replying to the question voice, the text segment cache queue is processed to obtain the reply voice.
[0147] Exemplarily, in the above step S340, when the text segment cache queue stores text segments, the reply voice segments for the question voice are determined one by one for the text segment cache queue, so as to broadcast the reply voice segments one by one. In this way, part of the reply voice can be broadcasted in advance, and it is not necessary to broadcast the complete reply voice after obtaining the last text segment for replying to the question voice. In this way, the user experience can be improved.
[0148] Exemplarily, when a reply text segment is obtained, it is necessary to determine whether the same text segment has been stored in the text segment cache queue. If so, the reply text segment is not added to the queue and is discarded.
[0149] According to the above implementation, one or more large language models are used to generate reply text segments for question voices, and a queue is used to cache the reply text segments generated by one or more large language models. In this way, the reply text segments generated first can be given priority to enter the queue for broadcasting, and there is no need to use different queues according to different large language models to broadcast one by one, thereby reducing the time users wait for reply voices.
[0150] In one embodiment, the above-mentioned determination of the reply voice to the question voice based on the text segment cache queue may include: extracting the first-ranked text segment from the text segment cache queue to obtain the first text segment, and deleting the first text segment from the text segment cache queue; according to the voice reply method for processing the first text segment according to any of the above-mentioned embodiments, processing the first text segment to obtain the current reply voice segment to the question voice.
[0151] For example, Figure 4 As shown, on the client side, the voice input by the user is received, and the question voice is recognized using ASR technology to obtain the corresponding question text. Based on the question text, the corresponding prompt keyword is determined. Then, the prompt keyword is uploaded to the cloud, and the cloud uses a large language model (LLM) to process the prompt keyword and return the reply text segments (generated content) to the client segment by segment. Each time the client receives a reply text segment, it adds the reply text segment to the text segment cache queue, such as the end, or the end of the last text segment from the same source in the queue.
[0152] In some technologies, the client directly passes the received text segment to the TTS engine, which converts the text into a speech signal. The TTS system converts the text into an audible speech waveform and broadcasts it through an audio device such as a speaker or headphones, so that the user can hear the speech content generated by the system.
[0153] However, the TTS broadcast is not smooth, there are pauses, and the experience is not good.
[0154] According to the above implementation, before the text segment is passed to the TTS engine, the method for processing the first text segment in any of the above embodiments is used to process the first text segment, and the target text segment is obtained after the above processing is performed on the first text segment, and then the target text segment is passed to the TTS engine. In this way, the pauses of the voice content broadcast by the TTS engine are reasonable, smooth and natural, which can improve the user experience.
[0155] In one embodiment, the type of reply text segment includes a main text segment, and inputting a prompt word keyword into a large language model includes: providing the prompt word keyword to a first large language model, wherein the first large language model is used to generate a main text segment for replying to the question voice based on the prompt word keyword.
[0156] In this example, only the first language model is used to generate a reply text segment as the main text segment, which can improve the reply accuracy of the reply speech to the question speech.
[0157] In one embodiment, the type of reply text segment also includes a summary text segment, and the method further includes: providing the prompt word keyword to the second largest language model, wherein the second largest language model is used to generate a summary text segment for replying to the question voice based on the prompt word keyword.
[0158] Understandably, two large language models are used to generate the main text segment and the summary text segment respectively. Since the total time of generating the summary text sequence is generally faster than the total time of generating the main text sequence, the reply text segment in the summary text sequence can be broadcasted in advance before the main text sequence is completely generated.
[0159] Exemplarily, the network parameter scale of the first largest language model is greater than the network parameter scale of the second largest language model.
[0160] Exemplarily, the total duration of the main text sequence generated by the first language model for the question speech is greater than the total duration of the summary text sequence generated by the second language model for the question speech.
[0161] Exemplarily, the speed at which the first large language model generates the first main text segment is greater than the speed at which the second large language model generates the first summary text segment.
[0162] According to the above implementation, two large language models are used to generate summary and text respectively. Since the generation speeds of the two are different, the summary can be generated before the text is broadcast, and the reply voice can be broadcast to the user in advance to improve the user experience.
[0163] In one embodiment, adding a reply text segment to a text segment cache queue includes: determining an arrangement position of the reply text segment based on the type of the reply text segment, and the types and arrangement order of each text segment in the text segment cache queue; and arranging the reply text segment in the text segment cache queue based on the arrangement position of the reply text segment.
[0164] It is understandable that the type of the reply text segment can be a summary text segment or a body text segment. Of course, the type can also be understood as the source of the reply text segment, for example, it comes from the first language model or it comes from the second language model.
[0165] Exemplarily, determining the arrangement position of the reply text segment based on the type of the reply text segment, and the types and arrangement order of each text segment in the text segment cache queue may include: based on the type of the reply text segment, determining text segments of the same type in the text segment cache queue, and then determining the arrangement position of the reply text segment based on the arrangement positions of the text segments of the same type.
[0166] Exemplarily, determining the arrangement position of the reply text segment based on the arrangement positions of text segments of the same type may include: determining the arrangement position of the reply text segment based on the arrangement position of the last text segment of the same type as the reply text segment in the text segment cache queue. For example, the end of the arrangement position of the last text segment of the same type as the reply text segment in the text segment cache queue is used as the arrangement position of the reply text segment.
[0167] Exemplarily, after the arrangement position of the reply text segment is determined, the reply text segment is added to a corresponding position in the text segment cache queue according to the arrangement position of the reply text segment.
[0168] According to the above implementation, based on the type of the reply text segment, and the type and arrangement order of each text segment in the text segment cache queue, the arrangement position of the reply text segment is determined. Based on the arrangement position of the reply text segment, the reply text segment is arranged in the text segment cache queue. In this way, the reply text segments from different sources can be arranged after the text sequences from the same source in the text segment cache queue. Therefore, when the voice broadcast is subsequently performed according to the text segment cache queue, the occurrence of disordered voice broadcast can be avoided.
[0169] In one implementation, determining the arrangement position of the reply text segment based on the type of the reply text segment and the type and arrangement order of each text segment in the text segment cache queue includes one of the following:
[0170] When the reply text segment is a summary text segment and the text segment cache queue includes at least one summary text segment, determining an arrangement position of the reply text segment based on an end position of the last summary text segment in the text segment cache queue;
[0171] In the case where the reply text segment is a main text segment and the text segment cache queue includes at least one main text segment, determining an arrangement position of the reply text segment based on an end position of the last main text segment in the text segment cache queue;
[0172] When the reply text segment is a main text segment, and the text segment cache queue does not include the main text segment but includes at least one summary text segment, the arrangement position of the reply text segment is determined based on the end position of the last summary text segment in the text segment cache queue.
[0173] It can be understood that, when the reply text segment is a summary text segment and the text segment cache queue includes at least one summary text segment, the arrangement position of the reply text segment is the end position of the last summary text segment in the text segment cache queue.
[0174] It can be understood that, when the reply text segment is a main text segment and the text segment cache queue includes at least one main text segment, the arrangement position of the reply text segment is the end position of the last main text segment in the text segment cache queue.
[0175] It can be understood that when the reply text segment is a main text segment, and the text segment cache queue does not include a main text segment but includes at least one summary text segment, the reply text segment is arranged at the end position of the last summary text segment in the text segment cache queue.
[0176] Exemplarily, when the reply text segment is a summary text segment and the text segment cache queue is an empty queue, the reply text segment is directly added to the text segment cache queue, that is, the reply text segment is arranged at the first position in the text segment cache queue.
[0177] Exemplarily, when the reply text segment is a main text segment, and the text segment cache queue is an empty queue, and the main text segment has not been extracted from the text segment cache queue, the reply text segment is not added to the queue temporarily until there is a summary text segment in the text segment cache queue, and then the reply text segment is added to the queue.
[0178] Continuing with the above example, the reply text segment can be temporarily cached in the main text standby queue. If the main text standby queue is an empty queue, the reply text segment is directly added to the main text standby queue; if the main text standby queue includes one or more main text segments, the reply text segment is added to the end of the main text standby queue. When the number of summary text segments in the text segment cache queue is greater than the preset data, the main text standby queue is merged into the text segment cache queue and arranged at the end of the text segment cache queue.
[0179] Exemplarily, when the reply text segment is a main text segment, and the text segment cache queue is an empty queue, and the main text segment has been extracted from the text segment cache queue, the reply text segment is added to the text segment cache queue, that is, the arrangement position of the reply text segment is the first in the text segment cache queue.
[0180] According to the above implementation, the sequence formed by the summary text segments can be arranged before the sequence of the main text reply text segments, so that when the summary is not fully broadcasted but the main text reply text segment has been generated, it is ensured that the main text is broadcasted only after the last summary text segment is broadcasted. Thus, the smoothness of the voice reply broadcast can be guaranteed.
[0181] Figure 5 The figure is a flow chart of a voice reply method according to another embodiment of the present invention. Figure 6 The present invention is a flowchart of text segment segmentation and splicing according to an embodiment of the present invention.
[0182] like Figure 5 As shown, an example of a voice reply method is introduced below, as follows:
[0183] Step S501, the user inputs voice through the microphone, the voice signal is converted into a digital signal and transmitted to the voice recognition engine. The voice recognition engine uses technologies such as acoustic model, language model and pronunciation dictionary to convert the voice signal into corresponding text. The acoustic model is responsible for matching the acoustic features with the phonemes (the smallest pronunciation unit) of the voice, determining the phonemes corresponding to each time period, and obtaining the phoneme sequence. The language model scores the phoneme sequence according to the known language structure and grammatical rules to improve the recognition accuracy. The pronunciation dictionary is used to map phonemes to words to determine the final recognition result.
[0184] Step S502, the recognized text needs to be understood in natural language, so the text needs to be converted into a structured representation that the computer can understand. The natural language understanding process includes tasks such as semantic analysis, intent recognition, and entity recognition to understand the user's intentions and needs. The present disclosure records the user's historical voice interaction behavior in chronological order of voice interaction, and then feeds back the user's historical voice interaction behavior and the voice text corresponding to the currently received user voice to the cloud. The cloud-based call model generates a rewritten prompt keyword based on the historical voice interaction behavior and the voice text corresponding to the currently received user voice.
[0185] In step S503, the content of the prompt keyword is input into the pre-trained large model for content generation. The large model can be a neural network model based on deep learning, such as GPT (Generative Pre-trained Transformer). The model predicts the next word or character by autoregressive generation based on the input prompt keyword and the word or character generated last time, and gradually generates a continuous text segment sequence. The generated text segment sequence may need to go through multiple rounds of iteration and adjustment to meet the needs and context of the user. Considering that the process of generating content (text segment sequence) of a large language model is slow, for this reason, before generating the main text reply content, the present disclosure first provides the prompt keyword information to a medium-sized language model to request the generation of summary information of the reply content. The cloud returns the summary information to the client first, and the client can quickly see the upper screen information of the reply content and hear the TTS broadcast voice. At the same time, for some scenarios where the summary information may not be obtained for some questions, we adopt a bottom-up strategy to fill in the summary content to ensure that users can quickly perceive the generation of content. Specific strategy: If no summary information of the reply content is received within the preset time, a text message will be broadcast to the user, such as "I haven't found a suitable answer to this question yet, try to explain it in more detail."
[0186] Step S504: Since the generated reply content is a stream content, it is composed of multiple text segments forming a text segment sequence. For example, for the voice question "Introduce Yao Ming", the summary text returned by the cloud is as follows:
[0187] Text 1: "Xiao Ming";
[0188] Text 2: "Is a famous basketball player and also in the basketball world";
[0189] Text 3: "One of the most successful players in history\n".
[0190] When the TTS engine is called for normal broadcasting, text 1 is broadcasted first, and then the content of text 2 is broadcasted. This will cause a pause after broadcasting text 1 "Xiao Ming", and the broadcast will feel disconnected, resulting in poor user experience. Therefore, before TTS broadcasts, the embodiment of the present disclosure processes the above text and then submits it to TTS for broadcasting.
[0191] like Figure 6 As shown, before TTS broadcast, the process of processing the text segment may include:
[0192] Step S601, initialize a buffer queue for storing the segmented text to be broadcast. The length of the queue can be adjusted according to system requirements, and is usually set to accommodate a certain number of segmented texts. The text segment returned by cloud streaming is added to the buffer queue, and the buffer queue records the conversation ID to which the current text segment belongs to determine whether the text segment is the last text segment returned by the current conversation ID.
[0193] Step S602, start the TTS engine, select the corresponding speaker, and set the relevant parameters of its TTS engine to complete the initialization of the voice TTS engine. Then, extract the first text segment from the buffer queue, and determine whether the text segment is a complete sentence. For example, if the text segment ends with punctuation (comma, period, colon, exclamation mark, question mark, semicolon, etc.), call the TTS engine to broadcast the text segment.
[0194] Step S603, if the text segment does not end with a punctuation mark, determine whether the text segment ends with a special character. The special character can be a line break "\n", or a dollar sign "¥", "#" or other characters. If so, call the TTS engine to broadcast the text segment.
[0195] Step S604: if the text segment ends with a special character, determine whether the text segment is the last text segment of the current conversation ID. If the text segment is the last text segment of the current conversation, the TTS engine needs to be called to broadcast the text segment regardless of whether it ends with a punctuation mark or a special character.
[0196] Step S605, if the text segment is not the last text segment of the current conversation ID, it is considered that this text segment is an incomplete text segment. Special processing is required for this text segment. For example, in the text segment, extract the last text segment ending with non-punctuation marks. For example: as the text 2 returned above "is a famous basketball player, also in the basketball world", extract the last text segment ending with non-punctuation marks as the text "also in the basketball world". At the same time, for the remaining text segment "is a famous basketball player," call the TTS engine to broadcast the text segment.
[0197] It should be noted that the design idea of segmenting text segments is to determine the Chinese and English punctuation marks of the text segment to be processed, and obtain the position information of the last Chinese and English punctuation mark in the text segment. Then, based on the position corresponding to the position information, the text segment ending with punctuation marks and the text segment ending without punctuation marks are segmented.
[0198] Furthermore, the text segment "also in the basketball world" without punctuation at the end is concatenated with the next sentence of text obtained from the cache queue after the current TTS broadcast ends, and the concatenated content is "also one of the most successful players in the history of the basketball world". For the concatenated content, the above steps 602 to 605 are repeatedly executed.
[0199] Step S606, if the above steps are executed, the remaining unbroadcasted content text is not the last text segment of the current conversation ID, and the TTS content segment to be broadcasted in the next sentence has not been returned or has failed to return, then the timer's timeout waiting mechanism is started. Among them, the waiting specific time range can be 500ms or 1s. The specific time setting can be adjusted according to the time item. The timeout waiting mechanism is to continue to broadcast the remaining unbroadcasted content text when no content is returned or the subsequent content generation fails, thereby ensuring that the displayed content is consistent with the broadcast content.
[0200] The disclosed embodiment uses a large language model and a medium language model to generate the body and summary of the reply text respectively, and can quickly provide voice replies to users. On the other hand, before streaming broadcast, the text segments are segmented and spliced according to the ending information of the text segments before voice broadcast, which can improve the fluency of voice broadcast and further enhance the user experience.
[0201] Figure 7 It is a structural block diagram of a voice reply device according to an embodiment of the present disclosure.
[0202] like Figure 7 As shown, a voice reply device comprises:
[0203] The text segmentation module 710 is used to segment the first text segment based on the ending information of the first text segment when the first text segment is obtained to obtain the second text segment to be broadcasted at the current moment and the third text segment to be broadcasted at the next moment;
[0204] The text segment concatenation module 720 is used to, when the second text segment is a non-empty text segment, concatenate the second text segment to the end of the fourth text segment to be broadcasted at the current moment obtained by segmentation at the previous moment, so as to obtain a target text segment to be broadcasted at the current moment;
[0205] The first speech determination module 730 is used to determine a current reply speech segment for the question speech based on the target text segment.
[0206] Figure 8 It is a structural block diagram of a voice reply device according to another embodiment of the present disclosure.
[0207] like Figure 7 and Figure 8 As shown, Figure 8 The text segment segmentation module 810, the text segment splicing module 820 and the first voice determination module 830 in Figure 7 The structures and functions of the text segment segmentation module 710, the text segment splicing module 720 and the first voice determination module 730 are the same and will not be described in detail here.
[0208] In one embodiment, if Figure 8 As shown, the text segment segmentation module 810 includes:
[0209] A segmentation position determining unit 811, configured to determine a segmentation position in the first text segment based on the end information of the first text segment;
[0210] The segmentation unit 812 is used to segment the first text segment based on the segmentation position to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment.
[0211] In one embodiment, if Figure 8 As shown, the segmentation position determining unit 811 is specifically used for:
[0212] When the end information of the first text segment does not include the first character and the dialog end mark, the segmentation position is determined based on non-end characters in the first text segment.
[0213] In one embodiment, determining the segmentation position based on non-end characters in the first text segment includes: when the first character is included in the non-end characters of the first text segment, determining the first segmentation position based on the position of the first character in the first text segment.
[0214] In one embodiment, the segmentation unit 812 is specifically used to: when the segmentation position is the first segmentation position, based on the first segmentation position, segment the first text segment into two segments to obtain the second text segment that needs to be broadcast at the current moment and the third text segment to be broadcast at the next moment; wherein the second text segment is located before the third text segment in the first text segment.
[0215] In one embodiment, determining the segmentation position based on the non-end characters in the first text segment includes: when the first character is not included in the non-end characters of the first text segment, determining the second segmentation position based on the position of the first character in the non-end characters of the first text segment.
[0216] In one embodiment, the segmentation unit 812 is specifically used to: when the segmentation position is the second segmentation position, set the second text segment that needs to be broadcast at the current moment to be an empty text segment, and splice the first text segment to the end of the fourth text segment to be broadcast at the current moment obtained by segmentation at the previous moment, to obtain the third text segment to be broadcast at the next moment.
[0217] In one embodiment, the above device further comprises:
[0218] A timing module 840, configured to control a timer to start timing when the second text segment is an empty text segment;
[0219] The target text segment determination module 850 is used to determine the target text segment that needs to be broadcast at the current moment based on the third text segment when the next first text segment to respond to the question voice is not obtained within a preset timing period.
[0220] In one embodiment, the segmentation position determination unit 811 is specifically used to determine the third segmentation position based on the position of the end character of the first text segment when the end information of the first text segment includes the first character and / or the dialog end mark.
[0221] In one implementation, the segmentation unit 812 is specifically configured to:
[0222] When the segmentation position is the third segmentation position, based on the first text segment, the second text segment to be broadcast at the current moment is determined, and the third text segment to be broadcast at the next moment is set as an empty text segment.
[0223] In one implementation, the first character includes any one of punctuation marks and special symbols.
[0224] Fig. 9 It is a structural block diagram of a device for voice reply according to another embodiment of the present disclosure.
[0225] like Fig. 9 As shown, the voice reply device may include:
[0226] A prompt word determination module 910, for determining a corresponding prompt word keyword based on the question text corresponding to the question voice;
[0227] A model processing module 920, configured to input the prompt word keyword into at least one large language model, wherein the large language model is configured to generate a reply text segment for the question voice based on the prompt word keyword;
[0228] A text segment adding module 930, configured to add the reply text segment to the text segment cache queue when the reply text segment is generated by the large language model;
[0229] The second voice determination module 940 is used to determine a reply voice for the question voice based on the text segment cache queue.
[0230] Fig.10 It is a structural block diagram of a device for voice reply according to another embodiment of the present disclosure.
[0231] like Fig. 9 and Fig.10 As shown, Fig.10 The prompt word determination module 1010, the model processing module 1020, the text segment adding module 1030 and the second speech determination module 940 are connected with Fig. 9 The prompt word determination module 910, the model processing module 920, the text segment adding module 930 and the second speech determination module 940 have the same structure and function and are not described in detail here.
[0232] In one implementation, the second speech determination module 1040 includes:
[0233] A text segment extracting unit 1041 is used to extract the first-ranked text segment from the text segment cache queue to obtain a first text segment, and delete the first text segment from the text segment cache queue;
[0234] The text segment processing unit 1042 is used to process the first text segment based on the voice reply method for processing the first text segment in any of the above embodiments to obtain a current reply voice segment for the question voice.
[0235] In one embodiment, the type of the reply text segment includes a body text segment. Fig.10 As shown, the model processing module 1020 includes:
[0236] The first model processing unit 1021 is used to provide the prompt word keyword to a first large language model, wherein the first large language model is used to generate a body text segment for replying to the question voice based on the prompt word keyword.
[0237] In one embodiment, the type of reply text segment also includes a summary text segment. Fig.10 As shown, the model processing module 1020 also includes:
[0238] The second model processing unit 1022 is used to provide the prompt word keyword to the second largest language model, wherein the second largest language model is used to generate a summary text segment for responding to the question voice based on the prompt word keyword.
[0239] In one embodiment, if Fig.10 As shown, the text segment adding module 1030 includes:
[0240] An arrangement position determining unit 1031, configured to determine an arrangement position of the reply text segment based on the type of the reply text segment and the type and arrangement order of each text segment in the text segment cache queue;
[0241] The text segment arranging unit 1032 is used to arrange the reply text segment in the text segment cache queue based on the arrangement position of the reply text segment.
[0242] In one implementation, the arrangement position determining unit 1031 is specifically used for one of the following:
[0243] In a case where the reply text segment is a summary text segment and the text segment cache queue includes at least one summary text segment, determining an arrangement position of the reply text segment based on an end position of a last summary text segment in the text segment cache queue;
[0244] In a case where the reply text segment is a main text segment and the text segment cache queue includes at least one main text segment, determining an arrangement position of the reply text segment based on an end position of the last main text segment in the text segment cache queue;
[0245] When the reply text segment is a main text segment, and the text segment cache queue does not include a main text segment but includes at least one summary text segment, the arrangement position of the reply text segment is determined based on the end position of the last summary text segment in the text segment cache queue.
[0246] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.
[0247] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0248] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium and a computer program product. The electronic device may be a server, and the server may also include any power supply control device in the embodiment of the present disclosure.
[0249] Fig.11 A schematic block diagram of an example electronic device 1100 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0250] like Fig.11 As shown, the electronic device 1100 includes a computing unit 1101, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1102 or a computer program loaded from a storage unit 1108 into a random access memory (RAM) 1103. In the RAM 1103, various programs and data required for the operation of the electronic device 1100 can also be stored. The computing unit 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0251] Multiple components in the electronic device 1100 are connected to the I / O interface 1105, including: an input unit 1106, such as a keyboard, a mouse, etc.; an output unit 1107, such as various types of displays, speakers, etc.; a storage unit 1108, such as a disk, an optical disk, etc.; and a communication unit 1109, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1109 allows the electronic device 1100 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0252] The computing unit 1101 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1101 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1101 performs the various methods and processes described above, such as a voice reply method. For example, in some embodiments, a voice reply method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 11011. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 1100 via ROM 1102 and / or communication unit 1109. When the computer program is loaded into RAM 1103 and executed by the computing unit 1101, one or more steps in a voice reply method described above may be performed. Alternatively, in other embodiments, the computing unit 1101 may be configured to execute a voice reply method in any other appropriate manner (eg, by means of firmware).
[0253] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0254] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0255] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0256] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0257] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0258] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0259] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0260] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A voice reply method, comprising: When a first text segment in response to the voice question is obtained, the first text segment is segmented based on the ending information of the first text segment to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment; If the second text segment is a non-empty text segment, the second text segment is concatenated to the end of the fourth text segment to be broadcasted at the current moment obtained by segmentation at the previous moment, so as to obtain the target text segment to be broadcasted at the current moment; Based on the target text segment, a current reply speech segment for the question speech is determined.
2. The method according to claim 1, wherein: The first text segment is segmented based on the ending information of the first text segment to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment, including: Determining a segmentation position in the first text segment based on the end information of the first text segment; Based on the segmentation position, the first text segment is segmented to obtain a second text segment that needs to be broadcast at the current moment and a third text segment to be broadcast at the next moment.
3. The method according to claim 2, wherein: The determining the segmentation position in the first text segment based on the end information of the first text segment includes: In a case where the end information of the first text segment does not include the first character and the dialog end mark, the segmentation position is determined based on non-end characters in the first text segment.
4. The method according to claim 3, wherein: The determining the segmentation position based on the non-end characters in the first text segment includes: When the first character is included in the non-end characters of the first text segment, a first segmentation position is determined based on the position of the first character in the first text segment.
5. The method according to claim 4, wherein: The first text segment is segmented based on the segmentation position to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment, including: In the case where the segmentation position is the first segmentation position, based on the first segmentation position, the first text segment is segmented into two segments to obtain a second text segment that needs to be broadcast at the current moment and a third text segment to be broadcast at the next moment; Wherein, in the first text segment, the second text segment is located before the third text segment.
6. The method according to claim 3, wherein: The determining the segmentation position based on the non-end characters in the first text segment further includes: When the first character is not included in the non-end characters of the first text segment, the second segmentation position is determined based on the position of the first character in the non-end characters of the first text segment.
7. The method according to claim 6, wherein: The first text segment is segmented based on the segmentation position to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment, including: When the segmentation position is the second segmentation position, the second text segment to be broadcast at the current moment is set as an empty text segment, and the first text segment is spliced to the end of the fourth text segment to be broadcast at the current moment obtained by segmentation at the previous moment, so as to obtain the third text segment to be broadcast at the next moment.
8. The method according to claim 7, further comprising: When the second text segment is an empty text segment, controlling the timer to start timing; When the next first text segment in response to the question voice is not obtained within the preset timing time period, the target text segment that needs to be broadcast at the current moment is determined based on the third text segment.
9. The method according to claim 2, wherein: The determining the segmentation position in the first text segment based on the end information of the first text segment includes: When the end information of the first text segment includes a first character and / or a dialog end mark, the third segmentation position is determined based on the position of the end character of the first text segment.
10. The method according to claim 9, wherein: The first text segment is segmented based on the segmentation position to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment, including: When the segmentation position is the third segmentation position, based on the first text segment, the second text segment to be broadcast at the current moment is determined, and the third text segment to be broadcast at the next moment is set as an empty text segment.
11. The method according to any one of claims 3 to 10, wherein: The first character includes any one of punctuation marks and special symbols.
12. A voice reply method, comprising: Determine the corresponding prompt word keyword based on the question text corresponding to the question voice; Inputting the prompt word keyword into at least one large language model, wherein the large language model is used to generate a reply text segment for the question voice based on the prompt word keyword; When the large language model generates the reply text segment, adding the reply text segment to the text segment cache queue; Based on the text segment cache queue, a reply voice for the question voice is determined.
13. The method according to claim 12, wherein: The step of determining a reply voice for the question voice based on the text segment cache queue includes: Extracting the first-ranked text segment from the text segment cache queue to obtain a first text segment, and deleting the first text segment from the text segment cache queue; Based on the voice reply method according to any one of claims 1 to 11, the first text segment is processed to obtain a current reply voice segment for the question voice.
14. The method according to claim 12, wherein: The type of the reply text segment includes a body text segment, and the step of inputting the prompt word keyword into the large language model includes: The prompt word keyword is provided to a first large language model, wherein the first large language model is used to generate a body text segment for responding to the question voice based on the prompt word keyword.
15. The method according to claim 14, wherein: The type of the reply text segment also includes a summary text segment, and the method further includes: The prompt word keyword is provided to a second language model, wherein the second language model is used to generate a summary text segment for responding to the question voice based on the prompt word keyword.
16. The method according to claim 15, wherein: The step of adding the reply text segment to the text segment cache queue includes: Determining an arrangement position of the reply text segment based on the type of the reply text segment and the type and arrangement order of each text segment in the text segment cache queue; Based on the arrangement position of the reply text segment, the reply text segment is arranged in the text segment cache queue.
17. The method according to claim 16, wherein: The determining the arrangement position of the reply text segment based on the type of the reply text segment and the type and arrangement order of each text segment in the text segment cache queue comprises one of the following: In a case where the reply text segment is a summary text segment and the text segment cache queue includes at least one summary text segment, determining an arrangement position of the reply text segment based on an end position of a last summary text segment in the text segment cache queue; In a case where the reply text segment is a main text segment and the text segment cache queue includes at least one main text segment, determining an arrangement position of the reply text segment based on an end position of the last main text segment in the text segment cache queue; When the reply text segment is a main text segment, and the text segment cache queue does not include a main text segment but includes at least one summary text segment, the arrangement position of the reply text segment is determined based on the end position of the last summary text segment in the text segment cache queue.
18. A voice reply device, comprising: A text segment segmentation module is used for, when a first text segment for replying to a question voice is obtained, segmenting the first text segment based on the ending information of the first text segment to obtain a second text segment to be broadcast at the current moment and a third text segment to be broadcast at the next moment; A text segment concatenation module, for concatenating the second text segment to the end of the fourth text segment to be broadcasted at the current moment obtained by segmentation at the previous moment, when the second text segment is a non-empty text segment, to obtain a target text segment to be broadcasted at the current moment; The first speech determination module is used to determine a current reply speech segment for the question speech based on the target text segment.
19. The device according to claim 18, wherein: The text segmentation module includes: a segmentation position determining unit, configured to determine a segmentation position in the first text segment based on the end information of the first text segment; The segmentation unit is used to segment the first text segment based on the segmentation position to obtain a second text segment that needs to be broadcast at the current moment and a third text segment to be broadcast at the next moment.
20. The device according to claim 19, wherein The segmentation position determination unit is specifically used for: In a case where the end information of the first text segment does not include the first character and the dialog end mark, the segmentation position is determined based on non-end characters in the first text segment.
21. The device according to claim 20, wherein: The determining the segmentation position based on the non-end characters in the first text segment includes: When the first character is included in the non-end characters of the first text segment, a first segmentation position is determined based on the position of the first character in the first text segment.
22. The device according to claim 21, wherein The segmentation unit is specifically used for: In the case where the segmentation position is the first segmentation position, based on the first segmentation position, the first text segment is segmented into two segments to obtain a second text segment that needs to be broadcast at the current moment and a third text segment to be broadcast at the next moment; Wherein, in the first text segment, the second text segment is located before the third text segment.
23. The device according to claim 20, wherein: The determining the segmentation position based on the non-end characters in the first text segment includes: When the first character is not included in the non-end characters of the first text segment, the second segmentation position is determined based on the position of the first character in the non-end characters of the first text segment.
24. The device according to claim 23, wherein: The segmentation unit is specifically used for: When the segmentation position is the second segmentation position, the second text segment to be broadcast at the current moment is set as an empty text segment, and the first text segment is spliced to the end of the fourth text segment to be broadcast at the current moment obtained by segmentation at the previous moment, so as to obtain the third text segment to be broadcast at the next moment.
25. The apparatus according to claim 24, further comprising: a timing module, configured to control a timer to start timing when the second text segment is an empty text segment; The target text segment determination module is used to determine the target text segment that needs to be broadcast at the current moment based on the third text segment when the next first text segment to respond to the question voice is not obtained within a preset timing time period.
26. The device according to claim 19, wherein The segmentation position determination unit is specifically used for: When the end information of the first text segment includes a first character and / or a dialog end mark, the third segmentation position is determined based on the position of the end character of the first text segment.
27. The device according to claim 26, wherein: The segmentation unit is specifically used for: When the segmentation position is the third segmentation position, based on the first text segment, the second text segment to be broadcast at the current moment is determined, and the third text segment to be broadcast at the next moment is set as an empty text segment.
28. The device according to any one of claims 20 to 27, wherein: The first character includes any one of punctuation marks and special symbols.
29. A voice reply device, comprising: A prompt word determination module, used to determine the corresponding prompt word keyword based on the question text corresponding to the question voice; A model processing module, used for inputting the prompt word keyword into at least one large language model, wherein the large language model is used for generating a reply text segment for the question voice based on the prompt word keyword; A text segment adding module, configured to add the reply text segment to the text segment cache queue when the reply text segment is generated by the large language model; The second voice determination module is used to determine a reply voice for the question voice based on the text segment cache queue.
30. The device according to claim 29, wherein: The second voice determination module includes: a text segment extraction unit, configured to extract the first-ranked text segment from the text segment cache queue to obtain a first text segment, and delete the first text segment from the text segment cache queue; A text segment processing unit is used to process the first text segment based on the voice reply method according to any one of claims 1 to 11 to obtain a current reply voice segment for the question voice.
31. The device according to claim 29, wherein: The type of the reply text segment includes a body text segment, and the model processing module includes: The first model processing unit is used to provide the prompt word keyword to a first large language model, wherein the first large language model is used to generate a body text segment for responding to the question voice based on the prompt word keyword.
32. The device according to claim 31, wherein The type of the reply text segment also includes a summary text segment, and the model processing module further includes: The second model processing unit is used to provide the prompt word keyword to a second language model, wherein the second language model is used to generate a summary text segment for responding to the question voice based on the prompt word keyword.
33. The device according to claim 32, wherein: The text segment adding module includes: an arrangement position determining unit, configured to determine an arrangement position of the reply text segment based on the type of the reply text segment and the type and arrangement order of each text segment in the text segment cache queue; The text segment arrangement unit is used to arrange the reply text segment in the text segment cache queue based on the arrangement position of the reply text segment.
34. The method of claim 33, wherein: The arrangement position determination unit is specifically used for one of the following: In a case where the reply text segment is a summary text segment and the text segment cache queue includes at least one summary text segment, determining an arrangement position of the reply text segment based on an end position of a last summary text segment in the text segment cache queue; In a case where the reply text segment is a main text segment and the text segment cache queue includes at least one main text segment, determining an arrangement position of the reply text segment based on an end position of the last main text segment in the text segment cache queue; When the reply text segment is a main text segment, and the text segment cache queue does not include a main text segment but includes at least one summary text segment, the arrangement position of the reply text segment is determined based on the end position of the last summary text segment in the text segment cache queue.
35. An electronic device comprising: at least one central processing unit; as well as A memory in communication with the at least one central processing unit; wherein, The memory stores instructions executable by the at least one central processor, and the instructions are executed by the at least one central processor to enable the at least one central processor to perform the method according to any one of claims 1 to 17.
36. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-17.
37. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 17.
Citation Information
Cited By
Voice reply method and device, equipment, storage medium and program product
CN121366574A
