AI song generation method and device based on parallel processing and terminal
By dividing the AI song generation process into two independent threads of cover and song processing in parallel, the problems of high latency and low resource utilization in the existing technology are solved, low latency and efficient song generation are achieved, and user experience and resource utilization are improved.
Patent Information
- Application Number
- CN202510507723.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-08-08
AI Technical Summary
The existing AI song generation technology has problems such as high latency, low resource utilization and poor scalability, and it is impossible to process multiple song requests in parallel, resulting in users waiting in line.
The song generation process is divided into two independent threads: cover generation and song generation. The cover picture and audio files are processed separately through the asynchronous parallel generation mechanism, and dynamic thread pool management tasks are used when multiple song generation requests are used.
It significantly shortens the song generation time, reduces from minute to second level, improves resource utilization, especially GPU utilization, from 30% to 75%, and supports the processing of multiple song generation requests at the same time.
Smart Images

Figure CN120448105A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an AI song generation method, device, intelligent terminal and storage medium based on parallel processing. Background Art
[0002] With the development of artificial intelligence (AI) technology and the continuous improvement of people's living standards, the use of various AI devices and technologies is becoming increasingly popular. People often use AI to generate songs. However, the mainstream existing AI song generation technology uses a serial process, which has the following drawbacks: 1) High latency: It requires waiting for the cover and song to be fully generated (taking an average of 3-5 minutes); 2) Low resource utilization: The serial processing of cover and song generation results in idle GPU / CPU resources; 3) Poor scalability: Multiple song requests cannot be processed in parallel, forcing users to wait in queues.
[0003] Therefore, the existing technology still needs to be improved and developed. Summary of the Invention
[0004] The technical problem to be solved by the present invention is that, in response to the problems and defects of the above-mentioned prior art, a method, device, intelligent terminal and storage medium for AI song generation based on parallel processing are provided. The present invention can solve the problem of low generation efficiency caused by low computing resource utilization during AI song generation; the serial blocking problem of a single song generation process. In the present invention, the cover generation thread and the song generation thread of AI song generation are separated and processed in parallel, which speeds up the generation efficiency and improves resource utilization.
[0005] The technical solutions adopted by the present invention to solve the problem are as follows: A method for generating AI songs based on parallel processing, comprising: Get the song generation request and create the song generation main thread according to the song generation request; Control the song generation main thread to assign the cover generation task to the cover generation sub-thread, and assign the song generation task to the song generation sub-thread; Adopting an asynchronous parallel generation mechanism, controlling the cover generation sub-thread to generate a cover image according to the assigned cover generation task; controlling the song generation sub-thread to generate an audio file according to the assigned song generation task; When it is detected that the cover image and audio file of the same song are generated, the cover image and audio file of the same song are controlled to be synthesized and output.
[0006] In the AI song generation method based on parallel processing, the steps of obtaining a song generation request and creating a song generation main thread according to the song generation request include: When the song generation request is a plurality of song generation requests, the control constructs a dynamic thread pool for managing the plurality of song generation tasks, and creates an independent song generation main thread for each song generation request.
[0007] The AI song generation method based on parallel processing, wherein the step of controlling the song generation main thread to assign the cover generation task to the cover generation sub-thread and assigning the song generation task to the song generation sub-thread includes: An independent thread group is assigned for each independent song generation main thread request, each independent assigned thread group assigns the cover generation task to the cover generation sub-thread, and assigns the song generation task to the song generation sub-thread.
[0008] The AI song generation method based on parallel processing, wherein the step of controlling the synthesis and output of the cover image and audio file of the same song when detecting that the cover image and audio file of the same song have been generated includes: When the cover images and audio files of multiple songs are merged and generated separately, the batch generation results are returned and output.
[0009] The AI song generation method based on parallel processing, wherein the step of synthesizing and outputting the cover image and audio file of the same song upon detecting that the generation is complete includes: Monitor the status of each child thread through the future object, and trigger the retry mechanism when any task fails; When it is detected that the cover image and audio file of the same song have been generated, they are synthesized and output. The AI song generation method based on parallel processing, wherein, when detecting that the cover image and audio file of the same song have been generated, the step of controlling the synthesis and output of the cover image and audio file of the same song further includes: Use message queue to notify task status in real time.
[0010] The AI song generation method based on parallel processing, wherein when the song generation request is multiple song generation requests, the steps of controlling and building a dynamic thread pool for managing multiple song generation tasks and creating an independent song generation main thread for each song generation request include: When the song generation request is a plurality of song generation requests, a dynamic thread pool is controlled to be constructed for managing the plurality of song generation tasks, namely, the first song generation task, the second song generation task to the Nth song generation task; And create an independent song generation main thread for each song generation request, which are the first song generation main thread corresponding to the first song generation task and the second song generation to the Nth song generation tasks.
[0011] An AI song generation device based on parallel processing, wherein the device comprises: A song generation request acquisition module is used to obtain a song generation request; A song generation main thread creation module is used to create a song generation main thread according to a song generation request; A task allocation module, used for controlling the song generation main thread to allocate the cover generation task to the cover generation sub-thread, and to allocate the song generation task to the song generation sub-thread; An asynchronous parallel generation control module is used to control the cover generation sub-thread to generate a cover image according to the assigned cover generation task; and to control the song generation sub-thread to generate an audio file according to the assigned song generation task, using an asynchronous parallel generation mechanism; The contract module is used to control the synthesis and output of the cover image and audio file of the same song when it is detected that the cover image and audio file of the same song are generated; A dynamic thread pool construction module is used to control the construction of a dynamic thread pool for managing multiple song generation tasks when the song generation request is a plurality of song generation requests, and to create an independent song generation main thread for each song generation request; The multi-song task allocation module is used to independently allocate a thread group for each independent song generation main thread request, and each independent allocation thread group allocates the cover generation task to the cover generation sub-thread and the song generation task to the song generation sub-thread.
[0012] An intelligent terminal includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, including the method for executing any one of the methods described above.
[0013] A computer-readable storage medium, wherein when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform any one of the methods described above.
[0014] Beneficial effects of the present invention: The present invention provides an AI song generation method, device, intelligent terminal and storage medium based on parallel processing. The present invention provides a low-latency song generation method, which reduces the user waiting time from minutes to seconds through multi-threaded parallel processing. That is, the two parts of song generation: generating the cover image and generating the song are executed separately using different threads. This can speed up the AI song generation time, shortening the time to return the first result to within 20 seconds (measured data); and can improve resource utilization, GPU utilization from 30% to more than 75%; and the concurrency capability is enhanced: it supports processing 3 song generation requests at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1 3 is a flow chart of the AI song generation method based on parallel processing provided in Example 1 of the present invention.
[0017] Figure 2 2 is a flow chart of the AI song generation method based on parallel processing provided in Example 2 of the present invention.
[0018] Figure 3 Schematic diagram of shooting alignment recognition of the AI song generation method based on parallel processing provided in Example 3 of the present invention.
[0019] Figure 4 A block diagram of the principles of an embodiment of an AI song generation device based on parallel processing provided by the present invention.
[0020] Figure 5 This is a block diagram of the internal structure of the smart terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solutions and advantages of the present invention more clear and distinct, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0022] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications will also change accordingly.
[0023] Artificial intelligence (AI) is often used to generate songs. The mainstream existing AI song generation technology uses a serial process, specifically: 1. The user submits a song generation request; 2. Subtasks are executed sequentially: first, the song cover image is generated, then the song audio file (MIDI / MP3 format) is generated and uploaded to cloud storage (COS); 3. After all processing is completed, the results are returned.
[0024] Existing AI song generation technology has the following flaws: 1) High latency: It is necessary to wait for the cover and song to be fully generated (taking an average of 3-5 minutes); 2) Low resource utilization: The serial processing of cover and song generation causes GPU / CPU resources to be idle; 3) Poor scalability: It is impossible to process multiple song requests in parallel, and users need to wait in line.
[0025] In view of the above-mentioned shortcomings of the prior art, the present invention provides an AI song generation method based on parallel processing, which can solve the following technical problems: 1). Serial blocking problem in the single song generation process; 2). Insufficient concurrent processing capabilities for multiple user requests; 3). Low generation efficiency due to low utilization of computing resources.
[0026] This invention provides a low-latency song generation method that reduces user wait time from minutes to seconds through multi-threaded parallel processing. Specifically, the two parts of song generation—cover image generation and song generation—are executed separately using different threads. This accelerates AI song generation, reducing the time it takes to return the first result to under 20 seconds (measured data); improves resource utilization, increasing GPU utilization from 30% to over 75%; and enhances concurrency: supporting the simultaneous processing of three song generation requests.
[0027] Example 1 like Figure 1 As shown, an AI song generation method based on parallel processing in embodiment 1 of the present invention includes the following steps: Step S100: Obtain a song generation request, and create a song generation main thread according to the song generation request; In this embodiment of the present invention, AI-generated songs are used as an example. In a specific implementation, song generation requests are obtained. When the system receives a request from a user or other program to generate a song, including information such as the user's selected style, mood, instrument, lyric theme, etc., these requests can be submitted through the API or user interface.
[0028] Once the system receives a song generation request, it creates a dedicated main thread (or task) based on the request content to handle it. A thread is the basic unit of computational scheduling in an operating system and can run independently of other threads. Therefore, embodiments of the present invention can handle multiple requests simultaneously.
[0029] For example, in an embodiment of the present invention, a user submits a request to generate a piece of "cheerful electronic music". In this scenario: Get Request: The user sends a request through the app interface, including their selected genre (electronic music), mood (upbeat), and possible instrument (synth, drum machine).
[0030] Then create the main thread: After receiving this request, the system of the present invention will create a new main thread T_main to facilitate the subsequent steps to perform the song generation task, using a specific audio library and algorithm (such as an AI-based music generation model) for generation.
[0031] Of course, the present invention can realize multi-user processing: for example, another user may want to generate a "tranquil piano piece", and another thread will be created in the system to run independently of the first thread, ensuring that the requests of the two users are processed in a timely manner.
[0032] In this embodiment, each song creates an independent main thread to handle song generation requests, allowing the system to handle multiple requests simultaneously without blocking the main program. Users can get feedback faster, improving user experience and response speed.
[0033] Multithreaded processing allows for more efficient use of computing resources, especially when processing complex algorithms or large amounts of data. The main thread can flexibly select different generation algorithms or processes based on different request types, allowing the system to better adapt to the needs of different users.
[0034] Step S200: Control the song generation main thread to assign the cover generation task to the cover generation sub-thread, and assign the song generation task to the song generation sub-thread; In an embodiment of the present invention, when a user submits a song generation request, a song generation main thread T_main is created; and the song generation main thread T_main is controlled to assign the cover generation task to the cover generation sub-thread T_cover, and assign the song generation task to the song generation sub-thread T_music.
[0035] In specific implementation, the song generation main thread is similar to the main control unit and is responsible for managing and scheduling various generation tasks. In the embodiment of the present invention, when the main thread receives a song generation request, it will decide how to assign these tasks to appropriate child threads.
[0036] Regarding assigning cover generation tasks to the cover generation sub-thread: Specifically, the main thread assigns the task of generating exclusive song cover art to a dedicated cover generation sub-thread. This sub-thread can use image processing libraries or AI models to design the requested cover.
[0037] Regarding assigning song generation tasks to the song generation sub-thread: Specifically, the main thread also assigns the actual song generation task (i.e., the melody, harmony, etc.) to another dedicated song generation sub-thread. This sub-thread processes the music data and algorithms to generate the song requested by the user.
[0038] For example, when a music generation application made using the present invention receives a request, the user hopes to generate a "vibrant pop song" and design a cover for it.
[0039] Then control task allocation: After receiving this request, the main thread will first analyze the request content and determine that two tasks are required - generating music and cover.
[0040] Task allocation: The main thread assigns the task of "generating song covers" to the cover generation sub-thread, and at the same time assigns the task of "generating vibrant pop songs" to the song generation sub-thread.
[0041] As can be seen, the present invention enables asynchronous parallel processing: by assigning different tasks (such as cover generation and song generation) to different sub-threads, the system can achieve parallel processing. This can significantly shorten completion time. Furthermore, each sub-thread can focus on executing a specific task. For example, the cover generation sub-thread can optimize image processing, while the song generation sub-thread can focus on music generation logic, thereby improving the processing efficiency of each.
[0042] Step S300: Using an asynchronous parallel generation mechanism, control the cover generation sub-thread to generate a cover image according to the assigned cover generation task; control the song generation sub-thread to generate an audio file according to the assigned song generation task; This step embodiment involves asynchronous programming and parallel processing to improve the efficiency and response speed of the system.
[0043] In specific implementation, the present invention adopts an asynchronous parallel generation mechanism, which allows the system to process multiple tasks in parallel at the same time, and each sub-thread can complete its assigned task in parallel. The use of an asynchronous mechanism can fully utilize system resources and improve overall execution efficiency.
[0044] In this embodiment of the present invention, the main thread controls the cover generation sub-thread to receive the cover generation task based on the previous task assignment. The cover generation sub-thread is specifically responsible for generating song cover images and can use image generation tools or algorithms (such as deep learning models) to create visual works.
[0045] Similarly, the main thread controls the song generation sub-thread to receive song generation tasks. The song generation sub-thread is responsible for processing audio data and using audio synthesis algorithms or AI models to quickly generate music audio files.
[0046] For example, when using the present invention to provide online music creation services, a user submits a request to generate a "dynamic electronic dance music" and its cover. Startup process: After the user clicks the button, the main thread of the system of the present invention receives the request and analyzes the content to be generated: song and cover.
[0047] Then the tasks are assigned: the main thread assigns the cover generation task to the cover generation sub-thread, and assigns the song generation task to the song generation sub-thread.
[0048] Then, asynchronous parallel generation begins: the cover generation thread begins running, using AI models (such as DALL-E or Stable Diffusion) to generate cover art suitable for the theme of "dynamic electronic dance music." Simultaneously, the song generation thread uses electronic music synthesizers and AI algorithms to generate audio files with dynamic rhythms and melodies.
[0049] Then, after the cover generation is completed, the song cover will be displayed quickly. At the same time, the song generation is also in progress, and the user may have seen the cover while waiting for the audio file, thus improving the experience.
[0050] It can be seen that the asynchronous parallel processing mechanism of the present invention ensures the efficient execution of the music and cover generation process, significantly reduces the user's waiting time, and brings a better user experience.
[0051] The present invention adopts an asynchronous parallel generation mechanism, which enables the system to process multiple requests simultaneously, improving overall efficiency. This means that users no longer have to wait for one task to complete before starting another, thus shortening the time of the entire generation process.
[0052] And the subthread of the present invention can make full use of multiple processing cores, concentrate power to perform specific tasks, and is particularly effective when processing complex algorithms.In addition, because the tasks are asynchronous, the system can handle more user requests without being overloaded.
[0053] Step S400: When it is detected that the cover image and audio file of the same song are generated, the cover image and audio file of the same song are controlled to be synthesized and output.
[0054] In this embodiment of the present invention, the status of the cover generation sub-thread and the song generation sub-thread are monitored during this phase. When both tasks for generating the same song are completed, the system is notified. This monitoring can be implemented using callback functions, signals, or status checks.
[0055] In this embodiment of the present invention, once the cover image and audio file have been successfully generated, the main thread will perform a synthesis operation. This process involves combining the cover image and the audio file to generate a complete output file that can also display the audio content (for example, an image file containing the audio or embedding information into a music player).
[0056] After the synthesis is completed, the present invention will provide the final generated content to the user. This may be a downloadable music file (such as MP3 or WAV format) and its corresponding cover image, which the user can use or share on his or her own device.
[0057] For example, when the method of the present invention is used to request generation of a song named "Dream Summer" and its corresponding cover in an online music generation application.
[0058] Each sub-thread is generated in parallel: By creating a main thread T_main, the cover generation sub-thread and song generation sub-thread are started simultaneously. The cover generation sub-thread uses an image synthesis model to generate a fresh, sunny cover, while the song generation sub-thread generates a light and melodious audio file.
[0059] Once both sub-threads complete the generation task, the present invention will automatically detect this state, for example, by detecting a flag of file creation or by triggering a callback function.
[0060] After detecting that both the cover and the audio file have been generated, the main thread controls the synthesis process and can embed the cover image into the metadata of the audio file (such as an ID3 tag) or package the cover together with the audio file as an attachment.
[0061] After the synthesis is complete, the user will receive a notification stating that the song "Dream Summer" and its cover have been generated, and a download link will be provided. After clicking, the user can directly download a compressed file containing the audio and cover, or view the corresponding cover when playing the song in the music player.
[0062] As can be seen from the above, the combined output of cover art and audio in the present invention provides users with an integrated product, enhancing the user experience. Users can simultaneously access music and related visual materials, which helps to increase the appeal of the content. Furthermore, by combining the cover art and audio into a single file, the user's download and management steps are simplified. Users no longer need to download the cover art and audio separately, reducing operational complexity. The combined output can better convey the theme and emotion of the song, closely integrating music with visual art, and enhancing the artistic expression of the work.
[0063] The present invention is further described in detail below through specific application examples: Example 2 like Figure 2 As shown, this specific application embodiment 2 provides an AI song generation method based on parallel processing, including the following steps: S10, the user requests to generate a song, and enters S11; S11, create the main thread and enter S12 and S121; In this specific implementation example, when the user submits a song generation request, a song generation main thread T_main is created; S12, start the cover generation thread CoverThread; and enter S13; S13, generate a cover image; and proceed to S14; S121, start the song generation thread MusicThread; and enter S122; S122, generate an audio file; and enter S122; In the embodiment of the present invention, when the song generation main thread T_main is successfully created, the song generation main thread T_main assigns the cover generation task to the cover generation sub-thread T_cover, and the song generation task to the song generation sub-thread T_music; an asynchronous parallel generation mechanism is adopted to control the cover generation sub-thread to generate a cover image according to the assigned cover generation task; and control the song generation sub-thread to generate an audio file according to the assigned song generation task. S14: Monitor the thread completion status. If any of them fails, proceed to S15. If both are completed, proceed to S16. S15, triggering the retry mechanism; That is, in the embodiment of the present invention, the status of each sub-thread is monitored through the future object, and a retry mechanism is triggered when any task fails; when it is detected that the cover image and audio file of the same song are generated, they are synthesized and output. S16. The merged result is returned to the front end; That is, the embodiment of the present invention adopts asynchronous generation and status monitoring: a dual-thread collaborative monitoring mechanism is introduced, and the status of the child threads is monitored through the Future object. If any task fails, a retry mechanism is triggered.
[0064] The present invention is further described in detail below through another specific application embodiment: like Figure 3 As shown, a method for generating an AI song based on parallel processing in a specific application embodiment 3 of the present invention includes the following steps: S30, receiving a user's request for generating batch songs, and proceeding to S31.
[0065] S31, create a thread pool and enter S40, S50, S60 respectively; In an embodiment of the present invention, when the song generation request is multiple song generation requests, a dynamic thread pool is controlled to manage multiple song generation tasks, such as task 1, task 2,...task n; and an independent song generation main thread is created for each song generation request.
[0066] That is, in this embodiment of the present invention, when the song generation request is for multiple song generation requests, a dynamic thread pool is controlled to be constructed to manage multiple song generation tasks, namely, the first song generation task, and the second to Nth song generation tasks; and an independent song generation main thread is created for each song generation request, namely, the first song generation main thread corresponding to the first song generation task, and the second to Nth song generation tasks. The specific steps are as follows: S40, Task 1: song_1, and enter S41 and S42 at the same time; S41, start the first cover generation thread CoverThread_1, generate the first cover image; and enter S43; S42, start the first song generation thread MusicThread_1, generate the first audio file; and enter S43; In the embodiment of the present invention, an independent thread group is independently assigned for each independent song generation main thread request, and each independent assigned thread group assigns a cover generation task to a cover generation sub-thread and a song generation task to a song generation sub-thread; S43. Merge the first cover image and the first audio file, output a first merge result 1, and proceed to S70.
[0067] S50, Task 2: song_2, and enter S51 and S52 at the same time; S51, start the second cover generation thread CoverThread_2, generate the second cover image; and enter S53; S52, start the second song generation thread MusicThread_2, generate a second audio file; and enter S53; S53. Merge the second cover image and the second audio file, output a second merge result 2, and proceed to S70.
[0068] S60, task n: song_n, start the second cover generation thread CoverThread_n, generate the nth cover image; start the nth song generation thread MusicThread_n, generate the nth audio file; merge the nth cover image and the nth audio file, output the nth merge result n, and enter S70.
[0069] S70. Return results in batches.
[0070] In the embodiment of the present invention, when the cover images and audio files of multiple songs are merged and generated respectively, the batch generation results are returned and output.
[0071] That is, the present invention has an embodiment that can realize multi-task parallel processing: a dynamic thread pool can be used to manage multiple song generation tasks, and each song request is independently assigned a thread group to avoid resource competition between tasks.
[0072] Thus, the present invention has the following advantages through the above embodiments: 1) Asynchronous generation mechanism for cover and song, optimized generation time: time to return the first result is shortened to within 20 seconds (measured data); 2) Using a dual-threaded collaborative monitoring model, resource utilization is improved: GPU utilization is increased from 30% to over 75%; 3) Flexible resource allocation through thread pool, support for high concurrency scenarios, and enhanced concurrency capabilities: support for processing 3 song generation requests at the same time.
[0073] In a further embodiment of the present invention, the parallel processing-based AI song generation method further includes the step of implementing task status notifications using a message queue (e.g., RabbitMQ). RabbitMQ provides a message persistence mechanism that ensures that messages remain available after a service restart or crash.
[0074] Exemplary devices like Figure 4 As shown, an embodiment of the present invention provides an AI song generation device based on parallel processing, the device comprising: A song generation request acquisition module 310 is used to acquire a song generation request; A song generation main thread creation module 320 is used to create a song generation main thread according to a song generation request; The task assignment module 330 is used to control the song generation main thread to assign the cover generation task to the cover generation sub-thread and assign the song generation task to the song generation sub-thread; The asynchronous parallel generation control module 340 is used to control the cover generation sub-thread to generate a cover image according to the assigned cover generation task and control the song generation sub-thread to generate an audio file according to the assigned song generation task using an asynchronous parallel generation mechanism; The contract module 350 is used to control the synthesis and output of the cover image and audio file of the same song when it is detected that the cover image and audio file of the same song are generated; A dynamic thread pool construction module 360 is used to control the construction of a dynamic thread pool for managing multiple song generation tasks when the song generation request is a plurality of song generation requests, and to create an independent song generation main thread for each song generation request; The multi-song task allocation module 370 is used to independently allocate a thread group for each independent song generation main thread request, and each independent allocation thread group allocates the cover generation task to the cover generation sub-thread and the song generation task to the song generation sub-thread, as described above.
[0075] Based on the above embodiment, the present invention also provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 5 As shown. The intelligent terminal includes a processor, a memory, a network interface, a display screen, and a database connected via a system bus. The processor of the intelligent terminal is used to provide computing and control capabilities. The memory of the intelligent terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the intelligent terminal is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an AI song generation method based on parallel processing is implemented. The database of the intelligent terminal is used to store an AI song generation program based on parallel processing.
[0076] Those skilled in the art will understand that Figure 5 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the solution of the present invention and does not constitute a limitation on the smart terminal to which the solution of the present invention is applied. The specific smart terminal may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0077] In one embodiment, a smart terminal is provided, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include instructions for performing the following operations: Get the song generation request and create the song generation main thread according to the song generation request; Control the song generation main thread to assign the cover generation task to the cover generation sub-thread, and assign the song generation task to the song generation sub-thread; Adopting an asynchronous parallel generation mechanism, controlling the cover generation sub-thread to generate a cover image according to the assigned cover generation task; controlling the song generation sub-thread to generate an audio file according to the assigned song generation task; When it is detected that the cover image and audio file of the same song are generated, the cover image and audio file of the same song are controlled to be synthesized and output, as described above.
[0078] The steps of obtaining a song generation request and creating a song generation main thread according to the song generation request include: When the song generation request is a plurality of song generation requests, the control constructs a dynamic thread pool for managing the plurality of song generation tasks, and creates an independent song generation main thread for each song generation request.
[0079] The step of controlling the song generation main thread to assign the cover generation task to the cover generation sub-thread and assigning the song generation task to the song generation sub-thread includes: An independent thread group is assigned for each independent song generation main thread request, each independent assigned thread group assigns the cover generation task to the cover generation sub-thread, and assigns the song generation task to the song generation sub-thread.
[0080] The step of controlling the synthesis and output of the cover image and audio file of the same song when it is detected that the cover image and audio file of the same song are generated includes: When the cover images and audio files of multiple songs are merged and generated separately, the batch generation results are returned and output.
[0081] The step of synthesizing and outputting the cover image and audio file of the same song when it is detected that the generation of the cover image and audio file is completed includes: Monitor the status of each child thread through the future object, and trigger the retry mechanism when any task fails; When it is detected that the cover image and audio file of the same song have been generated, they are synthesized and output. Wherein, when it is detected that the cover image and audio file of the same song are generated, the step of controlling the synthesis and output of the cover image and audio file of the same song further includes: Use message queue to notify task status in real time.
[0082] Wherein, when the song generation request is a plurality of song generation requests, the steps of controlling and building a dynamic thread pool for managing the plurality of song generation tasks and creating an independent song generation main thread for each song generation request include: When the song generation request is a plurality of song generation requests, a dynamic thread pool is controlled to be constructed for managing the plurality of song generation tasks, namely, the first song generation task, the second song generation task to the Nth song generation task; And create an independent song generation main thread for each song generation request, namely the first song generation main thread corresponding to the first song generation task, and the second song generation to the Nth song generation tasks, as described above.
[0083] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the above-described method embodiments. Any reference to memory, storage, database, or other media used in the various embodiments provided herein may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).
[0084] In summary, the present invention provides an AI song generation method, device, intelligent terminal and storage medium based on parallel processing. The present invention provides a low-latency song generation method, which reduces the user waiting time from minutes to seconds through multi-threaded parallel processing. That is, the two parts of song generation: generating the cover image and generating the song are executed separately using different threads. This can speed up the AI song generation time, shortening the time to return the first result to within 20 seconds (measured data); and can improve resource utilization, GPU utilization from 30% to more than 75%; and the concurrency capability is enhanced: it supports processing 3 song generation requests at the same time.
Claims
1. An AI song generation method based on parallel processing, characterized in that: include: Get the song generation request and create the song generation main thread according to the song generation request; Control the song generation main thread to assign the cover generation task to the cover generation sub-thread, and assign the song generation task to the song generation sub-thread; Adopting an asynchronous parallel generation mechanism, controlling the cover generation sub-thread to generate a cover image according to the assigned cover generation task; controlling the song generation sub-thread to generate an audio file according to the assigned song generation task; When it is detected that the cover image and audio file of the same song are generated, the cover image and audio file of the same song are controlled to be synthesized and output.
2. The AI song generation method based on parallel processing according to claim 1 is characterized in that: The steps of obtaining a song generation request and creating a song generation main thread according to the song generation request include: When the song generation request is a plurality of song generation requests, the control constructs a dynamic thread pool for managing the plurality of song generation tasks, and creates an independent song generation main thread for each song generation request.
3. The AI song generation method based on parallel processing according to claim 2 is characterized in that: The step of controlling the song generation main thread to assign the cover generation task to the cover generation sub-thread and assigning the song generation task to the song generation sub-thread includes: An independent thread group is assigned for each independent song generation main thread request, each independent assigned thread group assigns the cover generation task to the cover generation sub-thread, and assigns the song generation task to the song generation sub-thread.
4. The AI song generation method based on parallel processing according to claim 1 is characterized in that: When it is detected that the cover image and audio file of the same song are generated, the step of controlling the synthesis and output of the cover image and audio file of the same song includes: When the cover images and audio files of multiple songs are merged and generated separately, the batch generation results are returned and output.
5. The AI song generation method based on parallel processing according to claim 1 is characterized in that: When it is detected that the cover image and audio file of the same song are generated, the steps of synthesizing and outputting the same song include: Monitor the status of each child thread through the future object, and trigger the retry mechanism when any task fails; When it is detected that the cover image and audio file of the same song have been generated, they are synthesized and output.
6. The AI song generation method based on parallel processing according to claim 1, characterized in that: When it is detected that the cover image and audio file of the same song are generated, the step of controlling the synthesis and output of the cover image and audio file of the same song further includes: Use message queue to notify task status in real time.
7. The AI song generation method based on parallel processing according to claim 2, characterized in that: When the song generation request is a plurality of song generation requests, the steps of controlling and building a dynamic thread pool for managing the plurality of song generation tasks and creating an independent song generation main thread for each song generation request include: When the song generation request is a plurality of song generation requests, a dynamic thread pool is controlled to be constructed for managing the plurality of song generation tasks, namely, the first song generation task, the second song generation task to the Nth song generation task; And create an independent song generation main thread for each song generation request, which are the first song generation main thread corresponding to the first song generation task and the second song generation to the Nth song generation tasks.
8. An AI song generation device based on parallel processing, characterized in that: The device comprises: A song generation request acquisition module is used to obtain a song generation request; A song generation main thread creation module is used to create a song generation main thread according to a song generation request; A task allocation module, used for controlling the song generation main thread to allocate the cover generation task to the cover generation sub-thread, and to allocate the song generation task to the song generation sub-thread; An asynchronous parallel generation control module is used to control the cover generation sub-thread to generate a cover image according to the assigned cover generation task; and to control the song generation sub-thread to generate an audio file according to the assigned song generation task; The contract module is used to control the synthesis and output of the cover image and audio file of the same song when it is detected that the cover image and audio file of the same song are generated; A dynamic thread pool construction module is used to control the construction of a dynamic thread pool for managing multiple song generation tasks when the song generation request is a plurality of song generation requests, and to create an independent song generation main thread for each song generation request; The multi-song task allocation module is used to independently allocate a thread group for each independent song generation main thread request, and each independent allocation thread group allocates the cover generation task to the cover generation sub-thread and the song generation task to the song generation sub-thread.
9. An intelligent terminal, characterized in that: The device comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, and the one or more programs include being used to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 7.