Text-to-voice conversion method, electronic equipment, storage medium and program product

By sorting text to speech tasks in the task queue and determining the number of consumer threads based on the capacity of the text to speech engine, the problem of high concurrency in the prior art has been solved, and the stable and efficient processing of text to speech services is achieved.

CN119600985APending Publication Date: 2025-03-11KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411676232.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The existing text-to-speech (tts) function can easily lead to service failure when the concurrency amount is too high, and it cannot effectively deal with high concurrency situations.

Method used

By sorting text to speech tasks in the task queue and determining the number of consumer threads based on the capacity of the text to speech engine, parallel processing and reasonable scheduling of tasks can be achieved to avoid excessive concurrency.

Benefits of technology

It effectively improves the processing capabilities of text-to-voice services, avoids service failures caused by high concurrency, and ensures the stability and fluency of services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600985A_ABST
    Figure CN119600985A_ABST
Patent Text Reader

Abstract

The invention provides a text-to-voice method, electronic equipment, a readable storage medium and a computer program product. The text-to-voice method disclosed by the invention comprises the following steps: adding text-to-voice tasks into a task queue, and sorting the text-to-voice tasks in the task queue according to a timestamp sequence; in response to a task acquisition request of a consumer thread, sending the first text-to-voice task in the task queue to the consumer thread; in response to a task processing request of the consumer thread, sending a text-to-voice task obtained by the consumer thread to a text-to-voice engine; acquiring voice data returned by the text-to-voice engine; wherein the text-to-voice engine is used for converting text data into voice data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a text-to-speech method, electronic device, storage medium, and program product. Background Art

[0002] When using the text-to-speech (TTS) function, the number of requests that the TTS service can process simultaneously is limited due to resource constraints. If the concurrency is too high within a certain period of time, it is easy to cause the overall TTS service to fail. The current TTS function is usually unable to cope with the problem of TTS service failure caused by excessive concurrency. Summary of the invention

[0003] The present disclosure provides a text-to-speech method, an electronic device, a storage medium, and a program product.

[0004] According to one aspect of the present disclosure, a text-to-speech method is provided, comprising: Adding the text-to-speech task to a task queue, wherein the text-to-speech tasks in the task queue are sorted in order of timestamps; In response to a task acquisition request of a consumer thread, sending the first text-to-speech task in the task queue to the consumer thread; In response to a task processing request of the consumer thread, sending the text-to-speech task acquired by the consumer thread to a text-to-speech engine; Obtaining the speech data returned by the text-to-speech engine; The text-to-speech engine is used to convert text data into speech data.

[0005] According to the text-to-speech method of at least one embodiment of the present disclosure, the number of the consumer threads is multiple; the text-to-speech method further includes: The number of the consumer threads is determined based on the capacity of the text-to-speech engine, and a plurality of the consumer threads are created based on the determined number.

[0006] According to the text-to-speech method of at least one embodiment of the present disclosure, the consumer thread is configured as follows: In response to the voice data returned by the text-to-speech engine corresponding to the task processing request of the consumer thread, a new task acquisition request is allowed to be generated.

[0007] According to a text-to-speech method of at least one embodiment of the present disclosure, obtaining voice data returned by the text-to-speech engine includes: sending a voice acquisition request to the text-to-speech engine; and in response to an overlimit message from the text-to-speech engine, resending a voice acquisition request to the text-to-speech engine after waiting for an overlimit time.

[0008] According to the text-to-speech method of at least one embodiment of the present disclosure, the text-to-speech task includes a preview task, and the timestamp of the preview task is the highest priority timestamp.

[0009] The text-to-speech method according to at least one embodiment of the present disclosure further includes: matching the text-to-speech task corresponding to the voice data; determining the timestamp of the text-to-speech task as the timestamp of the voice data corresponding to it; adding the voice data to a return queue, wherein the voice data in the return queue is sorted in timestamp order; and sending the return queue to a client.

