Anhypnia traditional Chinese medicine five-tone music generation method and system based on adversarial neural network, and medium
By combining adversarial neural networks with a knowledge base of traditional Chinese medicine music prescriptions, personalized sleep-aid music that conforms to the five-tone theory of traditional Chinese medicine is generated, which solves the problem of existing sleep-aid music products lacking personalization and medical guidance, and achieves more stable therapeutic effects.
Patent Information
- Application Number
- CN202511412975.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2026-01-02
AI Technical Summary
Existing sleep-aid music products lack personalization and medical guidance, and cannot effectively address the different causes of insomnia in different patients. The integration of traditional Chinese medicine's five-tone theory with artificial intelligence is insufficient, and there is a lack of a rigorous mapping mechanism between syndrome type, treatment principle, and music elements, resulting in unstable treatment effects.
Using an adversarial neural network-based approach combined with a TCM music prescription knowledge base, personalized music conforming to the TCM five-tone theory is generated through a multi-level mapping of syndrome type, pathogenesis, treatment principle, and musical elements. The adversarial neural network generator and discriminator are then used to accurately generate the music matrix and determine its authenticity.
It enables customized TCM five-tone therapy music based on different syndrome types, improving the correspondence and interpretability between music and TCM treatment principles, enhancing the authenticity and artistry of the generated music, and providing more targeted and stable treatment plans.
Smart Images

