An efficient voice playing method, device and system
By introducing a playback queue mechanism into the voice playback system, the problem of low voice playback efficiency is solved, efficient utilization of processor resources and code compactness are achieved, and the device's responsiveness and data processing capabilities are improved.
Patent Information
- Application Number
- CN202310729996.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-06-16
AI Technical Summary
In existing technologies, voice playback methods are inefficient. The processor cannot respond to other events in a timely manner after waiting for the voice segment to finish playing, which leads to device jamming and data loss. The program logic is also difficult to be compact, and the code readability and maintainability are poor.
A playback queue mechanism is adopted. When the voice chip is idle, the processor reads the voice segment number from the queue and sends it to the voice chip for playback. When the voice chip is busy, no number is sent. The playback queue is maintained by a ring memory to ensure that the processor resources are not occupied.
It improves processor resource utilization, has compact code logic, enhances program readability and maintainability, and avoids device lag and data loss.
Smart Images

Figure CN116881496B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of control methods for electronic products, and more specifically, to an efficient voice playback method, apparatus, and system. Background Technology
[0002] Voice playback is a novel and popular user interface method in various electronic appliances. By playing corresponding voice prompts under appropriate conditions, information can be provided to users or guidance can be given for the next step. Compared to simple buzzer beeps or LED indicator lights, this method can convey a wealth of information. More importantly, compared to user interface components such as LCD screens, this method has a significant cost advantage while also enhancing user appeal, instantly giving the product a "high-end" feel. Therefore, this technology is very popular in consumer electronics, especially toys.
[0003] When a product is playing a voice message, the processor typically waits for the current message segment to finish playing before playing the next one. A common practice is to poll the VOICE_BUSY pin of the voice chip to check its "playing" status. For example, a certain type of voice chip outputs a high level when idle and a low level when playing voice messages. After the processor triggers playback by sending the voice segment number to the VOICE_DAT pin, it must continuously poll the VOICE_BUSY pin until it returns to a high level before playing the next segment. However, this approach introduces a problem: during the polling period, the processor cannot respond to other events in a timely manner. Since voice playback often lasts for one second or longer, this inability to respond to other events manifests as the device suddenly freezing until the voice message finishes playing, and during this time, data from various peripherals is lost.
[0004] Due to the unique characteristics of voice playback—it is often time-consuming and frequently requires piecing together multiple voice segments for sequential playback, such as amounts or values—the program flow inevitably involves waiting for the next segment to finish playing before it can be specified. Furthermore, specifying all voice segments to be played at once using data types like arrays is logically difficult to make compact. The code efficiency remains low, and the program readability and maintainability are poor. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide an efficient voice playback method, device, and system, which addresses the issues of low efficiency and difficulty in coherent processor logic in conventional methods.
[0006] The technical solution adopted by this invention to solve its technical problem is: to provide an efficient voice playback method, which can be used in a voice playback system, including the following steps:
[0007] S1. Plan all the audio segments that the audio playback system needs to play and their numbers, and manufacture a voice chip. The voice chip indicates the busy / idle status through its pin level.
[0008] S2. The processor of the voice playback system establishes and maintains a playback queue to store the numbers of the voice segments that need to be played.
[0009] S3. When it is necessary to play a certain audio segment among all the audio segments, write the number corresponding to the audio segment to be played to the end of the playback queue;
[0010] S4. The processor checks the pin status of the voice chip. When the voice chip is idle, if the playback queue is not empty, the processor reads the voice segment number pointed to by the head from the playback queue and sends it to the voice chip to trigger the voice chip to play the corresponding voice segment.
[0011] When the voice chip is busy, it will not read the playback queue and will not send the voice segment number to the voice chip.
[0012] S5. After the voice chip finishes playing the voice segment, the pin level will indicate that it is idle, and the processor will send a new voice segment number when the playback queue is not empty.
[0013] Preferably, in step S1, the communication between the processor and the voice chip includes an output signal line outputting to the VOICE_DATA pin of the voice chip, the processor sending the voice segment number to the voice chip via the output signal line to trigger the voice chip to play; and an input signal line from the VOICE_BUSY pin of the voice chip, the level of which reflects whether the voice chip is in the busy state of playing voice or the idle state of not playing voice.
[0014] Preferably, the voice chip is in a busy state when the input signal line VOICE_BUSY pin outputs a low level;
[0015] When the input signal line VOICE_BUSY pin outputs a high level, the voice chip is in an idle state.
[0016] Preferably, in step S2, the playback queue is set up and maintained by software in the processor's memory, simulating a ring memory.
[0017] Preferably, the ring memory includes storage cells, a head pointer, a tail pointer, an "empty" flag, and a "full" flag;
[0018] The head pointer points to the head of the playback queue, allowing the processor to read the memory unit it points to; the tail pointer points to the tail of the playback queue, allowing the processor to write to the memory unit it points to.
[0019] The "empty" and "full" flags are used to indicate the storage status of the playback queue.
[0020] Preferably, step S4 includes:
[0021] After the processor reads the audio segment number pointed to by the head from the playback queue, the head pointer moves to the next storage unit along the read / write direction of the ring memory.
[0022] If the storage unit pointed to by the head pointer after it moves is the same as the tail pointer, then the playback queue is empty, and the "empty" flag is set; the processor will not send a new voice segment number after the voice chip plays the current voice segment.
[0023] Preferably, writing the number corresponding to the audio segment to be played to the tail of the playback queue includes:
[0024] The tail pointer points to the first free storage unit in the ring memory after the valid data in the playback queue, for writing;
[0025] After the voice segment number is written to the storage unit corresponding to the tail pointer, the tail pointer moves to the next storage unit along the read / write direction of the ring memory;
[0026] If the storage unit pointed to by the tail pointer after it moves is the same as the head pointer, then the playback queue is full, and the "full" flag is set.
[0027] Furthermore, the present invention also provides a high-efficiency voice playback device, including a voice chip, a processor, and a memory storing a computer program, wherein the processor implements any of the above-described voice playback methods when executing the computer program.
[0028] Furthermore, the present invention also provides a high-efficiency voice playback system, comprising:
[0029] The voice chip is used to store all the pre-planned voice segments to be played according to their numbers, and the corresponding voice segments can be specified by external numbers.
[0030] The processor is used to set up and maintain a playback queue and execute the following procedures:
[0031] When it is necessary to play a certain audio segment among all the audio segments, the number corresponding to the audio segment to be played is written to the end of the playback queue;
[0032] When the voice chip is idle and the playback queue is not empty, the voice segment number pointed to by the head is read from the playback queue and sent to the voice chip to trigger the voice chip to play the corresponding voice segment.
[0033] When the voice chip is in a busy state, the voice segment number is not sent to the voice chip;
[0034] After the voice chip finishes playing the voice segment, the pin level will indicate that it is idle, and the processor will send a new voice segment number when the playback queue is not empty.
[0035] Implementing this invention has at least the following beneficial effects: by separating the actions of "needing to play" and "actually playing", the voice number to be played is written to the queue at one time, so that the processor does not have to pay attention to a certain event continuously, reducing the resource consumption of the processor; at the same time, the code logic is compact, and the readability and maintainability are strong. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a flowchart of an embodiment of the voice playback method provided by the present invention;
[0038] Figure 2 This is a logic block diagram of the ring memory in this invention;
[0039] Figure 3 This is a schematic diagram of an embodiment of the voice playback system provided by the present invention. Detailed Implementation
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] like Figure 1 As shown, in some embodiments of an efficient voice playback method of the present invention, the method can be used in a voice playback system and includes the following steps:
[0042] S1. Plan all the audio segments and their numbers that the voice playback system needs to play, and manufacture a voice chip. The voice chip indicates its busy / idle status through its pin levels. Specifically, this can be implemented by the voice chip manufacturer. When a specific audio segment needs to be played, the processor sends the corresponding audio segment number to the voice chip. It's understandable that the processor often needs to play one or more audio segments in sequence under specific circumstances, such as piecing together audio segments of a specific amount or duration.
[0043] Optionally, in step S1, the communication between the processor and the voice chip includes an output signal line outputting to the VOICE_DATA pin of the voice chip, through which the processor sends a voice segment number to the voice chip to trigger the voice chip to play; the input signal line from the VOICE_BUSY pin of the voice chip reflects whether the voice chip is playing voice, i.e., a busy state of playing voice or an idle state of not playing voice.
[0044] For example, when the VOICE_BUSY pin of the voice chip outputs a low level, the voice chip is in a busy state, indicating that it is playing;
[0045] When the input signal line VOICE_BUSY pin outputs a high level, the voice chip is in an idle state. It is conceivable that in some voice chips, the input signal line VOICE_BUSY can also be a low level indicating idle, with a high level indicating playback. This invention describes the embodiment using the state of high level idle and low level indicating playback.
[0046] S2. The processor of the voice playback system establishes and maintains a playback queue to store the numbers of the voice segments that need to be played.
[0047] Specifically, the playback queue can be established and maintained in the processor's memory, implemented using a ring memory simulated by a software algorithm. For example... Figure 2 As shown, gray represents numbered cells, and white represents free cells. The sum of the number of gray cells and the number of white cells is the capacity of the playback queue. The gray and white cell areas are contiguous and rotate in the queue along the read / write direction as the playback queue is written to and read from.
[0048] Optionally, the ring memory includes storage cells, a head pointer, a tail pointer, an "empty" flag, and a "full" flag. The head pointer points to the head of the playback queue and is used to read the storage cell it points to; the tail pointer points to the tail of the playback queue and is used to write to the storage cell it points to; the "empty" and "full" flags indicate the storage status of the playback queue. The head and tail pointers are used to obtain the read and write positions of the playback queue, and these positions are used to determine whether the playback queue is in an "empty" or "full" state.
[0049] This ring memory can be used and maintained by write and read functions. It is implemented in a high-level language using an array with appropriate code; the number of array elements is the queue capacity.
[0050] S3. When a specific audio segment needs to be played from all audio segments, the audio chip is not directly triggered to play it. Instead, the number corresponding to the audio segment to be played is written to the tail of the playback queue. Specifically, the tail pointer points to the first free storage unit in the circular memory after the valid data in the playback queue, for writing.
[0051] After the voice segment number is written to the storage unit corresponding to the tail pointer, the tail pointer moves to the next storage unit along the read / write direction of the ring memory.
[0052] If the storage unit pointed to by the tail pointer after moving is the same as the head pointer, then the playback queue is full, meaning no new storage unit can be written, and the "full" flag is set. This flag can be cleared after reading the audio segment number from the playback queue.
[0053] Furthermore, the content of the playback queue changes dynamically with writing and playback. When writing, it should be determined whether the playback queue is full. If it is full, new audio segment numbers cannot be written, resulting in data loss. In this case, the queue capacity should be increased to avoid the queue becoming "full".
[0054] S4. The processor checks the pin status of the voice chip. Specifically, when the voice chip is idle, the processor checks the pin status of the voice chip's signal output line VOICE_BUSY in the main loop. A high level indicates that the voice chip is idle.
[0055] When the voice chip is idle, if it determines that the playback queue is not empty, it reads the voice segment number pointed to by the head of the playback queue and sends it to the voice chip to trigger the voice chip to play the corresponding voice segment. It should be noted that after the processor reads the voice segment number pointed to by the head, the next voice segment number is located at the head of the queue. In other words, after the processor reads the voice segment number pointed to by the head of the playback queue, the head pointer moves to the next memory unit along the read / write direction of the circular memory.
[0056] If the memory cell pointed to by the head pointer after it moves is the same as the tail pointer, then the playback queue is empty and the "empty" flag is set. The "empty" flag being set is a normal state, indicating that there are no audio segments to play in the playback queue, and the processor will not send a new audio segment number after the audio chip plays the current audio segment.
[0057] Specifically, the voice playback method of the present invention further includes: when the program is initialized or after the processor reads the playback queue, the head pointer of the circular memory coincides with the tail pointer of the circular memory, and the playback queue is determined to be "empty", that is, there are no playable voice segments. This flag can be cleared after writing the voice segment number to the playback queue.
[0058] When the voice chip is busy, the processor does not send voice segment numbers to the voice chip; specifically, when the voice chip is playing a voice segment, the VOICE_BUSY pin outputs a low level to indicate that the voice chip is busy.
[0059] In the subsequent main loop, the processor checks the pin status of the VOICE_BUSY voice chip. If it is low, even if the playback queue is not empty, it will not send the voice segment number to the voice chip to ensure that the current voice segment is played completely.
[0060] S5. After the voice chip finishes playing a voice segment, the pin level will indicate that it is idle. Based on this, the processor will send a new voice segment number when the queue is not empty. Specifically, after the voice chip finishes playing the current voice segment, the VOICE_BUSY pin outputs a high level. In the subsequent main loop, the processor checks that the VOICE_BUSY pin of the voice chip is at a high level and that the playback queue is not empty. If so, it continues to send voice segment numbers to the voice chip so that other voice segments in the queue can be played.
[0061] Optionally, step S5 also includes: when the playback queue is empty, even if the processor finds that the voice chip is idle, since there is no voice to play, the processor does not need to perform voice processing at this time.
[0062] Furthermore, in some embodiments of the efficient voice playback device of the present invention, a voice chip and a processor are included, wherein the processor implements any of the above-described voice playback methods when executing the computer program.
[0063] Furthermore, such as Figure 3 As shown, in some embodiments of a high-efficiency voice playback system of the present invention, the system includes:
[0064] The voice chip 110 is used to store all the pre-planned voice segments to be played according to their numbers, and the corresponding voice segments can be specified by external numbers to play.
[0065] Optionally, the voice chip 110 is connected to the sound-emitting device 130, and the sound-emitting device 130 emits sound to play voice segments;
[0066] Processor 120 is used to establish and maintain the playback queue in memory; and to execute the following procedures:
[0067] When a specific audio segment needs to be played from all audio segments, the number corresponding to the audio segment to be played is written to the end of the playback queue;
[0068] When the voice chip is in an idle state, that is, when the VOICE_BUSY pin outputs a high level and the playback queue is not empty, the voice segment number pointed to by the head is read from the playback queue and sent to the voice chip to trigger the voice chip to play the corresponding voice segment.
[0069] When the voice chip is busy, i.e., when the VOICE_BUSY pin outputs a low level, the processor does not send the voice segment number to the voice chip. Specifically, if the voice chip is busy, i.e., when the VOICE_BUSY pin outputs a low level, even if the playback queue is not empty, the processor will not take the first voice segment number from the playback queue and send it to the voice chip to trigger the voice chip to play the corresponding voice segment, so as not to disrupt the playback of the current voice segment.
[0070] Once the voice chip has finished playing the voice segment, set the voice chip to idle.
[0071] Optionally, if the voice chip finishes playing the current voice segment and returns to idle while the playback queue is not empty, it can continue to retrieve the first voice segment number from the playback queue and send it to the voice chip to trigger the voice chip to play the corresponding voice segment... and so on.
[0072] The further coordination process between the various units of the voice playback system can be referred to the specific process of the voice playback method described above, and will not be elaborated further here.
[0073] The above-disclosed embodiments are merely preferred embodiments of the present invention and should not be construed as limiting the scope of the invention. Those skilled in the art will understand that all or part of the processes for implementing the above embodiments, and equivalent variations made in accordance with the claims of the present invention, still fall within the scope of the invention.
Claims
1. A highly efficient voice playback method, applicable to a voice playback system, characterized in that, Includes the following steps: S1. Plan all the audio segments that the audio playback system needs to play and their numbers, and manufacture a voice chip. The voice chip indicates the busy / idle status through its pin level. S2. The processor of the voice playback system establishes and maintains a playback queue to store the numbers of the voice segments that need to be played. S3. When it is necessary to play a certain audio segment among all the audio segments, write the number corresponding to the audio segment to be played to the end of the playback queue; S4. The processor checks the pin status of the voice chip. When the voice chip is idle, and the playback queue is not empty, the processor reads the voice segment number pointed to by the head from the playback queue and sends it to the voice chip to trigger the voice chip to play the corresponding voice segment. When the voice chip is busy, it will not read the playback queue and will not send the voice segment number to the voice chip. S5. When the voice chip finishes playing the voice segment, the pin level will indicate that it is idle, and the processor will send a new voice segment number when the playback queue is not empty. In step S1, the communication between the processor and the voice chip includes an output signal line outputting to the VOICE_DATA pin of the voice chip, and the processor sending the voice segment number to the voice chip via the output signal line to trigger the voice chip to play the voice segment; the input signal line from the VOICE_BUSY pin of the voice chip reflects whether the voice chip is in a busy state of playing voice or an idle state of not playing voice. In step S2, the playback queue is set up and maintained by software in the processor's memory, simulating a ring memory.
2. The efficient voice playback method according to claim 1, characterized in that, When the input signal line VOICE_BUSY pin outputs a low level, the voice chip is in a busy state; When the input signal line VOICE_BUSY pin outputs a high level, the voice chip is in an idle state.
3. The efficient voice playback method according to claim 1, characterized in that, The ring memory includes storage cells, a head pointer, a tail pointer, an "empty" flag, and a "full" flag; The head pointer points to the head of the playback queue, allowing the processor to read the memory unit it points to; the tail pointer points to the tail of the playback queue, allowing the processor to write to the memory unit it points to. The "empty" and "full" flags are used to indicate the storage status of the playback queue.
4. The efficient voice playback method according to claim 3, characterized in that, Step S4 includes: After the processor reads the audio segment number pointed to by the head from the playback queue, the head pointer moves to the next storage unit along the read / write direction of the ring memory. If the storage unit pointed to by the head pointer after it moves is the same as the tail pointer, then the playback queue is empty, and the "empty" flag is set; the processor will not send a new voice segment number after the voice chip plays the current voice segment.
5. The efficient voice playback method according to claim 3, characterized in that, In step S3, writing the number corresponding to the audio segment to be played to the tail of the playback queue includes: The tail pointer points to the first free storage unit in the ring memory after the valid data in the playback queue, for writing; After the voice segment number is written to the storage unit corresponding to the tail pointer, the tail pointer moves to the next storage unit along the read / write direction of the ring memory; If the storage unit pointed to by the tail pointer after it moves is the same as the head pointer, then the playback queue is full, and the "full" flag is set.
6. A high-efficiency voice playback device, comprising a voice chip, a processor, and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the voice playback method according to any one of claims 1-5.
7. A high-efficiency voice playback system, characterized in that, include: The voice chip is used to store all the pre-planned voice segments to be played according to their numbers, and the corresponding voice segments can be specified by external numbers. The processor is used to set up and maintain a playback queue and execute the following procedures: When it is necessary to play a certain audio segment among all the audio segments, the number corresponding to the audio segment to be played is written to the end of the playback queue; When the voice chip is idle and the playback queue is not empty, the voice segment number pointed to by the head is read from the playback queue and sent to the voice chip to trigger the voice chip to play the corresponding voice segment. When the voice chip is in a busy state, the voice segment number is not sent to the voice chip; When the voice chip finishes playing the voice segment, the pin level will indicate that it is idle, and the processor will send a new voice segment number when the playback queue is not empty. The communication between the processor and the voice chip includes an output signal line outputting to the VOICE_DATA pin of the voice chip, the processor sending the voice segment number to the voice chip via the output signal line to trigger the voice chip to play; and an input signal line from the VOICE_BUSY pin of the voice chip, the level of which reflects whether the voice chip is in a busy state of playing voice or an idle state of not playing voice. The playback queue is set up and maintained by software in the processor's memory, simulating a ring memory.
Citation Information
Patent Citations
Method and device for prompting voice of uninterruptible power supply
CN101609583A
Method and system for generating minority language corpus
CN111091812A