[0010] According to a text-to-speech method of at least one embodiment of the present disclosure, the text-to-speech task is added to a task queue, and the text-to-speech tasks in the task queue are sorted in order of timestamps, including: adding the text-to-speech task to the task queue, and configuring the time when the text-to-speech task is added to the task queue as the timestamp of the text-to-speech task; and when the text-to-speech task obtains a timestamp, sorting the text-to-speech tasks in the task queue in order of timestamps.

[0011] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the text-to-speech method of any one embodiment of the present disclosure.

[0012] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the text-to-speech method of any embodiment of the present disclosure is implemented.

[0013] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the text-to-speech method of any one of the embodiments of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0015] Figure 1 It is a schematic diagram of an application scenario of a text-to-speech method according to an embodiment of the present invention.

[0016] Figure 2 It is a flowchart of a text-to-speech method according to an embodiment of the present invention.

[0017] Figure 3 It is a flowchart of a text-to-speech method according to an embodiment of the present invention.

[0018] Figure 4 It is a flowchart of a text-to-speech method according to an embodiment of the present invention.

[0019] Figure 5 It is a schematic diagram of an application scenario of a text-to-speech method according to an embodiment of the present invention.

[0020] Figure 6 It is a flowchart of a text-to-speech method according to an embodiment of the present invention.

[0021] Figure 7 It is a flowchart of a text-to-speech method according to an embodiment of the present invention.

[0022] Figure 8 It is a flowchart of a text-to-speech method according to an embodiment of the present invention.

[0023] Fig. 9 The figure is a schematic block diagram of the structure of a text-to-speech device according to an embodiment of the present disclosure.

[0024] Fig.10 The present invention is a block diagram showing a structure of an electronic device equipped with a text-to-speech device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0025] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.

[0026] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0027] When using the text-to-speech (TTS) function, the number of requests that the TTS service can process simultaneously is limited due to resource constraints. If the concurrency is too high within a certain period of time, it is easy to cause the overall TTS service to fail.

[0028] For example, in some scenarios, the number of requests per minute (RPM) as a resource indicator is subject to strict restrictions. If the request flow is too high, the result "429" will be returned, which means that the frequency limit has been exceeded and accumulated in the RPM. At the same time, if a request for a resource fails, the caller of the resource will repeat the request, occupying the request channel of other resources, and eventually causing the entire tts service to exceed the limit and become unavailable.

[0029] To this end, the present disclosure proposes a text-to-speech method.

[0030] For the convenience of description and to make the technical solutions of the specific implementation methods of the present disclosure easier to understand, before describing the text-to-speech method implemented in the present disclosure, the technical terms involved in the specific implementation methods of the present disclosure are explained as follows: Text-To-Speech (TTS) is a technology that converts text content into speech output. It can be widely used in various scenarios, such as assisting visually impaired people to read e-books, voice prompts in car navigation systems, etc.

[0031] Figure 1 FIG. 2 shows a schematic diagram of the overall process of a text-to-speech method M100 according to an embodiment of the present disclosure. Figure 1 The method shown includes steps S120 to S180. The method can be executed by electronic devices such as mobile phones, computers, and servers.

[0032] Specifically, Figure 1 The methods shown include: S120: Add the text-to-speech task to a task queue, and sort the text-to-speech tasks in the task queue in order of timestamps.

[0033] The text-to-speech task is used to indicate the task of converting specific text information into corresponding voice data. The task queue is a queue for caching text-to-speech tasks. The timestamp of the text-to-speech task is used to determine the priority of the text-to-speech task.

[0034] In one example, the timestamp of a text-to-speech task may be a mark added to the text-to-speech task by the client when the text-to-speech task is generated, indicating the time when the text-to-speech task is generated. In this way, it can be ensured that the first generated text-to-speech task is processed first.

[0035] In another example, the timestamp of the text-to-speech task can be a mark added to the text-to-speech task when the text-to-speech task is added to the task queue, indicating the time when the text-to-speech task is added to the task queue. In this way, it can be ensured that the text-to-speech task added to the task queue first is processed first.