Figure CN121243580A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of neural network technology, and in particular to a method, system, and medium for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks. Background Technology
[0002] Insomnia is a prevalent sleep disorder in modern society. Long-term insomnia not only affects quality of life but can also trigger serious problems such as cardiovascular disease and depression. As a non-pharmacological intervention, music therapy has gained widespread attention due to its safety and lack of side effects. Currently, sleep-aid music products on the market are mainly implemented through apps, smart speakers, or wearable devices, forming three common technological approaches.
[0003] The first category is general-purpose sleep-aid music playback technology. Its basic approach involves providing users with a pre-set library of light music, white noise, or natural sounds, which users can then choose to play. This method is simple to operate but lacks personalization and medical guidance, offering little long-term benefit. The second category is music regulation technology based on physiological indicator feedback. By collecting parameters such as heart rate and EEG, it dynamically switches tracks according to universal rules, enhancing interactivity to some extent. However, it still fails to address the issue of differentiated causes of illness, and the numerous data collection devices make it inconvenient to use. The third category is music recommendation technology that incorporates the Five Elements theory of Traditional Chinese Medicine, simply categorizing music into five elements or five musical notes for users to choose from. However, this method remains at the level of label-based recommendation, lacking a rigorous mapping mechanism between syndrome type, treatment principle, and music elements. It cannot handle complex complex syndromes, and the integration of Traditional Chinese Medicine theory and artificial intelligence is insufficient. Its application remains at the conceptual level, lacking scientific quantitative model support. Summary of the Invention
[0004] Based on the shortcomings of the existing technology, this invention provides a method, device, and medium for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks. It enables differentiated customization according to different syndrome information, thereby providing insomnia patients with more targeted and stable traditional Chinese medicine five-tone therapeutic music.
[0005] To address the aforementioned technical problems, the first aspect of this invention discloses a method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks, comprising: It receives information on the TCM syndrome type corresponding to insomnia input by the user, and generates the corresponding music prescription vector based on the TCM music prescription knowledge base mapped by preset elements. The music prescription vector is input as a conditional vector into the adversarial neural network, and the adversarial neural network outputs the music matrix corresponding to the music prescription vector. The music matrix is rendered to output traditional Chinese medicine five-tone therapy music.
[0006] In some implementations, the preset elements include syndrome type, pathogenesis, treatment principle, and music element; The TCM music prescription knowledge base includes a syndrome type-pathogenesis-treatment principle layer, a treatment principle-music element mapping layer, and a parameter quantification and output layer. The syndrome type-pathogenesis-treatment principle layer is used to store TCM syndrome types and corresponding pathogenesis data, as well as treatment principle data corresponding to the pathogenesis for insomnia. The rule-music element mapping layer stores the mapping rules corresponding to the rule and the music element, and generates music composition elements based on the mapping rules; the parameter quantization and output layer transforms the music composition elements into music prescription vectors containing the music composition elements.
[0007] In some implementations, the adversarial neural network includes a generator and a discriminator; the generator generates a music matrix that conforms to the principles of traditional Chinese medicine in real time based on the music prescription vector and the random noise vector; the discriminator simultaneously judges the authenticity of the music matrix and its matching degree with the music prescription vector; the generator weights are updated based on the discriminator feedback until a music matrix that satisfies the music prescription vector is output; the generator weights are updated based on the discriminator feedback until a music matrix that satisfies the music prescription vector is output.
[0008] In some implementations, the music prescription vector includes pitch parameters, rhythm parameters, melody parameters, timbre parameters, and dynamic parameters.
[0009] In some implementations, the music matrix is rendered to output traditional Chinese medicine five-tone therapy music, including: Traverse the music matrix according to the time step, identify all note events in the music matrix, and calculate the note duration; Generate a MIDI object by combining the beat information of the rhythm parameter in the music prescription vector; Based on the timbre parameters and dynamic parameters defined in the music prescription vector, the timbre categories of the lead and accompaniment are obtained. The timbre categories are converted into corresponding timbre library files and instrument numbers through a timbre mapping table. The MIDI object is then waveform rendered to output traditional Chinese medicine five-tone therapy music.
[0010] In some implementations, the system receives information from the user regarding the TCM syndrome type corresponding to insomnia, including: A pre-defined structured TCM syndrome database is provided, wherein each entry in the TCM syndrome database includes the Chinese name of the syndrome, a unique identifier, the full pinyin spelling, and the pinyin abbreviation; Obtain the keywords corresponding to insomnia input by the user, and preprocess the keywords to obtain the query string; Match the entry's certificate type Chinese name, unique identifier, full pinyin or pinyin abbreviation based on the query string; When a match is successful, the entry is set as a candidate result; a recommendation list containing the candidate results is generated in the user interaction screen; Obtain the candidate results selected by the user from the recommendation list, and convert the candidate results into TCM syndrome information.
[0011] In some implementations, the loss function of the generator includes a tonic loss function, a rhythm loss function, and an instrument category loss function; the tonic loss function and the instrument category loss function use classification cross-entropy loss; the rhythm loss function uses mean squared error loss.
[0012] In some implementations, the pitch parameters include a tonic pitch category, a scale mask, and a pitch weight distribution, corresponding to integers between 0 and 11 for MIDI pitch category values; the scale mask uses a 12-bit binary vector to represent the allowed pitches; and the pitch weight distribution is used to limit the probability of each pitch appearing in the melody. The rhythm parameters include the tempo range, the rhythm complexity scalar, which is expressed in beats per minute and has a tempo range of 30 to 120; and the rhythm complexity scalar, which has a value range of 0 to 1 and is used to indicate the complexity of the rhythm pattern. Melodic parameters include the direction of the melody and the range of intervals. The direction of the melody ranges from -1 to 1 and is used to characterize the overall upward or downward trend of the melody. The range of intervals is used to limit the pitch difference between adjacent notes, and the unit is degrees. The timbre parameters include the main instrument category and the accompaniment instrument category, which correspond to preset instrument tags and are converted into specific timbre library files or MIDI instrument numbers through a mapping table; The dynamic parameters include the average dynamic value and the variance of dynamic variation. The average dynamic value ranges from 0 to 127. The variance of dynamic variation is used to characterize the amplitude of the loudness fluctuations of music during playback.
[0013] Secondly, a traditional Chinese medicine five-tone music generation system for insomnia based on adversarial neural networks is disclosed, including: The music prescription vector generation module receives TCM syndrome information input by the user and generates corresponding music prescription vectors based on a TCM music prescription knowledge base mapped by preset elements. The adversarial neural network processing module inputs the music prescription vector as a conditional vector into the adversarial neural network, and the adversarial neural network outputs the music matrix corresponding to the music prescription vector. The Traditional Chinese Medicine Five-Tone Music Generation Module renders the music matrix and outputs Traditional Chinese Medicine Five-Tone Therapeutic Music.
[0014] Thirdly, a computer storage medium is disclosed, on which a computer program is stored, which, when executed by a processor, implements the method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks as described in any of the above.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention provides a method, system, and medium for generating traditional Chinese medicine (TCM) five-tone music for insomnia based on adversarial neural networks (ANNs). By introducing an ANN and combining it with a knowledge base, the user-inputted TCM syndrome information is transformed into quantifiable music prescription vectors based on TCM diagnostic logic, thus ensuring consistency between the generated music and the treatment prescription. Compared to existing methods that rely solely on music library recommendations or general neural network generation, this invention can precisely constrain the music based on the prescription vector in each generation, outputting personalized music that conforms to the five-tone theory, effectively improving the correspondence and interpretability between the music and TCM treatment principles. Simultaneously, the conditional constraint mechanism of the ANN enhances the authenticity and artistry of the generated TCM five-tone therapeutic music. Differential customization is achieved according to different syndrome types, thus providing insomnia patients with more targeted and stable therapeutic music. Attached Figure Description
[0016] Figure 1 A flowchart illustrating a method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks, provided by this invention; Figure 2 This is a schematic diagram of the user interface in a method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks provided by the present invention. Figure 3 This is a flowchart illustrating step S1 of the method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks provided by the present invention. Figure 4 This is a schematic diagram of the adversarial neural network structure in the method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks provided by the present invention. Figure 5 This is a flowchart illustrating step S3 of the method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks provided by the present invention. Detailed Implementation
[0017] To better understand and implement this invention, the technical solutions in the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0018] The terms “comprising” and “having” and any variations thereof in this invention are intended to cover non-exclusive inclusion, for example, a process, method, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to such processes, methods, products or devices.
[0019] The embodiments of the present invention disclose a method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks, which can achieve differentiated customization according to different syndrome types, thereby providing more targeted and more stable therapeutic music for insomnia patients.
[0020] like Figure 1 As shown, this method includes: Step S1: Receive the TCM syndrome type information corresponding to insomnia input by the user, and generate the corresponding music prescription vector based on the preset element mapping TCM music prescription knowledge base.
[0021] This step transforms abstract Traditional Chinese Medicine (TCM) concepts into concrete, quantifiable music generation instructions. It systematically converts complex medical concepts such as "heart-kidney disharmony" into music prescription vectors—precise parameter sets containing multiple dimensions such as pitch, rhythm, and timbre. Users can then use methods such as... Figure 2 The interactive page for inputting syndrome types shows the TCM syndrome type information corresponding to your insomnia. Specifically, for example... Figure 3 As shown, the system receives user input regarding the TCM syndrome type corresponding to insomnia, including: Step S11: Preset a structured TCM syndrome type database. Each entry in the TCM syndrome type database includes the Chinese name of the syndrome type, a unique identifier, the full pinyin spelling, and the pinyin abbreviation. Step S12: Obtain the keywords corresponding to insomnia input by the user, and preprocess the keywords to obtain the query string; Step S13: Match the Chinese name of the certificate type, unique identifier, full pinyin or pinyin abbreviation of the entry according to the query string; Step S14: When a match is successful, set the item as a candidate result; generate a recommendation list containing the candidate results in the user interaction screen; Step S15: Obtain the candidate results selected by the user in the recommendation list, and convert the candidate results into TCM syndrome information.
[0022] To enhance professionalism and ease of use, and to address the challenges of numerous and complex TCM syndrome types and their names, an intelligent text-matching-based syndrome type input and encoding method is used to replace the traditional fixed list selection. A pre-stored structured TCM syndrome type database is established based on the national standard "Clinical Terminology of Traditional Chinese Medicine Part 2: Syndromes" (GB / T 16751.2-2021). This database is in the form of a database or structured data structure, containing multiple syndrome type entries, each entry including at least the following fields: 1. Name field, used to record the standard Chinese name of the certificate type, such as "heart and kidney disharmony"; 2. Unique identifier, used to record a unique standardized English ID internally, such as "Syndrome_HeartKidney_Disharmony". This identifier serves as key data for subsequent module calls; 3. Pinyin field, used to store the full pinyin of the certificate name, such as "xinshenbujiao"; 4. Abbreviation field, used to store the initial letter abbreviation of the certificate type name in pinyin, such as "xsbj".
[0023] In practical use, users, such as TCM practitioners or professionals, can input keywords related to their target syndrome through text input boxes on the interactive interface. This input process is completed via keyboard or interactive screen. The background system listens for events in the input boxes in real time and automatically preprocesses the input string to form a query string after receiving the input content.
[0024] Based on the query string, a multi-dimensional matching process is performed, traversing all entries in the syndrome type database and determining whether the input query string matches the name, pinyin, or abbreviation fields of the entry. If any condition is met, the entry is set as a candidate result and added to the recommendation list. This matching process can simulate a doctor's search for syndrome types in memory, quickly locating the target syndrome type whether using Chinese characters, pinyin, or abbreviations. A drop-down recommendation list is dynamically generated in the user interface, displaying all matched candidate syndrome types. Users can directly select TCM syndrome type information from the recommendation list. After the user completes the selection, the standard name of the selected TCM syndrome type information is automatically filled into the input box, providing clear visual confirmation. At the same time, the unique identifier corresponding to the syndrome type entry (such as "Syndrome_Heart_Kidney_Disharmony") is extracted and used as input data for subsequent module calls, thereby realizing the conversion between syndrome type input and standardized coding.
[0025] During the input process, users do not need to enter the full name of the certificate type. Instead, they can enter core keywords, initials, fragments of pinyin, or common abbreviations to trigger the intelligent matching system for multi-dimensional matching. The user interface generates a candidate list sorted by matching degree in real time, allowing users to directly select the target certificate type. This reduces input steps and, through collaborative matching, lowers the risk of matching failures due to users' unfamiliarity with certificate names or input errors, thereby improving the accuracy of certificate name matching.
[0026] To address the shortcomings of traditional music generation methods, such as cumbersome and inefficient steps for identifying TCM syndromes, or the tendency for text input errors due to complex terminology leading to matching failures, this embodiment shortens the input path and improves efficiency by employing a multi-dimensional intelligent matching and candidate recommendation mechanism based on keywords, pinyin, and abbreviations. Multimodal matching rules cover possible user input habits, and candidate recommendations reduce the input error rate, ensuring accurate input of syndrome information and providing reliable initial data support for subsequent music prescription vector generation and treatment initiation.
[0027] After obtaining the user's TCM syndrome information, a corresponding music prescription vector is generated based on a preset element mapping TCM music prescription knowledge base. The TCM Music Prescription Knowledge Base (TMP-KB) is not a simple lookup table, but a multi-level mapping model embedding TCM pathology, the Five Elements theory, the Five Tones theory, and music psychoacoustics rules. It includes data for storing TCM syndromes and their corresponding pathogenesis, treatment principles corresponding to the pathogenesis, and mapping rules that correspond the treatment principles to music elements. When receiving TCM syndrome information, the knowledge base sequentially retrieves the corresponding pathogenesis and treatment principle, and generates a music prescription vector containing the music element parameters based on the mapping rules.
[0028] Specifically, this application divides the internal logical structure of the TCM music prescription knowledge base into three layers to achieve a layer-by-layer mapping from TCM syndrome types to machine-readable music parameters. The first layer is the syndrome type-pathogenesis-treatment principle layer. It receives the syndrome type identifier (Syndrome_ID) corresponding to the input TCM syndrome type information, such as "Syndrome_Heart_Kidney_Disharmony", and automatically retrieves the core pathogenesis and standard treatment principle corresponding to that syndrome type. Taking heart-kidney disharmony as an example, the corresponding entry is retrieved from the knowledge base, yielding the pathogenesis of kidney water deficiency in the lower body and heart fire excess in the upper body, resulting in water-fire imbalance, and the corresponding treatment principle of nourishing water and clearing the heart, harmonizing the heart and kidneys. For the liver qi stagnation transforming into fire syndrome, the corresponding output pathogenesis is liver qi stagnation, qi stagnation transforming into fire, disturbing the mind, and the treatment principle is soothing the liver and relieving stagnation, clearing liver fire. Through this mapping layer, syndrome type information is standardized and transformed into treatment principle expressions, providing a foundation for the subsequent generation of music elements.
[0029] The second layer is the Treatment Principles-Musical Element Mapping Layer. It receives the treatment principles from the previous layer and, according to predefined mapping rules, decomposes the abstract TCM treatment principles into specific musical elements. For example, the "Nourishing Water and Clearing the Heart" treatment principle will be decomposed into two parts: Nourishing Water and Clearing the Heart. Nourishing Water corresponds to Water in the Five Elements theory, and is mapped to a Yu tone as the main melody, a descending overall melody, a soothing and tranquil rhythm, and instruments with a soft and calm timbre, such as the low register of the guqin, the dongxiao, or the cello. Clearing the Heart corresponds to Fire in the Five Elements theory, and based on the principles of mutual restraint and generation, it is mapped to a scale that avoids the Zhi tone, appropriately introduces the Gong tone as a secondary melody, and generates a harmonious and ethereal harmonic texture to reflect the effect of clearing the heart fire. Communicating the Heart and Kidneys corresponds to the balanced relationship of Water and Fire, and is mapped to an overall soft dynamic with subtle and smooth fluctuations to simulate the state of energy flow and exchange. Through this mapping layer, the abstract treatment principles are transformed into musical elements such as melodic direction, rhythmic setting, timbre selection, harmonic type, and dynamic control.
[0030] The third layer is the parameter quantization and output layer. It further transforms the musical element descriptions obtained from the previous layer into machine-readable numerical values or category labels, forming a multi-dimensional music prescription vector (Vp). In this process, elements such as tonic key, tempo range, melodic direction, harmonic type, timbre category, and dynamic parameters are quantized into explicit parameter vectors, enabling the musical features corresponding to the TCM treatment principles to be accessed by the subsequent adversarial neural network in structured data form.
[0031] The Traditional Chinese Medicine (TCM) music prescription knowledge base constructs a complete logical reasoning chain from syndrome differentiation to pathogenesis, treatment principles, and finally musical elements through a layered design, clearly presenting the transformation process from diagnostic information to pathological analysis, treatment principles, and specific treatment methods. This embodiment addresses the shortcomings of traditional music generation methods, such as the lack of a mapping mechanism or a simplistic mapping logic. Through a three-layered structure of syndrome differentiation-pathogenesis-treatment principles-musical elements, the generation process of music prescriptions possesses a clear theoretical basis and rigorous reasoning logic, while maintaining consistency with the TCM theoretical system. For example, in the case of liver-related insomnia, this invention distinguishes between two different syndromes: "liver fire rising" and "liver blood deficiency," and generates distinctly different musical styles based on the corresponding treatment principles: "clearing liver fire" and "nourishing liver blood."
[0032] Furthermore, the hierarchical structure of the TCM music prescription knowledge base makes the decision-making process for music generation traceable, and can clearly define the medical basis for the elements such as tone, rhythm, and timbre used in generating music, providing a scientific basis for clinical verification, effect evaluation, and model optimization.
[0033] The music prescription vector includes at least pitch parameters, rhythm parameters, melody parameters, timbre parameters, and dynamic parameters. The pitch parameters include the tonic pitch category, scale mask, and pitch weight distribution, corresponding to MIDI pitch category values between 0 and 11. The scale mask uses a 12-bit binary vector to represent allowed pitches. The pitch weight distribution limits the probability of each pitch appearing in the melody. The rhythm parameters include a tempo range, a rhythm complexity scalar (expressed in beats per minute, with a tempo range of 30 to 120), and a rhythm complexity scalar (range 0 to 1) to represent the complexity of the rhythmic pattern. The melody parameters include the melody direction and interval span range (range -1 to 1), representing the overall ascending or descending trend of the melody. The interval span range limits the pitch difference between adjacent notes, in degrees. The timbre parameters include the lead instrument category and the accompaniment instrument category, corresponding to preset instrument tags and converted to specific timbre library files or MIDI instrument numbers via a mapping table. The dynamic parameters include the average dynamic value and the variance of dynamic variation, which range from 0 to 127; and the variance of dynamic variation is used to characterize the amplitude of the loudness fluctuations of the music during playback.
[0034] By coordinating the configuration of five core parameter dimensions of the music prescription, a comprehensive music control framework is constructed to achieve refined, multi-dimensional, and collaborative control of the generated music. These five parameter dimensions do not function independently but rather form a collaborative control mechanism through the adjustment of their interrelationships: setting the pitch dimension lays the foundation for the music's basic mode; configuring the rhythm dimension determines the music's temporal organization characteristics; planning the melody dimension guides the development path of the musical theme; selecting the timbre dimension endows the music with a specific auditory texture; and adjusting the dynamic dimension enables dynamic changes in the music's intensity. Each dimension parameter is collaboratively adjusted through preset correlation rules to jointly shape the overall form of the generated music.
[0035] Traditional music adjustment mechanisms often only adjust a single dimension such as speed or volume, which is insufficient to meet the requirements of the Five Tones Theory in Traditional Chinese Medicine for the synergistic effect of multiple elements in music form. This embodiment, through the synergistic control of five core parameter dimensions, and the synergistic effect of pitch, rhythm, melody, timbre, and dynamics, enables the generated music to form an organic whole in terms of mode, meter, theme development, timbre texture, and intensity changes. This enhances the richness and delicacy of the generated music, strengthens its adaptability to the complex connotations of the Five Tones Theory in Traditional Chinese Medicine, more accurately matches the multi-dimensional requirements of music therapy in TCM syndrome differentiation and treatment, and improves the pertinence and reliability of insomnia treatment.
[0036] The specific generation rules are as follows: 1. Pitch parameter generation rules: First, based on the correspondence between the five tones and the five elements, the tonic category is determined and mapped to a MIDI pitch category value. For example, Gong, Shang, Jiao, Zhi, and Yu correspond to the pitch categories C, D, E, G, and A, respectively. A twelve-dimensional scale mask vector is constructed to indicate the notes allowed in the current scale, and the control of disabled or weakened notes is achieved by masking specific pitches. In addition, a weight distribution for each note is generated to set the probability of each pitch appearing in the melody, reflecting the principle that the tonic is dominant, the consonant is secondary, and disabled notes do not appear.
[0037] 2. Rhythm parameter generation rules: Based on the emotional attributes of the governing principles, such as peaceful, soothing, or exciting, the tempo range is determined and expressed in beats per minute (BPM). Simultaneously, the rhythmic complexity is set to a scalar value from 0 to 1, where 0 represents a completely simple long-duration note and 1 represents a highly complex multi-layered rhythm; an appropriate range can be selected according to the needs of the governing principles.
[0038] 3. Melody parameter generation rules: The direction of the melody is determined according to the principles of governance, and represented by values from -1 to 1, where -1 represents a pure descending melody, 1 represents a pure ascending melody, and 0 represents an overall smooth melody. The intervals between adjacent notes in the melody are limited to a certain range, such as from a degree to several degrees, to control the stability or liveliness of the melody.
[0039] 4. Timbre parameter generation rules: The instrument category tags for lead and accompaniment instruments are extracted from the music prescription, and then mapped to specific timbre library file names or MIDI instrument numbers using a timbre mapping table. Lead instruments are typically used to carry the melody line, while accompaniment instruments are used to create background atmosphere, thus reflecting the tonal requirements.
[0040] 5. Dynamic parameter generation rules: Set the average velocity value of the music, using a MIDI velocity range of 0 to 127 to represent the overall volume. Also, set the variance of the velocity variation according to rules to control the amplitude of the music's dynamic range during playback. A smaller variance indicates a smoother change, while a larger variance indicates more pronounced velocity fluctuations.
[0041] By applying the above rules, abstract musical elements can be transformed into specific numerical parameters, generating a multi-dimensional musical prescription vector Vp. This prescription vector serves as the conditional input to the adversarial neural network, ensuring that the generated music maintains consistency with the logic of traditional Chinese medicine treatment principles in terms of pitch, rhythm, melody, timbre, and dynamics.
[0042] Taking the syndrome type of "disharmony between the heart and kidney" (Syndrome_ID = "HKD") as an example, the complete quantification process of music prescription generation is demonstrated. Processing the input traditional Chinese medicine syndrome information, first, at the syndrome-pathogenesis-treatment principle layer, the input syndrome identifier "HKD" is received, and the corresponding pathogenesis and treatment principle are retrieved from the knowledge base. The pathogenesis of this syndrome is "kidney water deficiency in the lower part, heart fire hyperactivity in the upper part, and the failure of water and fire to interact properly", and the treatment principle is "nourish water to clear the heart and promote the interaction between the heart and kidney". This treatment principle requires clearing heart fire by enhancing the nourishing effect of water and achieving the balance and coordination between the heart and kidney.
[0043] At the treatment principle - music element mapping layer, the above treatment principle is transformed into specific music composition elements. Among them, "nourish water" corresponds to "water" in the five elements, and is mapped to the yu pitch as the main pitch, the overall melody descends, the rhythm is slow and peaceful, and the timbre is soft and quiet instruments such as guqin, dongxiao or cello; "clear the heart" corresponds to the heart belonging to fire. According to the principles of mutual generation and restriction of the five elements, it is mapped to reducing the use of the zhi pitch, moderately introducing the gong pitch as an auxiliary pitch, and maintaining a harmonious and ethereal effect in the harmony structure to play the role of clearing heart fire; "promote the interaction between the heart and kidney" is mapped to the balance of the overall music dynamics, manifested as a gentle volume with a weak and smooth undulation to simulate the dynamic balance state of "the interaction of water and fire".
[0044] At the parameter quantification and output layer, the above music elements are further quantified into the music prescription vector Vp, which includes the following parameters: In terms of pitch parameters, the main pitch category is determined to be the yu pitch, corresponding to the MIDI pitch category 9, that is, note A, with C = 0, C# = 1... B = 11. In terms of scale control, a 12-dimensional binary vector is generated to indicate the allowed pitches. Among them, C, D, E, and A are allowed to be used, while the zhi pitch G is blocked, thus forming a more precise five-tone control. Further, the probability distribution of the appearance of each pitch is set. The weight of the yu pitch A is 0.6, the weight of the gong pitch C is 0.25, the weights of the shang pitch D and the jue pitch E are 0.1 and 0.05 respectively, and the weight of the zhi pitch G is 0, thus forcing the melody to be mainly based on the yu pitch and supplemented by the gong pitch, and avoiding using the zhi pitch.
[0045] In terms of rhythm parameters, the set speed range is 45 to 60 beats per minute, corresponding to the speed category of Largo; the rhythm complexity is set to 0.2, indicating that mostly long-duration notes such as whole notes and half notes are used, and less complex rhythms such as syncopation and sixteenth notes are used, thus ensuring the overall slow and peaceful state.
[0046] In terms of melodic parameters, the melodic trend is defined as -0.7, which is within the range of -1 to 1. Here, -1 represents a pure downward trend, 1 represents a pure upward trend, and -0.7 indicates that the melody as a whole shows an obvious downward trend, in line with the characteristic of "Water moistens and descends" corresponding to "disharmony between the heart and the kidney". At the same time, the interval span between adjacent notes is limited to between 1 and 5 degrees, avoiding excessive jumps and creating a smooth and flowing melody.
[0047] In terms of timbre and dynamic parameters, the main instrument category is set to plucked string instruments in the low register, such as the guqin, and the accompanying or background instrument category is set to sustained wind instruments, such as the dongxiao. In terms of dynamic parameters, the average intensity is set to 40 (the MIDI intensity value range is 0–127, and 40 belongs to the relatively weak pp–p interval), and the overall volume is gentle; the variance of intensity change is set to 0.1, indicating that the change between strong and weak is very gentle and there are no abrupt contrasts.
[0048] Through the above generation rules, the qualitative descriptions of soothing in traditional Chinese medicine theory are quantitatively corresponded to a combination of parameters with a BPM range of 40 - 60, a rhythm complexity coefficient ≤ 0.5, and an interval jump threshold ≤ 3 semitones; the qualitative description of calm is quantitatively corresponded to a combination of parameters with a strength value range of 20 - 40, a weight of the pitch level in the low register in the scale mask ≥ 0.8, and a rhythm complexity coefficient ≤ 0.3; the qualitative description of exciting is quantitatively corresponded to a combination of parameters with a BPM range of 100 - 120, a strength value range of 80 - 100, and an interval jump threshold ≤ 7 semitones. The quantitative parameters are associated with the qualitative characteristics in traditional Chinese medicine music theory through a preset mapping rule, forming digital instructions that can be directly input into the adversarial neural network.
[0049] Aiming at the defect that the application of traditional Chinese medicine music theory stays at the conceptual level, resulting in that traditional Chinese medicine theory cannot be directly parsed and executed by AI models, and the treatment plan is difficult to be standardized, replicated, and quantitatively evaluated, this application constructs a standardized digital model of traditional Chinese medicine music theory through the quantitative definition of music treatment vector parameters. The five musical notes of jue, zhi, gong, shang, and yu in the five - tone theory are specifically quantified into a combination of parameters such as the main tone category, where jue corresponds to the main tone of E major, the scale mask of jue corresponds to the pentatonic scale mask, and the weight of the jue pitch level corresponds to a weight of the jue pitch level ≥ 0.7; the association between the five emotions and music emotions is quantified into a combination of parameters such as the BPM range, where fear corresponds to a BPM of 50 - 70, the rhythm complexity coefficient, where worry corresponds to ≤ 0.4, and the dynamic parameter, where joy corresponds to a strength value range of 60 - 90. This makes traditional Chinese medicine music theory transform from an abstract concept into computable and verifiable engineering parameters, providing precise digital constraints for the adversarial neural network to generate music in line with traditional Chinese medicine theory, and enabling the efficacy evaluation of traditional Chinese medicine music therapy to be achieved through parameter adjustment and result data comparison.
[0050] Through the above quantitative processing, a music prescription vector Vp is finally generated, containing multi-dimensional parameters such as pitch, rhythm, melody, timbre, and dynamics. This provides standardized input for subsequent calls to the adversarial neural network, enabling the generation of personalized music that conforms to the treatment principles of the "heart-kidney disharmony" syndrome. Unlike the traditional "one-size-fits-all" approach of providing generic light music or white noise to all users, which often only addresses symptoms and not the underlying cause, this step delves into the "syndrome" level, directly targeting the fundamental pathogenesis of insomnia, such as "liver stagnation transforming into fire" or "heart and spleen deficiency." This allows music therapy to intervene at the root, theoretically resulting in a more profound and lasting effect. This step achieves true personalized customization. The music generation is no longer based on vague user preferences but directly stems from professional medical diagnoses of TCM syndromes, ensuring targeted treatment. Compared to the simple five-tone tagging recommendation in traditional methods, this step uses a rigorous knowledge base mapping to fully integrate the syndrome differentiation logic of syndrome type-pathogenesis-treatment principle into the AI model input, reflecting the essence of TCM "syndrome differentiation and treatment" and realizing the deep and structured application of TCM theory, far exceeding simple tag matching, and ensuring the medical consistency and interpretability of the generated music.
[0051] Step S2: Input the music prescription vector as a conditional vector into the adversarial neural network, and the adversarial neural network outputs the music matrix corresponding to the music prescription vector.
[0052] The multiple parameters in the music prescription vector Vp are normalized and scaled to a fixed range, such as 0 to 1 or -1 to 1, to avoid the scale differences of different parameters affecting model training. All encoded and embedded parameter vectors are concatenated to form a single, flattened, high-dimensional conditional vector c.
[0053] For example, the music prescription vector Vp contains: primary_pitch_class=9 (class, vocabulary 12) -> after embedding, it becomes a 32-dimensional vector. instrument_class="Guqin" (category, vocabulary size 50) -> after embedding, it becomes a 64-dimensional vector. tempo_bpm=52 (value, range 30-180) -> after normalization, it becomes (52-30) / (180-30)=0.146 melody_contour=-0.7(value, range -1 to 1) -> already within range, no processing required. The final condition vector c will have a dimension of 32 + 64 + 1 + 1 = 98.
[0054] In this application, as Figure 4As shown, the adversarial neural network employs a Conditional Generative Adversarial Network (cGAN). In this embodiment, the adversarial neural network is named "Five-tone Conditional Music GAN (FCM-GAN)". The Five-tone Conditional Music GAN follows the standard GAN framework, comprising two competing neural networks: a generator (G) and a discriminator (D).
[0055] The random noise vector and the music prescription vector are used as inputs to the generator. The random noise vector z (LatentVector) is a 100-dimensional vector following a standard normal distribution. The condition vector c (Condition Vector) is the music prescription vector Vp generated in step S1. The music prescription vector and the random noise vector are concatenated and fused as the initial input to the network. The generator network adopts a transposed convolutional neural network structure. This network takes the low-dimensional condition vector as input and gradually expands the feature dimension through multiple layers of transposed convolutions, finally outputting a high-dimensional music matrix Xfake. This two-dimensional matrix is represented in the form of a piano roll, where the row index corresponds to the time step, the column index corresponds to the pitch dimension, and the values of the matrix elements represent the existence of a note at the corresponding time step and pitch position, as well as its corresponding dynamic range.
[0056] The discriminator employs a convolutional neural network (CNN) structure to simultaneously perform authenticity and conditional matching assessments. The discriminator's input consists of two parts: a music matrix X, which can be a generated music matrix Xfake or a real sample; and a conditional vector c corresponding to the music matrix, indicating the creative requirements upon which the music generation was based. During operation, the discriminator first extracts features from the input music matrix using a CNN and then combines this with the features of the conditional vector c for joint representation. In the output layer, the discriminator uses a multi-task output structure instead of a single true / false judgment. This includes authenticity and conditional matching assessments. Authenticity assessment uses a sigmoid-activated output unit with a value ranging from 0 to 1, representing the probability that the input music matrix belongs to a real sample. Conditional matching assessment sets up a corresponding output layer based on the specific content of the conditional vector c. For example, if the conditional vector contains a tonic tone category, a Softmax output layer is set up to predict the tonic tone category; if the conditional vector contains a tempo range, a regression output layer is set up to predict the BPM value of the music. By comparing the discriminator's prediction with the input conditional vector c, the conditional loss can be calculated. This loss measures the consistency between the input music and the conditional requirements and is fed back into the network parameter updates during training.
[0057] The discriminator's dual judgment task forms a collaborative constraint on the generator, enabling the generator to improve the realism of the generated music during training and generation, so as to imitate the complex structure and artistic expression of real music. It also ensures the accurate matching of the generated music with the music prescription vector, so as to meet the requirements of the TCM treatment principle for the core elements.
[0058] To address the shortcomings of traditional conditional generative adversarial networks (GANs), where the discriminator focuses solely on the macroscopic matching degree between the generated content and the conditional vector, potentially leading to generated music that, while conforming to the conditional constraints, lacks the naturalness and artistry of authentic music, or possesses naturalness but whose core elements deviate from the conditional limits, this embodiment constructs a stronger constraint mechanism through the discriminator's dual judgment function. During the generator's learning process, the discriminator's judgment on authenticity ensures that the generated music possesses fluency and artistic quality comparable to authentic music, while the judgment on matching degree ensures that the core elements of the generated music strictly adhere to the limitations of the music prescription vector based on traditional Chinese medicine treatment principles. This ensures that the generated therapeutic music, while possessing high-quality artistic expression, always meets the requirements of medical treatment effectiveness and safety, effectively solving the technical problem of the disconnect between AI-generated music quality and medical requirements.
[0059] During training, the discriminator's loss function includes a tonic pitch loss function, a rhythm loss function, and an instrument category loss function. The tonic pitch loss function and the instrument category loss function employ classification cross-entropy loss; the rhythm loss function employs mean squared error loss. The tonic pitch loss function L_pitch ensures that the tonic pitch of the music matches the pitch parameters specified in the music prescription vector. This loss function is calculated using classification cross-entropy. Specifically, when the prescription requires the tonic pitch to be a yu tone, this pitch is encoded as a 12-dimensional one-hot vector. The discriminator generates 12 probability values in the Softmax output layer, corresponding to 12 pitch categories. By comparing the predicted probability distribution with the target one-hot vector, the cross-entropy loss value is obtained, which serves as Lpitch.
[0060] Regarding rhythm constraints, a rhythm loss function, Ltempo, is defined to ensure that the tempo of the generated music closely matches the rhythm specified in the prescription. This loss function is calculated using mean squared error. Specifically, the tempo in the music prescription vector is given numerically, and the discriminator predicts the rhythm of the input music to obtain a corresponding BPM value. Ltempo is obtained by calculating the squared difference between the predicted value and the target value.
[0061] Regarding timbre constraints, a linstrument loss function is used to ensure that the main timbre of the generated music matches the timbre parameters specified in the prescription. This loss function is also calculated using the classification cross-entropy method. If the instrument library contains 50 instruments, the instrument categories specified in the prescription are encoded as a 50-dimensional one-hot vector. The discriminator predicts the instrument categories in the softmax output layer, obtaining the corresponding probability distribution. The linstrument is obtained by comparing the predicted probability distribution with the target vector.
[0062] During training, the generator's total loss function LossG consists of several parts, including the adversarial loss Loss. adv And a weighted combination of the losses from the three constraints mentioned above. The calculation formula is:
[0063] in, w 1 、w 2 、w3 represents the loss weight, used to balance the contributions of different constraints during training. Through the synergistic effect of the above multi-objective loss functions, the quantitative definition and precise optimization of the matching degree between the generator's output music and the music prescription vector are achieved: the multi-objective loss functions transform the matching requirements of core parameters such as tonic pitch, rhythm, and instrument category in the music prescription vector into calculable mathematical indicators. Among them, the first loss function quantifies the tonic pitch matching deviation through the difference in category probability distribution, the second loss function quantifies the rhythm feature matching deviation through the difference in continuous numerical values, and the third loss function quantifies the instrument category matching deviation through the difference in category prediction confidence. The output results of each loss function are weighted and summed to form the total loss value, which serves as the optimization target for updating the generator parameters, enabling the generator to make targeted corrections for the deviations of different core parameters during training.
[0064] To address the shortcomings of traditional general AI music generation models, which often employ single or ambiguous loss functions, making it difficult for generators to precisely control the matching degree between output content and preset conditions, this application implements a multi-objective optimization framework by configuring independent loss functions for each core music parameter. This achieves refined quantification and targeted penalty for multi-dimensional parameter matching deviations in the generated music. When the generator's output pitch deviates from the range defined by the music prescription vector, the first loss function value is significantly increased to drive parameter correction. When rhythmic features exceed the defined numerical range, the second loss function forces the generator to adjust its rhythm generation logic through numerical deviation feedback. When the instrument category does not match the prescription requirements, the third loss function strengthens the matching constraint on therapeutic instrument categories through a focus loss mechanism. The collaborative optimization of these multi-objective loss functions ensures that the generator always uses the core parameters defined by the music prescription vector as convergence targets during training. This ensures that the final generated music highly conforms to the prescription requirements in key dimensions such as pitch, rhythm, and instrument category, providing an underlying algorithmic guarantee for precise control of the generated content.
[0065] In the specific calculation process, the generator first generates a music matrix X_fake based on the condition vector c, and inputs it along with the condition vector into the discriminator. The discriminator analyzes the music matrix X_fake, and the output includes tonic pitch prediction, rhythm prediction, and instrument category prediction. These prediction results are compared with the target information in the condition vector to obtain the corresponding tonic pitch loss, rhythm loss, and instrument category loss, which, together with the adversarial loss, constitute the generator's training objective. Through backpropagation, these loss values adjust the generator's weights, enabling the generator to generate music that better meets the prescription requirements in subsequent iterations.
[0066] By dynamically generating music fragments using Generative Adversarial Networks (GANs), this approach effectively addresses the auditory fatigue problem caused by the reliance on limited pre-set music libraries in traditional music therapy applications. Leveraging the real-time creation capabilities of GANs, unique music content can be dynamically generated. This avoids user boredom due to repetitive content while maintaining consistency in treatment content, thus improving user experience and treatment adherence. Furthermore, this embodiment constrains the GAN's creation process through music prescription vectors. These vectors, based on Traditional Chinese Medicine (TCM) principles, limit the core elements of the generated music, such as pitch and rhythm range. This ensures that while maintaining artistry and diversity, the core elements of the generated music consistently conform to TCM principles, effectively overcoming the shortcomings of general AI music generation models that lack directional constraints, leading to insufficient therapeutic effectiveness and safety.
[0067] Step S3: Render the music matrix to output traditional Chinese medicine five-tone therapy music. For example... Figure 5 As shown, it includes: Step S31: Traverse the music matrix according to the time step, identify all note events in the music matrix, and calculate the note duration; Step S32: Generate a MIDI object by combining the music prescription vector; Step S33: Based on the timbre parameters and dynamic parameters defined in the music prescription vector, obtain the timbre categories of the lead and accompaniment, convert the timbre categories into corresponding timbre library files and instrument numbers through the timbre mapping table, perform waveform rendering on the MIDI object, and output the traditional Chinese medicine five-tone therapy music.
[0068] The generated music matrix can be converted into MIDI (Musical Instrument Digital Interface) format through event recognition and parameter mapping for subsequent timbre rendering and audio output. The conversion from music matrix to MIDI is performed. During this process, the generated music matrix is traversed, scanning sequentially according to time steps. Note events are identified during the scan: if the pitch j value at the (i-1)th time step is zero, and the same pitch value at the ith time step is greater than zero, it is identified as a note on event. This event includes pitch j, start time i, and the velocity value obtained by multiplying the matrix element value by 127. If the pitch j value at the (i-1)th time step is greater than zero, and the same pitch value at the ith time step is zero, it is identified as a note off event. This event includes pitch j and end time i. The note duration is obtained by calculating the difference between the note's start and end times. The note events identified in this way are combined with the preset tempo information in the music prescription to assemble MIDI data conforming to a standard format.
[0069] The timbre selection and loading are performed based on the timbre parameters of the music prescription. The main instrument category and accompaniment instrument category, such as `instrument_class_primary` and `instrument_class_secondary`, are read from the music prescription vector, and the corresponding timbre resources are searched in a preset timbre mapping table. In some implementations, this mapping table converts the categorized instrument tags into specific SoundFont file names and MIDI instrument numbers. For example, the resource corresponding to the "Guqin" category is the "chinese_classics.sf2" file and instrument timbre number 27, and the resource corresponding to the "Dongxiao" category is the "chinese_classics.sf2" file and instrument timbre number 78. After mapping, the corresponding SoundFont file is loaded, and the corresponding instrument number is set in the synthesis engine, thereby ensuring that the generated music meets the prescription requirements at the timbre level.
[0070] When parsing the music matrix, timbre parameters and dynamic parameters are extracted simultaneously from the music prescription vector. Based on the timbre parameters, corresponding instrument timbre models are matched from a preset professional timbre library. This professional timbre library contains specific instrument timbre data adapted to the five-tone theory of Traditional Chinese Medicine, such as the timbre of flutes and xiao corresponding to the "jiao" note, and the timbre of qin and se corresponding to the "zhi" note. Based on the dynamic parameters, the volume intensity of the generated audio is adjusted in real time to ensure that the volume changes conform to preset intensity gradient and rate requirements. Through the above processing, the music therapy information carried by the digital music representation matrix is completely preserved and accurately presented during the conversion into audible audio, while retaining the therapeutic timbre characteristics defined by the timbre parameters and the therapeutic volume change characteristics defined by the dynamic parameters.
[0071] The generated MIDI data can be rendered using a software synthesizer to obtain a playable audio stream. Initialization is performed using a Fluid Synth-based synthesizer, which loads a specified sound library file, such as "chinese_classics.sf2". This process ensures that the instrument sounds corresponding to the music prescription can be used during subsequent rendering. After loading the sound library, each track in the MIDI object is traversed sequentially, and the corresponding instrument numbers are assigned to different channels based on the preset lead and accompaniment instrument categories in the music prescription vector. This ensures that the generated music maintains timbre consistency with the prescription specifications.
[0072] To address the shortcomings of traditional music generation methods, which rely on general timbre libraries and fail to provide targeted control over therapeutic parameters such as timbre and dynamics, resulting in the loss of music therapy information related to the Five Tones theory of Traditional Chinese Medicine during the audio rendering process, this embodiment uses timbre and dynamic parameters as the core control parameters for audio rendering. This enables the rendering process to not only restore the basic musical elements such as melody and rhythm of the digital music representation matrix, but also accurately reproduce the therapeutic elements in the music prescription vector, such as timbre type, spectral characteristics, and volume variation patterns based on the principles of Traditional Chinese Medicine. This ensures the integrity and consistency of the treatment plan throughout the entire process from digital music data to audible audio, effectively avoiding the weakening of therapeutic effects caused by emphasizing melody over timbre or the loss of dynamic features.
[0073] After the instrument configuration is complete, the full MIDI object is input into the synthesizer for rendering. The synthesizer generates corresponding waveform signals step by step according to the MIDI event sequence, outputting PCM data in single-precision floating-point format. This PCM data exists in the form of an array, which can be directly used as input to subsequent audio playback modules, completing the mapping process from symbolic music to digital audio, and outputting traditional Chinese medicine five-tone therapy music.
[0074] During the audio stream playback phase, the audio playback library is invoked to open the output channel, setting the sampling rate to 44,100Hz, the number of channels to mono, and the data format to 32-bit floating-point. The PCM waveform data obtained from the previous rendering step is converted into a byte stream that meets playback requirements and continuously written to the audio output stream to achieve real-time music playback. After the music playback is complete, the audio stream is closed and resources are released, ending a complete music generation and playback process. This end-to-end automated process seamlessly integrates automated processing, enabling a complete workflow from user input of symptoms to generation of customized therapeutic music without manual intervention, effectively reducing the user's operational threshold. Compared to traditional interactive methods that rely on users manually selecting tags or tracks, this embodiment provides a one-stop solution through automated processing, eliminating the need for manual selection and avoiding deviations in treatment content due to differences in user operation, thus improving the convenience and efficiency of the process.
[0075] Through the above implementation methods, this invention achieves a closed-loop processing flow from TCM insomnia syndrome differentiation to quantitative music prescriptions, and then to artificial intelligence-based conditional generation. This flow can output music that meets the corresponding treatment principles in terms of parameters such as pitch, rhythm, melody, and timbre, based on different syndrome information such as "heart-kidney disharmony" and "liver stagnation transforming into fire." Compared with traditional methods relying on vague concepts or empirical recommendations, this invention achieves precision in music generation at the prescription level, thereby significantly improving the targeted nature of music therapy.
[0076] In terms of music generation, this invention relies on the conditional generation capability of generative adversarial networks to break through the traditional processing mode based on a limited music library or template. It can generate a new music data matrix each time it is called and output unique music content, avoiding the problems of repetition and auditory fatigue caused by a limited music library during long-term use.
[0077] This invention uses the mapping rules between the five tones and treatment principles as an intrinsic condition of the adversarial neural network, rather than an external label, thereby ensuring that every element of the generated music is consistent with the theory of traditional Chinese medicine musicology. This makes the musical content interpretable and traceable, guaranteeing the scientific nature and consistency of the treatment process.
[0078] Therefore, this invention not only boasts significant advantages in the accuracy, personalization, and theoretical consistency of music generation, but also provides a standardized and replicable implementation path for traditional Chinese medicine music therapy, thereby improving the accessibility and professionalism of digital TCM treatment methods. Simultaneously, this method offers a new technical solution for non-pharmacological intervention of insomnia. Compared to traditional sleep-aiding music or noise intervention, it is more in line with the Eastern medical system and patients' cultural understanding, expanding the technological reserves for non-pharmacological interventions.
[0079] This invention provides a method for generating traditional Chinese medicine (TCM) five-tone music for insomnia based on adversarial neural networks (ANNs). By introducing an ANN and combining it with a knowledge base, the method transforms user-inputted TCM syndrome information into quantifiable music prescription vectors based on TCM diagnostic logic, thus ensuring consistency between the generated music and the treatment prescription. Compared to existing methods that rely solely on music library recommendations or general neural network generation, this invention can precisely constrain the music based on the prescription vector in each generation, outputting personalized music that conforms to the five-tone theory, effectively improving the correspondence and interpretability between the music and TCM treatment principles. Simultaneously, the conditional constraint mechanism of the ANN enhances the authenticity and artistry of the generated TCM five-tone therapeutic music. Differential customization based on different syndrome types provides insomnia patients with more targeted and stable therapeutic music.
[0080] Based on the same inventive concept, this application also provides a traditional Chinese medicine five-tone music generation system for insomnia based on adversarial neural networks, comprising: The music prescription vector generation module receives TCM syndrome information input by the user and generates corresponding music prescription vectors based on a TCM music prescription knowledge base mapped by preset elements. The adversarial neural network processing module inputs the music prescription vector as a condition vector into the adversarial neural network, and the adversarial neural network outputs a music matrix that satisfies the music prescription vector. The Traditional Chinese Medicine Five-Tone Music Generation Module renders the music matrix and outputs Traditional Chinese Medicine Five-Tone Therapeutic Music.
[0081] Based on the same inventive concept, the present invention also provides a computer device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed as described above in the method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks.
[0082] The processing methods for computer devices can be referred to the description of the methods above, and will not be repeated here.
[0083] This application also provides a non-transitory machine-readable storage medium storing an executable program, which, when run by a microprocessor, causes the processor to execute the method provided in the above embodiments.
[0084] This invention discloses a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform the described methods.
[0085] This invention discloses a computer program product including a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform the described method.
[0086] The embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0087] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0088] Finally, it should be noted that the embodiments disclosed in this invention are merely preferred embodiments of this invention and are only used to illustrate the technical solutions of this invention, not to limit it. Although this invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this invention.
Claims
1. A method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks, characterized in that, include: It receives information on the TCM syndrome type corresponding to insomnia input by the user, and generates the corresponding music prescription vector based on the TCM music prescription knowledge base mapped by preset elements. The music prescription vector is input as a conditional vector into the adversarial neural network, and the adversarial neural network outputs the music matrix corresponding to the music prescription vector. The music matrix is rendered to output traditional Chinese medicine five-tone therapy music.
2. The method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks according to claim 1, characterized in that, The preset elements include syndrome type, pathogenesis, treatment principle, and music element; The TCM music prescription knowledge base includes a syndrome type-pathogenesis-treatment principle layer, a treatment principle-music element mapping layer, and a parameter quantification and output layer. The syndrome type-pathogenesis-treatment principle layer is used to store TCM syndrome types of insomnia and corresponding pathogenesis data, as well as treatment principle data corresponding to the pathogenesis. The rule-music element mapping layer stores the mapping rules corresponding to the rule and the music element, and generates music composition elements based on the mapping rules; the parameter quantization and output layer transforms the music composition elements into music prescription vectors containing the music composition elements.
3. The method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks according to claim 2, characterized in that, The adversarial neural network includes a generator and a discriminator. The generator generates a music matrix that conforms to the principles of traditional Chinese medicine in real time based on the music prescription vector and the random noise vector. The discriminator simultaneously judges the authenticity of the music matrix and its matching degree with the music prescription vector. The generator weights are updated based on the discriminator feedback until a music matrix that satisfies the music prescription vector is output.
4. The method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks according to claim 3, characterized in that, The music prescription vector includes pitch parameters, rhythm parameters, melody parameters, timbre parameters, and dynamic parameters.
5. The method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks according to claim 3, characterized in that, The music matrix is rendered to output traditional Chinese medicine five-tone therapy music, including: Traverse the music matrix according to the time step, identify all note events in the music matrix, and calculate the note duration; Generate a MIDI object by combining the beat information of the rhythm parameter in the music prescription vector; Based on the timbre parameters and dynamic parameters defined in the music prescription vector, the timbre categories of the lead and accompaniment are obtained. The timbre categories are converted into corresponding timbre library files and instrument numbers through a timbre mapping table. The MIDI object is then waveform rendered to output traditional Chinese medicine five-tone therapy music.
6. The method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks according to claim 5, characterized in that, Receive information from the user regarding the TCM syndrome type corresponding to insomnia, including: A pre-defined structured TCM syndrome database is provided, wherein each entry in the TCM syndrome database includes the Chinese name of the syndrome, a unique identifier, the full pinyin spelling, and the pinyin abbreviation; Obtain the keywords corresponding to insomnia input by the user, and preprocess the keywords to obtain the query string; Match the entry's certificate type Chinese name, unique identifier, full pinyin or pinyin abbreviation based on the query string; When a match is successful, the entry is set as a candidate result; a recommendation list containing the candidate results is generated in the user interaction screen; Obtain the candidate results selected by the user from the recommendation list, and convert the candidate results into TCM syndrome information.
7. The method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks according to claim 3, characterized in that, The generator's loss function includes a tonic loss function, a rhythm loss function, and an instrument category loss function; the tonic loss function and the instrument category loss function use classification cross-entropy loss; the rhythm loss function uses mean squared error loss.
8. The method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks according to claim 4, characterized in that, The pitch parameters include the tonic pitch category, the scale mask, and the pitch weight distribution, corresponding to integer values between 0 and 11 for MIDI pitch categories; the scale mask uses a 12-bit binary vector to represent the allowed pitches; the pitch weight distribution is used to limit the probability of each pitch appearing in the melody; The rhythm parameters include the tempo range, the rhythm complexity scalar, which is expressed in beats per minute and has a tempo range of 30 to 120; and the rhythm complexity scalar, which has a value range of 0 to 1 and is used to indicate the complexity of the rhythm pattern. Melodic parameters include the direction of the melody and the range of intervals. The direction of the melody ranges from -1 to 1 and is used to characterize the overall upward or downward trend of the melody. The range of intervals is used to limit the pitch difference between adjacent notes, and the unit is degrees. The timbre parameters include the main instrument category and the accompaniment instrument category, which correspond to preset instrument tags and are converted into specific timbre library files or MIDI instrument numbers through a mapping table; The dynamic parameters include the average dynamic value and the variance of dynamic variation. The average dynamic value ranges from 0 to 127. The variance of dynamic variation is used to characterize the amplitude of the loudness fluctuations of music during playback.
9. A traditional Chinese medicine five-tone music generation system for insomnia based on adversarial neural networks, characterized in that, include: The music prescription vector generation module receives TCM syndrome information input by the user and generates corresponding music prescription vectors based on a TCM music prescription knowledge base mapped by preset elements. The adversarial neural network processing module inputs the music prescription vector as a conditional vector into the adversarial neural network, and the adversarial neural network outputs the music matrix corresponding to the music prescription vector. The Traditional Chinese Medicine Five-Tone Music Generation Module renders the music matrix and outputs Traditional Chinese Medicine Five-Tone Therapeutic Music.
10. A computer storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the steps of the method for generating traditional Chinese medicine five-tone music for insomnia based on adversarial neural networks as described in any one of claims 1-8.
Citation Information
Patent Citations
Music sleep aiding method and device based on traditional Chinese medicine deficiency-excess syndrome differentiation and computer equipment
CN117323539A
Music therapy system for generating five voices of traditional Chinese medicine based on intelligent algorithm
CN118197550A
Music sleep-aiding prescription generation method and device, medium and computer equipment
CN119909290A
Relaxing and decompression system for relieving depression of teenagers based on five-tone music of traditional Chinese medicine
CN120346425A
Method and system for assisting clinical psychotherapy through traditional Chinese medicine music therapy
CN120550288A