A method, device, equipment and medium for supporting double-queue mixed broadcasting audio
Patent Information
- Application Number
- CN202311193808.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2043-09-15
AI Technical Summary
[0005]本公开实施例的目的在于提供一种支持双队列混合存取音频的方法、装置、设备及介质,从而解决现有技术中存在的前述问题
[0041]本公开实施例将录制音频和合成音频混合播报提高了用户体验,同时最大程度的提高了性价比,给用户更好的体验效果。播报方法简单,通过播报缓存头标识类型判断播报类型。而且增加了产品软件的灵活性,缩短了开发周期,达到了降低成本的目的。
Smart Images

Figure CN117238272B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of electronic communication and audio broadcasting technology, and in particular to a method, apparatus, device and medium that supports dual-queue mixed audio broadcasting. Background Technology
[0002] The number of IoT devices is increasing. These devices incorporate various voice prompts, necessitating audio playback processing capabilities.
[0003] Since various smart devices play a variety of audio messages during operation, the playback methods are divided into MP3 and TTS. Each of these two methods has its advantages and disadvantages. TTS playback uses synthesized mechanical voices, which lack emotion and result in a slightly worse user experience. MP3, on the other hand, is a recorded audio file that can play music, human speech, etc., but may not cover all content. Most general voice commands use MP3, while some less common or customized voice commands use TTS playback, which can avoid the disadvantages of using only one method to the greatest extent.
[0004] The industry's current approach is to use a single playback method for each audio stream. Clearly, there's a lack of a hybrid playback method that can both improve user experience and provide multiple audio playback options. Summary of the Invention
[0005] The purpose of this disclosure is to provide a method, apparatus, device, and medium that supports dual-queue mixed access to audio, thereby solving the aforementioned problems existing in the prior art.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this disclosure are as follows:
[0007] This disclosure provides, in one aspect, a method for supporting dual-queue mixed access to audio, the method comprising:
[0008] In response to an audio playback request, determine the playback cache header identifier type corresponding to the audio playback request;
[0009] If the type of the broadcast cache header is recorded audio, then wait for the previous voice broadcast to end, read the recorded audio data in the recorded audio cache queue, and broadcast the voice until the voice broadcast ends;
[0010] If the type of the broadcast buffer header is synthetic audio, then wait for the previous voice broadcast to end, read the volume value in the synthetic audio buffer queue, and broadcast the voice until the voice broadcast ends.
[0011] For example, the recorded audio includes one of mp3, amr, pcm and amv; the synthesized audio includes TTS.
[0012] For example, before reading the recorded audio data in the recorded audio buffer queue, the method further includes:
[0013] Determine whether the mutex lock for recorded audio and synthesized audio has been released when they are pushed onto and popped from the stack;
[0014] If the mutex has been released, record audio to lock the mutex;
[0015] After reading the recorded audio data from the recorded audio buffer queue, the mutex is released after storing it in the playback buffer.
[0016] For example, before reading the volume value from the synthesized audio buffer queue, the method further includes:
[0017] Determine whether the mutex lock for recorded audio and synthesized audio has been released when they are pushed onto and popped from the stack;
[0018] If the mutex has been released, the synthesized audio locks the mutex;
[0019] After reading the synthesized audio data from the synthesized audio buffer queue, the mutex is released after storing it in the playback buffer.
[0020] For example, before responding to the audio playback request, the method further includes storing the recorded audio and the synthesized audio respectively, specifically:
[0021] Create a structure for the broadcast cache header identifier and initialize the structure for the broadcast cache header identifier.
[0022] For example, after creating and initializing the structure of the broadcast cache header identifier, the method further includes:
[0023] Create a buffer space for the synthesized audio and initialize the buffer space for the synthesized audio;
[0024] The master controller creates a mutex lock for pushing and popping recorded and synthesized audio onto and off the stack.
[0025] Prepare to call the interface and push a synthesized audio file onto the stack;
[0026] Determine whether the mutex lock has been released. If the mutex lock has been released, determine whether the number of cached synthesized audios has reached a first preset threshold. If the number of cached synthesized audios has not reached the first preset threshold, push the playback cache header with the type of synthesized audio into the stack, and pass the playback content of the synthesized audio and the corresponding parameters into the cache space of the synthesized audio.
[0027] The write pointer to the synthesized audio buffer is incremented accordingly.
[0028] For example, after creating and initializing the structure of the broadcast cache header identifier, the method further includes:
[0029] Create a buffer space for the recorded audio and initialize the buffer space for the recorded audio;
[0030] The master controller creates a mutex lock for pushing and popping recorded and synthesized audio onto and off the stack.
[0031] Prepare to call the API and push an audio record onto the stack;
[0032] Determine whether the mutex lock has been released. If the mutex lock has been released, determine whether the number of cached recorded audios has reached a second preset threshold. If the number of cached recorded audios has not reached the second preset threshold, push the playback cache header with the type of the recorded audio into the stack, and pass the playback content of the recorded audio and the corresponding parameters into the cache space of the recorded audio.
[0033] The write pointer to the recorded audio buffer is incremented accordingly.
[0034] Another aspect of this disclosure provides an apparatus for supporting dual-queue mixed access audio, the apparatus comprising:
[0035] The type determination module is used to respond to an audio playback request and determine the playback cache header identifier type corresponding to the audio playback request;
[0036] The audio recording and playback module is used to wait for the previous voice broadcast to end, read the recorded audio data in the recorded audio buffer queue, and broadcast the voice if the type of the broadcast buffer header is recorded audio, until the broadcast ends.
[0037] The synthesized audio playback module is used to wait for the previous voice broadcast to end, read the volume value in the synthesized audio buffer queue, and broadcast the voice if the type of the broadcast buffer header is synthesized audio, until the broadcast ends.
[0038] Another aspect of this disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the method of mixed audio playback as described above.
[0039] Another aspect of this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method of mixed audio playback as described above.
[0040] The beneficial effects of the embodiments disclosed herein are:
[0041] This disclosed embodiment improves user experience by combining recorded and synthesized audio for playback, while maximizing cost-effectiveness and providing a better user experience. The playback method is simple, determining the playback type by identifying the type in the playback buffer header. Furthermore, it increases the flexibility of the product software, shortens the development cycle, and achieves the goal of cost reduction. Attached Figure Description
[0042] Figure 1 This is a flowchart of a method for supporting dual-queue mixed audio playback according to an embodiment of the present disclosure;
[0043] Figure 2 This is a schematic diagram of the structure of a device supporting dual-queue mixed audio playback according to an embodiment of the present disclosure;
[0044] Figure 3 This is a flowchart illustrating a method for storing TTS audio that supports dual-queue mixed broadcast audio according to an embodiment of this disclosure;
[0045] Figure 4 This is a flowchart illustrating a method for storing MP3 audio that supports dual-queue mixed playback, according to an embodiment of this disclosure.
[0046] Figure 5 This is a schematic flowchart of a method for playing TTS and MP3 audio with dual-queue mixed broadcast, according to an embodiment of the present disclosure. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the embodiments of this disclosure will be further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of this disclosure and are not intended to limit the embodiments of this disclosure.
[0048] like Figure 1 As shown, one embodiment of this disclosure provides a method for supporting dual-queue mixed audio playback, the method comprising:
[0049] Step S1: Respond to the audio playback request and determine the playback cache header identifier type corresponding to the audio playback request.
[0050] In this embodiment of the disclosure, the audio playback request can be a user manually selecting the type of audio to play. The playback cache header identifier type includes recorded audio and synthesized audio. The recorded audio is music, human speech, etc., and the synthesized audio is synthesized mechanical sound, etc.
[0051] For example, the recorded audio includes one of mp3, amr, pcm and amv; the synthesized audio includes TTS.
[0052] The recorded audio is natural; TTS is a text-to-speech technology, and the speech synthesized through TTS is mechanical and lacks emotion.
[0053] Step S2: If the type of the broadcast buffer header identifier is recorded audio, wait for the previous voice broadcast to end, read the recorded audio data in the recorded audio buffer queue, and broadcast the voice until the voice broadcast ends.
[0054] In this embodiment of the disclosure, after receiving an audio playback request, the audio of the playback cache header type corresponding to the audio playback request is played after the previous voice playback has ended.
[0055] For example, before reading the recorded audio data from the recorded audio buffer queue, the method further includes:
[0056] Determine whether the mutex lock for recorded audio and synthesized audio is released when they are pushed onto and popped from the stack;
[0057] If the mutex has been released, the recorded audio locks the mutex.
[0058] After reading the recorded audio data from the recorded audio buffer queue, the mutex is released after storing it in the playback temporary storage area.
[0059] In this embodiment, the mutex locks for pushing and popping recorded and synthesized audio onto and from the stack are created during the storage of recorded or synthesized audio, thus enabling ordered audio playback. In this embodiment, after reading the recorded audio data from the buffer queue and storing it in the playback temporary storage area, the mutex locks are released.
[0060] Step S3: If the type of the broadcast buffer header is synthesized audio, wait for the previous voice broadcast to end, read the volume value, text encoding format and reading number method in the synthesized audio buffer queue, and broadcast the voice until the voice broadcast ends.
[0061] For example, before reading the volume value from the synthesized audio buffer queue, the method further includes:
[0062] Determine whether the mutex lock for recorded audio and synthesized audio is released when they are pushed onto and popped from the stack;
[0063] If the mutex has been released, the synthesized audio locks the mutex.
[0064] After reading the synthesized audio data from the synthesized audio buffer queue, the mutex is released after storing it in the playback temporary storage area.
[0065] In this embodiment, the mutex locks for pushing and popping recorded and synthesized audio onto and from the stack are created during the storage of recorded or synthesized audio, thus enabling ordered audio playback. In this embodiment, after reading the synthesized audio data from the buffer queue and storing it in the playback temporary storage area, the mutex locks are released.
[0066] For example, before responding to the audio playback request, the method further includes storing the recorded audio and the synthesized audio respectively, specifically:
[0067] Create a structure for the broadcast cache header identifier and initialize the structure for the broadcast cache header identifier.
[0068] In this embodiment, the structure of the broadcast buffer header identifier stores data such as the audio type, number of buffers, read pointer, and write pointer of the corresponding audio queue.
[0069] This disclosure, after creating the structures of the broadcast buffer header identifiers corresponding to the recorded audio and the synthesized audio, describes the methods for storing the synthesized audio and the recorded audio, as follows:
[0070] For example, after creating and initializing the structure of the broadcast cache header identifier, the method further includes:
[0071] Create a buffer space for the synthesized audio and initialize the buffer space for the synthesized audio.
[0072] It should be noted that the buffer space for the synthesized audio is used to store data in the synthesized audio buffer playback, including: read pointer, write pointer, and total number of buffers, etc.
[0073] The master controller creates a mutex lock for the recorded audio and the synthesized audio when they are pushed onto and popped from the stack. The mutex lock protects the recorded audio and the synthesized audio during push and pop operations.
[0074] Prepare to call the interface and push a synthesized audio file onto the stack;
[0075] Determine whether the mutex lock has been released. If the mutex lock has been released, determine whether the number of cached synthesized audios has reached a first preset threshold. If the number of cached synthesized audios has not reached the first preset threshold, push the playback cache header with the type of synthesized audio into the stack, and pass the playback content of the synthesized audio and the corresponding parameters into the cache space of the synthesized audio.
[0076] The write pointer to the synthesized audio buffer is incremented accordingly.
[0077] Through the above steps, the storage of synthesized audio is completed. The first preset threshold can be understood as the maximum number of cached synthesized audio.
[0078] For example, after creating and initializing the structure of the broadcast cache header identifier, the method further includes:
[0079] Create a buffer space for the recorded audio and initialize the buffer space for the recorded audio.
[0080] The audio recording buffer is used to store some data from the recorded audio buffer playback. This data includes: read pointer, write pointer, and initial value for the number of buffered data.
[0081] The master controller creates a mutex lock for pushing and popping recorded and synthesized audio onto and off the stack; the mutex lock protects the recorded and synthesized audio during push and pop operations. A single mutex lock is created when storing the recorded and synthesized audio. The mutex lock can be replaced with a semaphore.
[0082] Prepare to call the API and push an audio record onto the stack;
[0083] Determine whether the mutex lock has been released. If the mutex lock has been released, determine whether the number of cached recorded audios has reached a second preset threshold. If the number of cached recorded audios has not reached the second preset threshold, push the playback cache header with the type of the recorded audio into the stack, and pass the playback content of the recorded audio and the corresponding parameters into the cache space of the recorded audio.
[0084] The write pointer to the recorded audio buffer is incremented accordingly.
[0085] Through the above steps, the storage and recording of audio is completed. The second preset threshold can be understood as the maximum number of buffers for the recorded audio.
[0086] The embodiments disclosed herein improve the user experience by using a mixed audio recording and synthesized audio playback method, giving users multiple playback options and making the playback method simple and convenient.
[0087] like Figure 2 As shown, another aspect of this disclosure provides an apparatus for supporting dual-queue mixed audio playback, the apparatus comprising:
[0088] The type determination module 100 is used to respond to an audio playback request and determine the playback cache header identifier type corresponding to the audio playback request. The playback cache header identifier type includes recorded audio and synthesized audio. The recorded audio is playback music, human speech, etc., and the synthesized audio is synthesized mechanical sound, etc.
[0089] The audio recording and playback module 200 is used to wait for the previous voice broadcast to end, read the recorded audio data in the recorded audio buffer queue, and broadcast the voice if the type of the broadcast buffer header identifier is recorded audio, until the broadcast ends.
[0090] The synthesized audio playback module 300 is used to wait for the previous voice broadcast to end, read the volume value in the synthesized audio buffer queue, and broadcast the voice if the type of the broadcast buffer header identifier is synthesized audio, until the broadcast ends.
[0091] In this embodiment, an audio playback request is first responded to, and the playback buffer header identifier type corresponding to the audio playback request is determined. If the playback buffer header identifier type is recorded audio, the system waits for the previous voice playback to finish, reads the recorded audio data from the recorded audio buffer queue, and plays the voice until playback ends. If the playback buffer header identifier type is synthesized audio, the system waits for the previous voice playback to finish, reads the volume value from the synthesized audio buffer queue, and plays the voice until playback ends. Thus, the mixed audio playback device of this embodiment provides two mixed playback methods and plays the audio one by one. The structure of this embodiment is simple, improving the user experience.
[0092] Another embodiment of this disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the method of mixed audio playback as described above.
[0093] Another embodiment of this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method of mixed audio playback as described above.
[0094] The computer-readable storage medium can be any tangible medium that contains or stores a program, and can be an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device. More specific examples include, but are not limited to, connections with one or more wires, portable computer disks, hard disks, optical fibers, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. The computer-readable storage medium can also include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code, specific examples of which include, but are not limited to, electromagnetic signals, optical signals, or any suitable combination thereof.
[0095] The embodiments disclosed herein increase the flexibility of the product software, shorten the development cycle, and achieve the goal of reducing costs.
[0096] The following uses MP3 audio as the recorded audio and TTS audio as the synthesized audio as an example to specifically illustrate the methods for storing (I) synthesized audio and (II) recorded audio, as well as the method for mixing and playing synthesized audio and recorded audio (III). First, the method for synthesizing audio will be explained, starting with the meanings of relevant characters, as follows:
[0097] TTS is a technology that converts text into speech (Text To Speech).
[0098] More detailed explanation:
[0099] (I) The process of TTS performing a push operation:
[0100] The meanings of the characters are as follows:
[0101] TTS_S: The structure of the TTS audio cache queue, i.e. the TTS cache space, which stores the volume, reading mode, encoding mode, interruption screen amount, queue enable, read pointer, write pointer, number of cached audios, playback status, etc. of the corresponding TTS audio.
[0102] mp3AndTtsPushMutex: A mutual exclusion lock for mp3 and tts during push and pop operations.
[0103] st_AudioPlay: A structure that identifies the playback buffer header and stores the audio type, number of buffers, read pointer, and write pointer of the corresponding audio buffer queue.
[0104] st_mp3Play.mp3PlayQueue: Playback buffer header identifier type.
[0105] like Figure 3 As shown, the method for storing synthesized audio, i.e., TTS audio, is as follows:
[0106] Step S11: Create a structure st_AudioPlay that identifies the playback buffer header. This structure is used to distinguish between MP3 audio and TTS audio.
[0107] Step S12: Initialize st_AudioPlay by setting some initial values. Set the initial value of the read / write pointer to 0, and the initial value of the total buffer length to the sum of the number of buffered synthesized audio and recorded audio.
[0108] Step S13: Create a TTS audio buffer space TTS_S. The buffer space TTS_S is used to store the read pointer, write pointer, and total number of buffers in the TTS audio buffer playback.
[0109] Step S14: Initialize TTS_S by setting some initial values. Set the initial values of the read / write pointer and the number of cached items to 0.
[0110] Step S15: The master controller creates a mutex lock mp3AndTtsPushMutex to protect mp3 and TTS audio files during push and pop operations. The mutex lock is used to mutually exclude mp3 and TTS audio files during push and pop operations.
[0111] Step S16: Prepare to call the interface to push a TTS audio message onto the stack.
[0112] Step S17: Determine whether the mutex lock has been released. If it has been released, then lock it and proceed to step S18; otherwise, proceed to step S114.
[0113] Step S18: Determine whether the number of cached TTS audio files, tts_s.tts_ordercnt, has reached the maximum number, i.e., it is full; if the maximum number has been reached, proceed to step S114 and then step S19.
[0114] Step S19: Push the audio of type st_mp3Play.mp3PlayQueue, which is a TTS file, to play the buffer.
[0115] Step S110: Pass the TTS audio playback content and corresponding parameters to TTS_S. Specifically, the passed information includes the volume, encoding format, reading method, and playback content of the TTS audio.
[0116] In step S111, the write pointer tts_s.tts_orderin of the TTS audio buffer is incremented accordingly.
[0117] Step S112: Release the mutex lock.
[0118] Step S113 returns a successful execution result.
[0119] Step S114 returned a failure.
[0120] (II) The process of pushing an MP3 file:
[0121] The meanings of the characters are as follows:
[0122] MP3_S: The structure of the mp3 cache queue, i.e. the mp3 cache space, which stores the corresponding mp3 file name, read pointer, write pointer, number of cached files, audio file name, etc.
[0123] mp3AndTtsPushMutex: A lock that mutually excludes mp3 and tts during push and pop operations.
[0124] st_AudioPlay: A structure that identifies the playback buffer header and stores the audio type, number of buffers, read pointer, and write pointer of the corresponding audio buffer queue.
[0125] st_mp3Play.mp3PlayQueue: Playback buffer header identifier type.
[0126] like Figure 4 As shown, the method for storing recorded audio, i.e., MP3 audio, is as follows:
[0127] Step S21: Create a structure st_AudioPlay that identifies the playback buffer header. This structure is used to distinguish between MP3 audio and TTS audio.
[0128] Step S22: Initialize st_AudioPlay by setting some initial values. Set the initial values of the read and write pointers to 0, and the total buffer length to the sum of the number of buffered synthesized audio and recorded audio.
[0129] Step S23: Create an MP3 audio buffer space MP3_S. The buffer space MP3_S is used to store data from the MP3 audio buffer playback. This data includes the audio filename, read / write pointers, and the number of buffered files.
[0130] Step S24: Initialize MP3_S by setting some initial values. Set the initial values of the read / write pointer and the number of buffered elements to 0.
[0131] Step S25: The master controller creates a mutex mp3AndTtsPushMutex to protect mp3 and tts during push and pop operations.
[0132] The mutex lock is used to prevent MP3 and TTS audio files from being pushed onto and popped from the stack. A single mutex lock can be shared between storing MP3 and TTS audio files. That is, if a mutex lock is created when storing TTS audio files, it is not necessary to create a new mutex lock here.
[0133] Step S26: Prepare to call the interface to push an MP3 audio file for playback.
[0134] Step S27: Determine whether the mutex lock has been released. If it has been released, lock it and proceed to step S28; otherwise, proceed to step S214.
[0135] Step S28: Determine whether the number of cached mp3 audio files st_Mp3.mp3_ordercnt has reached the maximum number, i.e., it is full; if the maximum number has been reached, proceed to step S214 and then step S29.
[0136] Step S29: Push the broadcast buffer header identifier type st_mp3Play.mp3PlayQueue for mp3 audio, which is divided into single mp3 and mp3_list.
[0137] Step S210: Pass the mp3 playback content and corresponding parameters to MP3_S, including the file name of the mp3 file.
[0138] In step S211, the write pointer st_Mp3.mp3_orderin of the mp3 audio buffer is incremented accordingly.
[0139] Step S212: Release the mutex lock.
[0140] Step S213 returns a successful execution result.
[0141] Step S214 returns a failure.
[0142] (III) Parsing process of mp3 and tts, symbol definition:
[0143] st_mp3Play.mp3PlayQueue: Playback buffer header identifier type.
[0144] st_Mp3.mp3_contenttemp: The filename of the cached MP3 file.
[0145] st_Mp3.mp3_orderout: The read pointer to the mp3 queue.
[0146] tts_s.tts_volumetemp: The volume value in the TTS queue.
[0147] tts_s.tts_orderout: The read pointer in the TTS queue.
[0148] like Figure 5 As shown, the method for playing audio using a dual-queue approach is as follows:
[0149] First, receive audio playback requests.
[0150] Step S31: Determine the type of the broadcast buffer header identifier. If it is TTS, proceed to step S38; if it is MP3, proceed to step S32.
[0151] Step S32: Wait for the previous voice broadcast to finish.
[0152] Step S33: Determine whether the mutex lock has been released. If it has been released, lock it and proceed to step S34; otherwise, proceed to step S31.
[0153] Step S34: Read the data st_Mp3.mp3_contenttemp from the cache queue.
[0154] Step S35 involves performing operations such as incrementing the read pointer and decrementing the number of cached items.
[0155] Step S36: Based on the read data, broadcast the voice message.
[0156] Step S37: Release the mutex lock.
[0157] Step S38: Wait for the previous voice broadcast to finish.
[0158] Step S39: Determine whether the mutex lock has been released. If it has been released, lock it and proceed to step S310; otherwise, proceed to step S31.
[0159] Step S310: Read the data in the buffer queue, such as volume (tts_s.tts_volumetemp), reading mode (tts_s.tts_readmode), text encoding format (tts_s.tts_tts_encode), and playback content (tts_s.tts_contenttemp).
[0160] Step S311 involves performing operations such as incrementing the read pointer and decrementing the number of cached items.
[0161] Step S312: Based on the read data, broadcast the voice message.
[0162] Step S313: Release the mutex lock.
[0163] Step S314: The broadcast ends, and a success message is returned.
[0164] The table structure used is as follows:
[0165]
[0166]
[0167]
[0168] By adopting the above-described technical solution disclosed in this embodiment, the following beneficial effects are achieved: the mixed playback of MP3 and TTS improves the user experience and maximizes the cost-effectiveness, providing users with a better experience.
[0169] The above description is only a preferred embodiment of the present disclosure. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present disclosure, and these improvements and modifications should also be considered within the protection scope of the present disclosure.
Claims
1. A method for supporting dual-queue mixed audio playback, characterized in that, The method includes: In response to an audio playback request, determine the playback cache header identifier type corresponding to the audio playback request; If the type of the broadcast cache header is recorded audio, then wait for the previous voice broadcast to end, read the recorded audio data in the recorded audio cache queue, and broadcast the voice until the voice broadcast ends; If the type of the broadcast buffer header is synthetic audio, then wait for the previous voice broadcast to end, read the volume value in the synthetic audio buffer queue, and broadcast the voice until the voice broadcast ends.
2. The method according to claim 1, characterized in that, The recorded audio includes one of the following formats: mp3, amr, pcm, and amv; the synthesized audio includes TTS.
3. The method according to claim 1, characterized in that, Before reading the recorded audio data from the recorded audio buffer queue, the method further includes: Determine whether the mutex lock for recorded audio and synthesized audio has been released when they are pushed onto and popped from the stack; If the mutex has been released, record audio to lock the mutex; After reading the recorded audio data from the recorded audio buffer queue, the mutex is released after storing it in the playback buffer.
4. The method according to claim 1, characterized in that, Before reading the volume value from the synthesized audio buffer queue, the method further includes: Determine whether the mutex lock for recorded audio and synthesized audio has been released when they are pushed onto and popped from the stack; If the mutex has been released, the synthesized audio locks the mutex; After reading the synthesized audio data from the synthesized audio buffer queue, the mutex is released after storing it in the playback buffer.
5. The method according to any one of claims 1 to 4, characterized in that, Before responding to the audio playback request, the method further includes storing the recorded audio and the synthesized audio respectively, specifically: Create a structure for the broadcast cache header identifier and initialize the structure for the broadcast cache header identifier.
6. The method according to claim 5, characterized in that, After creating and initializing the structure of the broadcast buffer header identifier, the method further includes: Create a buffer space for the synthesized audio and initialize the buffer space for the synthesized audio; The master controller creates a mutex lock for pushing and popping recorded and synthesized audio onto and off the stack. Prepare to call the interface and push a synthesized audio file onto the stack; Determine whether the mutex lock has been released. If the mutex lock has been released, determine whether the number of cached synthesized audios has reached a first preset threshold. If the number of cached synthesized audios has not reached the first preset threshold, push the playback cache header with the type of synthesized audio into the stack, and pass the playback content of the synthesized audio and the corresponding parameters into the cache space of the synthesized audio. The write pointer to the synthesized audio buffer is incremented accordingly.
7. The method according to claim 5, characterized in that, After creating and initializing the structure of the broadcast buffer header identifier, the method further includes: Create a buffer space for the recorded audio and initialize the buffer space for the recorded audio; The master controller creates a mutex lock for pushing and popping recorded and synthesized audio onto and off the stack. Prepare to call the API and push an audio recording onto the stack; Determine whether the mutex lock has been released. If the mutex lock has been released, determine whether the number of cached recorded audios has reached a second preset threshold. If the number of cached recorded audios has not reached the second preset threshold, push the playback cache header with the type of the recorded audio into the stack, and pass the playback content of the recorded audio and the corresponding parameters into the cache space of the recorded audio. The write pointer to the recorded audio buffer is incremented accordingly.
8. A device supporting dual-queue mixed audio playback, characterized in that, The device includes: The type determination module is used to respond to an audio playback request and determine the playback cache header identifier type corresponding to the audio playback request; The audio recording and playback module is used to wait for the previous voice broadcast to end, read the recorded audio data in the recorded audio buffer queue, and broadcast the voice if the type of the broadcast buffer header is recorded audio, until the broadcast ends. The synthesized audio playback module is used to wait for the previous voice broadcast to end, read the volume value in the synthesized audio buffer queue, and broadcast the voice if the type of the broadcast buffer header is synthesized audio, until the broadcast ends.
9. An electronic device, characterized in that, include: One or more processors; A memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the method of mixed audio playback as described in any one of claims 1 to 7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for mixed audio playback as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Audio data playing method, device and terminal
CN106653068A
Presence availability device and system
WO2023283182A1