[0036] The text-to-speech tasks in the task queue are sorted in the order of timestamps, which means that the text-to-speech tasks in the task queue are sorted in the order that the tasks with earlier times are sorted first and processed first, and the tasks with later times are sorted last and processed last. For example, the text-to-speech tasks in the task queue include the first task and the second task. The timestamp of the first task is "12:00:00" and the timestamp of the second task is "12:02:00", then the first task is sorted before the second task.

[0037] S140 . In response to the task acquisition request of the consumer thread, send the first text-to-speech task in the task queue to the consumer thread.

[0038] The consumer thread is a thread used to consume text-to-speech tasks in the task queue. The task acquisition request of the consumer thread is used to obtain the text-to-speech task from the task queue.

[0039] The number of consumer threads may be one or more. For example, multiple text-to-speech tasks may be executed by one consumer thread, or multiple text-to-speech tasks may be executed in parallel by multiple consumer threads, which is not limited here.

[0040] The first text-to-speech task in the task queue refers to the text-to-speech task with the highest processing priority in the task queue. When the first text-to-speech task in the task queue is sent, it will be removed from the task queue, and the first text-to-speech task in the task queue will become another text-to-speech task with the highest priority. This ensures that the text-to-speech tasks in the task queue can be sent to the text-to-speech engine for processing without duplication.

[0041] S160 . In response to the task processing request of the consumer thread, send the text-to-speech task acquired by the consumer thread to the text-to-speech engine.

[0042] The text-to-speech engine is a software or service that can convert text information into speech output. For example, the text-to-speech engine can be an application, a mobile phone software, a deep learning model (such as Tacotron, WaveNet, FastSpeech, Flow-based Models), etc., without limitation.

[0043] In one example, a text-to-speech engine is a deep learning model that includes a text analysis network, a speech synthesis network, and a post-processing network. The text analysis network is used to pre-process the input text, including word segmentation, sentence segmentation, word form conversion, etc., to ensure that the text can be pronounced correctly. The speech synthesis network is used to convert the processed text into a speech signal. This process usually involves mapping the text to a phoneme sequence, then converting the phoneme sequence into acoustic features (such as spectrum, fundamental frequency, etc.), and finally generating a speech waveform through a vocoder (such as WaveNet, Griffin-Lim algorithm, etc.). The post-processing network is used to post-process the generated speech signal, such as adding background noise, adjusting the volume, etc., to improve the naturalness of the speech.

[0044] In one example, the consumer thread forwards the text-to-speech task to the text-to-speech engine for processing through the server. That is, the server responds to the task processing request of the consumer thread and sends the text-to-speech task obtained by the consumer thread from the task queue to the text-to-speech engine for processing. In this way, only when the server receives the task processing request of the consumer thread will it initiate a processing request for the text-to-speech task to the text-to-speech engine, which can limit the number of requests initiated to the text-to-speech engine at the same time to a certain extent, avoiding excessive concurrency.

[0045] S180: Acquire speech data returned by the text-to-speech engine.

[0046] In one example, the consumer thread forwards the text-to-speech task to the text-to-speech engine for processing through the server. When the text-to-speech engine completes the processing of the text-to-speech task and generates voice data, the generated voice data is returned to the server, and the server sends the acquired voice data to the client. In this way, if the text-to-speech engine exceeds the limit or fails to process a text-to-speech task from a consumer thread, the server can wait or request a retry according to the situation, which will not affect the text-to-speech engine's processing of text-to-speech tasks from other consumer threads, thereby avoiding the exception of one text-to-speech task causing the global text-to-speech task to be put into waiting.

[0047] In summary, the text-to-speech method provided in this embodiment maintains a task queue, sorts the text-to-speech tasks in the task queue in timestamp order, and sends the first text-to-speech task in the task queue to the consumer thread in response to the task acquisition request of the consumer thread. The text-to-speech task acquired by the consumer thread is processed by requesting the text-to-speech engine through the server. In this way, in the first aspect, for the client, the production of text-to-speech tasks and the consumption of voice data are separated. Whether the voice data obtained by the previous text-to-speech task is consumed will not affect the sending of the next text-to-speech request, which can ensure the smooth operation of the text-to-speech service; in the second aspect, the consumer thread requests to obtain the text-to-speech task in the task queue, which can realize that multiple consumer threads consume the text-to-speech tasks in the task queue in parallel; in the third aspect, each time the first text-to-speech task in the task queue is sent to the consumer thread for processing, the order of the text-to-speech tasks can be ensured, so that the text-to-speech service can be carried out in an orderly manner.

[0048] Please combine Figure 1 , Figure 1 The application scenario of the text-to-speech method of an embodiment of the present disclosure is shown. In one embodiment of the present disclosure, the text to be converted into speech is provided by the client, and the text to be converted into speech is generated as one or more text-to-speech tasks. The text-to-speech task is executed by the text-to-speech engine to obtain speech data, and the obtained speech data is finally returned to the client. In this process, there are many interactive requests between the client and the text-to-speech engine. The text-to-speech method of the present disclosure can schedule the requests involved in the text-to-speech function to prevent the text-to-speech function from being over-limited and unavailable due to excessive concurrency.

[0049] exist Figure 1In the application scenario shown, the server is used to schedule the interaction request between the client and the text-to-speech engine. The text information provided by the client is packaged as a text-to-speech task (tts task). When the text-to-speech task is packaged, the text-to-speech task is added to the task queue, and the text-to-speech tasks in the task queue are all pending tasks. The idle consumer thread will send a task acquisition request, and the task acquisition request is used to obtain the text-to-speech task in the task queue. When responding to the task acquisition request, a text-to-speech task in the task queue will be sent to the consumer thread corresponding to the task acquisition request, and the sent text-to-speech task will be removed from the task queue to ensure that the text-to-speech tasks in the task queue are all pending tasks. After the consumer thread obtains the text-to-speech task, it sends the obtained text-to-speech task to the server, and the server requests the text-to-speech engine to process the text-to-speech task. If the text-to-speech engine successfully generates voice data, the generated voice data is returned to the server. After receiving the voice data, the server returns the voice data to the client.

[0050] Based on the above scheme, the client separates the production of text-to-speech tasks and the consumption of voice data. When processing multiple text-to-speech tasks, it is not carried out in the following manner: sending a text-to-speech task to the text-to-speech engine, and sending the next text-to-speech task to the text-to-speech engine when receiving the voice data returned by the text-to-speech engine. Instead, each time a text-to-speech task is obtained, the text-to-speech task can be added to the task queue, and the idle consumer thread obtains the text-to-speech task from the task queue for processing, so that multiple text-to-speech tasks in the task queue can be processed in parallel by multiple consumer threads. After obtaining the text-to-speech task, the consumer thread requests the text-to-speech engine to execute the obtained text-to-speech task through the server, so that the number of requests to the text-to-speech engine within a certain period of time is limited by the number of consumer threads, avoiding the failure of the overall text-to-speech service due to excessive concurrency of requests.

[0051] Regarding step S120, in some embodiments of the present disclosure, it may include the following steps: Figure 3 Steps S1201 to S1202 are shown.

[0052] S1201: Add a text-to-speech task to a task queue, and configure the time when the text-to-speech task is added to the task queue as a timestamp of the text-to-speech task.

[0053] That is to say, the timestamp of the text-to-speech task indicates the time when the text-to-speech task is added to the task queue.

[0054] S1202: When the text-to-speech task obtains a timestamp, each text-to-speech task in the task queue is sorted in the order of the timestamp.

[0055] In this way, the order in which the text-to-speech tasks in the task queue are processed depends on the order in which the text-to-speech tasks are added to the task queue, which can ensure that the text-to-speech tasks added to the task queue first are processed first.

[0056] Regarding step S180, in some embodiments of the present disclosure, it may include: Figure 4 Steps S1801 to S1802 are shown.

[0057] S1801. Send a speech acquisition request to a text-to-speech engine.

[0058] The speech acquisition request is used to request the text-to-speech engine that sends the speech acquisition request to execute a text-to-speech task.

[0059] Please combine Figure 1 ,If the text-to-speech task is executed normally, the text-to-speech engine returns the speech data to the server.

[0060] S1802: In response to the limit-exceeding message of the text-to-speech engine, wait for the limit-exceeding time and then resend a speech acquisition request to the text-to-speech engine.

[0061] Among them, the over-limit message refers to the message generated by the text-to-speech engine when the usage of the text-to-speech engine exceeds its predetermined maximum capacity or limit, which is used to indicate that the text-to-speech engine is in an over-limit state. For example, when the request is too frequent and exceeds the maximum request frequency that the text-to-speech engine can handle; or when the number of concurrent connections exceeds the maximum number of connections that the text-to-speech engine can handle simultaneously; or when the memory used by the text-to-speech engine exceeds the memory space allocated to it; or when the disk space usage reaches the upper limit; when the bandwidth usage exceeds the limit; or when the number of API calls reaches the limit, the text-to-speech engine is in an over-limit state, and the text-to-speech engine will not return voice data, but will return an over-limit message.

[0062] The overtime time refers to the waiting time for the next voice acquisition request to be sent when the server responds to the overtime message of the text-to-speech engine. For example, if the overtime time is 3 minutes, the server will no longer send a voice acquisition request to the text-to-speech engine within 3 minutes, and will not send a voice acquisition request to the text-to-speech engine again until 3 minutes have passed, so as to request the text-to-speech engine to return voice data. In this way, it can be prevented that when the text-to-speech engine is in an overtime state, the server will repeatedly send requests to the text-to-speech engine, resulting in excessive concurrency.

[0063] See also Figure 5 In some embodiments of the present disclosure, the priority of the text-to-speech task in the task queue can be increased or decreased by configuring the timestamp of the text-to-speech task.

[0064] In one example, a text-to-speech task includes a preview task. The preview task is mainly used for users to preview the effect of text-to-speech, so in most application scenarios, the preview task often needs to be processed first. However, the creation time of the preview task may be later than other text-to-speech tasks. In this case, the priority of the preview task in the task queue can be increased by configuring the timestamp of the preview task so that the preview task is processed first.

[0065] In one example, the timestamp of the preview task is configured as the highest priority timestamp. For example, the value of the highest priority timestamp is "0", indicating that once the preview task is added to the task queue, the preview task will be sorted to the top of the current task queue. For another example, if two preview tasks are added to the task queue one after another, and the timestamp values ​​of the two preview tasks are both "0", the preview task that is added to the task queue later will be sorted to the top of the current task queue.

[0066] In summary, by configuring the timestamp of the text-to-speech task, a "queue jumping" mechanism can be introduced so that a specific text-to-speech task can be sorted to a specific position in the task queue.

[0067] See also Figure 6 In some embodiments of the present disclosure, step S110 may be further included before step S120.

[0068] S110 : Determine the number of consumer threads based on the capacity of the text-to-speech engine, and create multiple consumer threads based on the determined number of consumer threads.

[0069] The capacity of the text-to-speech engine represents the computing power of the text-to-speech engine. The stronger the computing power of the text-to-speech engine, the greater its capacity and the more tasks that can be processed simultaneously, so that more consumer threads can be created accordingly, and more text-to-speech tasks can be obtained from the task queue and sent to the text-to-speech engine for consumption. If the capacity of the text-to-speech engine is small and the computing power is weak, a smaller number of consumer threads can be created accordingly to limit the number of text-to-speech tasks provided to the text-to-speech engine for consumption at the same time.

[0070] In one example, the server may obtain the capacity of the text-to-speech engine, calculate the number of consumer threads based on the capacity of the text-to-speech engine, send the number of consumer threads to the client, and the client may create a corresponding number of consumer threads based on the number of consumer threads.

[0071] In one example, the server periodically monitors the maximum concurrency of the text-to-speech service, and the client calculates the size of the thread pool based on the maximum concurrency provided by the server. The size of the thread pool determines the number of consumers that the text-to-speech engine allows to consume simultaneously, that is, the number of consumer threads. Generally speaking, the thread pool size should match the maximum number of concurrent consumers allowed by the text-to-speech engine on the server. In one example, the server periodically checks the status of the thread pool, such as the number of active threads, the length of the task queue, etc., to ensure that the thread pool is in a healthy state. The server can dynamically adjust the thread pool size according to the actual load situation to avoid resource waste or excessive load.

[0072] In one example, the client can call different text-to-speech engines to perform text-to-speech tasks. Different text-to-speech engines have different capacities. In this case, the number of consumer threads corresponding to different text-to-speech engines can be calculated based on the capacities of different text-to-speech engines. In this way, when the client calls one of the text-to-speech engines, multiple consumer threads can be created based on the number of consumer threads corresponding to the text-to-speech engine. For example, 8 consumer threads are configured for the first engine with a larger capacity, and 2 consumer threads are configured for the second engine with a smaller capacity. If the client calls the first engine to process the text-to-speech task, the client creates 8 corresponding consumer threads to obtain the text-to-speech task from the task queue. In this way, different numbers of consumer threads can be configured for different text-to-speech engines to limit the maximum flow of different text-to-speech engines.

[0073] In some embodiments of the present disclosure, the consumer thread is configured to generate a new task acquisition request in response to the speech data returned by the text-to-speech engine corresponding to the task processing request of the consumer thread.

[0074] Based on a task processing request of the consumer thread, the server sends the text-to-speech task obtained by the consumer thread to the text-to-speech engine for processing. At this time, the voice data obtained by the text-to-speech engine when executing the text-to-speech task obtained by the consumer thread is called the voice data corresponding to the consumer thread. For example, consumer 1 sends task processing request 1, and task processing request 1 is used to instruct the text-to-speech engine to execute text-to-speech task 1. Assuming that the voice data generated by the text-to-speech engine when executing text-to-speech task 1 is recorded as voice data 1, it is considered that voice data 1 corresponds to task processing request 1. When consumer 1 responds that voice data 1 corresponds to task processing request 1, consumer 1 generates a new task acquisition request for acquiring a new text-to-speech task from the task queue.

[0075] In this way, when the same consumer thread requests to obtain the text-to-speech task in the task queue and requests the server to process the text-to-speech task, the request form used is a serial request. In other words, every time the consumer thread initiates a task processing request to the server, if the task processing request has not been completed, the consumer thread will not obtain the task from the task queue until the task processing request is completed. The consumer thread will generate a new task acquisition request and obtain a new task from the task queue.

[0076] In some embodiments of the present disclosure, the text-to-speech method M100 may further include: Figure 7 Step S190 is shown.

[0077] S190: Send the voice data to the client.

[0078] In some embodiments of the present disclosure, step S190 specifically includes the following steps: Figure 8 Steps S1901 to S1904 are shown.

[0079] S1901, matching the text-to-speech task corresponding to the voice data.

[0080] Among them, a voice data is the result obtained by executing a text-to-speech task, and the voice data corresponds to the text-to-speech task.

[0081] S1902: Determine the timestamp of the text-to-speech task as the timestamp of the corresponding speech data.

[0082] S1903: Add the voice data to a return queue, and sort the voice data in the return queue in order of timestamps.

[0083] In this way, the order of the voice data in the return queue is consistent with the order of the text-to-speech tasks corresponding to the voice data in the task queue. Even if the voice data is obtained by executing the preview task, it can be ensured that the voice data has the highest priority in the return queue.

[0084] S1904. Send the return queue to the client.

[0085] Through the above steps S1501 to S1504, the order in which the voice data received by the client can be consistent with the order of the text-to-speech tasks corresponding to the voice data in the task queue, so that the text-to-speech tasks with high priority are processed first and their corresponding voice data are received by the client first, so as to ensure the sequentiality of data interaction in the text-to-speech service.

[0086] In other embodiments, the voice data may not be sorted, and the voice data may be returned to the client when it is generated, so as to ensure that the client receives the voice data in real time.

[0087] Based on any of the above implementations, the present disclosure also provides a text-to-speech device. Fig. 9 The figure is a schematic block diagram of the structure of a text-to-speech device according to an embodiment of the present disclosure.

[0088] like Fig. 9 As shown, the text-to-speech device comprises: The queue module 110 is used to add the text-to-speech task to the task queue. The text-to-speech tasks in the task queue are sorted in the order of timestamps.

[0089] The consumer thread functional module 120 is used to send the first text-to-speech task in the task queue to the consumer thread in response to the task acquisition request of the consumer thread.

[0090] The service module 130 (ie, the server described above) is used to respond to the task processing request of the consumer thread and send the text-to-speech task acquired by the consumer thread to the text-to-speech engine.

[0091] The service module 130 obtains the speech data returned by the text-to-speech engine.

[0092] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0093] The execution subject of the text-to-speech method in the specific implementation manner of the present disclosure may be an electronic device such as a mobile phone, a computer, or a server.

[0094] Therefore, based on any of the above embodiments, the present disclosure further provides an electronic device, which can execute the text-to-speech method of any of the above embodiments of the present disclosure, and the text-to-speech device of any of the above embodiments can be configured on the electronic device.

[0095] Fig.10 1 is a schematic block diagram of the structure of an electronic device 1000 configured with a text-to-speech device (eg, configured in a memory in the form of software) according to an embodiment of the present disclosure.

[0096] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.

[0097] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.

[0098] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.

[0099] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.

[0100] A computer program or instruction may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, a computer program or instruction may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.

[0101] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0102] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable text-to-speech device to produce a machine, so that the instructions executed by the processor of the computer or other programmable text-to-speech device generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0103] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable text-to-speech device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0104] These computer program instructions may also be loaded onto a computer or other programmable text-to-speech device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0105] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.

[0106] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0107] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.

Claims

1. A text-to-speech method, characterized in that: include: Adding the text-to-speech task to a task queue, wherein the text-to-speech tasks in the task queue are sorted in order of timestamps; In response to a task acquisition request of a consumer thread, sending the first text-to-speech task in the task queue to the consumer thread; In response to a task processing request of the consumer thread, sending the text-to-speech task acquired by the consumer thread to a text-to-speech engine; as well as Obtaining the speech data returned by the text-to-speech engine; The text-to-speech engine is used to convert text data into speech data.

2. The text-to-speech method according to claim 1, characterized in that: The number of the consumer threads is multiple; The text-to-speech method further comprises: The number of the consumer threads is determined based on the capacity of the text-to-speech engine, and a plurality of the consumer threads are created based on the determined number.

3. The text-to-speech method according to claim 1, characterized in that: The consumer thread is configured as: In response to the voice data returned by the text-to-speech engine corresponding to the task processing request of the consumer thread, a new task acquisition request is allowed to be generated.

4. The text-to-speech method according to claim 1, characterized in that: Acquiring the speech data returned by the text-to-speech engine includes: Sending a speech acquisition request to the text-to-speech engine; and In response to the limit-exceeding message of the text-to-speech engine, a speech acquisition request is resent to the text-to-speech engine after waiting for the limit-exceeding time.

5. The text-to-speech method according to claim 1, characterized in that: The text-to-speech task includes a preview task, and the timestamp of the preview task is the highest priority timestamp.

6. The text-to-speech method according to claim 1, characterized in that: The text-to-speech method further comprises: Matching the text-to-speech task corresponding to the voice data; Determine the timestamp of the text-to-speech task as the timestamp of the speech data corresponding to it; Adding the voice data to a return queue, wherein the voice data in the return queue is sorted in order of timestamps; and The return queue is sent to the client.

7. The text-to-speech method according to claim 1, characterized in that: Adding a text-to-speech task to a task queue, wherein the text-to-speech tasks in the task queue are sorted in the order of timestamps, includes: Adding the text-to-speech task to a task queue, and configuring the time when the text-to-speech task is added to the task queue as the timestamp of the text-to-speech task; and When one of the text-to-speech tasks in the task queue obtains a timestamp, the text-to-speech tasks in the task queue are sorted in order of the timestamps.

8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the text-to-speech method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the text-to-speech method according to any one of claims 1 to 7 when executed by a processor.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the text-to-speech method according to any one of claims 1 to 7 is implemented.