Method and system for synchronously displaying transliterated lyrics
Through the two-way alignment and scoring mechanism, the problem of inconsistent transliteration lyrics and the timestamp of the original lyrics is solved. The string matching and time window algorithm are used to achieve accurate synchronization of the lyrics, improving the matching speed and accuracy.
Patent Information
- Application Number
- CN202411142944.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-11-29
AI Technical Summary
In existing KTV systems or karaoke devices, the transliteration lyrics are inconsistent with the timestamp of the original lyrics, resulting in the inability to accurately synchronize, especially when the pace is fast or the content is complicated, it is difficult for users to follow.
The two-way alignment method is used to extract the timestamps in the lyrics through the string matching algorithm, and select the appropriate matching method according to the lyrics of different lengths, and match them with the time window and the dynamic time regularization algorithm to calculate the score to ensure synchronization accuracy.
It realizes accurate synchronous display of transliterated lyrics and original lyrics, improves matching speed and accuracy, and ensures synchronization consistency between the two during playback.
Smart Images

Figure CN119046497A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of multimedia, and in particular to a method and system for synchronously displaying transliterated lyrics. Background Art
[0002] In existing KTV systems or karaoke equipment, in order to facilitate users to understand and sing foreign songs, a transliteration lyrics display function is usually provided. The purpose of transliteration lyrics is to transcribe the pronunciation of the original lyrics into a text form familiar to users, helping users to pronounce more accurately.
[0003] Existing transliterated lyrics are usually displayed independently of the original lyrics. Although pronunciation tips are provided, the timestamps of the transliterated lyrics and the original lyrics are not completely consistent, which often leads to the inability to accurately synchronize the two when playing. This asynchrony makes it difficult for users to compare and understand the transliterated content with the original lyrics, especially when the lyrics have a fast rhythm or complex content, and users may not be able to follow accurately.
[0004] There is currently no effective solution to the above problems in the prior art. Summary of the invention
[0005] To solve the above problems, the present invention provides a method and system for synchronously displaying transliterated lyrics. By adopting different matching methods for lyrics of different lengths, the transliterated lyrics are accurately matched with the original lyrics. The matching accuracy of the timestamps is ensured through bidirectional alignment, so as to solve the problem in the prior art that the transliterated lyrics and the original lyrics cannot be accurately synchronized.
[0006] To achieve the above-mentioned object, the present invention provides a method for synchronously displaying transliterated lyrics, comprising: obtaining an original lyrics file and a transliterated lyrics file; extracting the original lyrics and the corresponding original lyrics timestamp in the original lyrics file by using a string matching algorithm; extracting the transliterated lyrics and the corresponding transliterated lyrics timestamp in the transliterated lyrics file by using a string matching algorithm; selecting a first target matching method according to the number of original lyrics timestamps, using the first target matching method to match and obtain the transliterated lyrics timestamp corresponding to each original lyrics timestamp as a first matching result, and calculating a first matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics; selecting a second target matching method according to the number of transliterated lyrics timestamps, using the second target matching method to match and obtain the original lyrics timestamp corresponding to each transliterated lyrics timestamp as a second matching result, and calculating a second matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics; merging the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result; and synchronously displaying the successfully matched original lyrics and transliterated lyrics in the final matching result.
[0007] Further optionally, the first target matching method is selected according to the number of original lyrics timestamps, and the first target matching method is used to match the transliterated lyrics timestamp corresponding to each original lyrics timestamp, including: when the number of original lyrics timestamps is greater than a preset number threshold, the original lyrics timestamps and the transliterated lyrics timestamps are roughly matched using a time window to obtain a candidate transliterated lyrics timestamp corresponding to each original lyrics timestamp; the original lyrics timestamps and the candidate transliterated lyrics timestamps are finely matched according to a dynamic time warping algorithm to obtain a transliterated lyrics timestamp corresponding to each original lyrics; when the number of original lyrics timestamps is not greater than a preset number threshold, the original lyrics timestamps and the transliterated lyrics timestamps are finely matched according to a dynamic time warping algorithm to obtain a transliterated lyrics timestamp corresponding to each original lyrics.
[0008] Further optionally, the calculating a first matching score based on the timestamp of the successfully matched original lyrics, the timestamp of the transliterated lyrics, the original lyrics and the transliterated lyrics includes: calculating a time difference score based on the timestamp of the successfully matched original lyrics and the transliterated timestamp; transcribing the successfully matched original lyrics using a vocabulary comparison table to obtain transcribed original lyrics; calculating a similarity score between the transcribed original lyrics and the corresponding transliterated lyrics using a text similarity algorithm; and performing a weighted summation of the time difference score and the similarity score to obtain a first matching score.
[0009] Further optionally, the merging the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result includes: for each original lyrics timestamp, when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are consistent, taking the original lyrics timestamp and the corresponding transliterated lyrics timestamp as a timestamp pair in the final matching result; when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are inconsistent, comparing the first matching score and the second matching score of the original lyrics timestamp, selecting the larger matching score as a candidate matching score, and if the candidate matching score is greater than a preset score threshold, taking the transliterated lyrics timestamp corresponding to the candidate matching score and the original lyrics timestamp as a timestamp pair in the final matching result; otherwise, manually transliterating the original lyrics corresponding to the original lyrics timestamp to obtain the corresponding transliterated lyrics.
[0010] Further optionally, the synchronous display of the successfully matched original lyrics and transliterated lyrics in the final matching result includes: displaying the successfully matched original lyrics and transliterated lyrics in double lines and in different colors.
[0011] The present invention also provides a transliteration lyrics synchronous display system, comprising: a data acquisition module, used to acquire an original lyrics file and a transliteration lyrics file; a timestamp extraction module, used to extract the original lyrics and the corresponding original lyrics timestamps in the original lyrics file by using a string matching algorithm; extract the transliteration lyrics and the corresponding transliteration lyrics timestamps in the transliteration lyrics file by using a string matching algorithm; a first scoring module, used to select a first target matching method according to the number of original lyrics timestamps, use the first target matching method to match and obtain the transliteration lyrics timestamp corresponding to each original lyrics timestamp as a first matching result, and score the timestamps of the original lyrics and the transliteration lyrics that have been successfully matched. The first matching score is calculated based on the timestamp of the original lyrics, the original lyrics and the transliterated lyrics; the second scoring module is used to select a second target matching method according to the number of the transliterated lyrics timestamps, and the original lyrics timestamp corresponding to each transliterated lyrics timestamp is matched by the second target matching method as the second matching result, and the second matching score is calculated based on the successfully matched original lyrics timestamp, the transliterated lyrics timestamp, the original lyrics and the transliterated lyrics; the fusion module is used to merge the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result; the display module is used to synchronously display the successfully matched original lyrics and the transliterated lyrics in the final matching result.
[0012] Further optionally, the first scoring module includes: a multi-level matching submodule, which is used to use a time window to perform a coarse match on the original lyrics timestamps and the transliterated lyrics timestamps when the number of original lyrics timestamps is greater than a preset number threshold, so as to obtain a candidate transliterated lyrics timestamp corresponding to each original lyrics timestamp; perform a fine match on the original lyrics timestamps and the candidate transliterated lyrics timestamps according to a dynamic time warping algorithm to obtain a transliterated lyrics timestamp corresponding to each original lyrics; and a single-level matching submodule, which is used to perform a fine match on the original lyrics timestamps and the transliterated lyrics timestamps according to a dynamic time warping algorithm to obtain a transliterated lyrics timestamp corresponding to each original lyrics when the number of original lyrics timestamps is not greater than a preset number threshold.
[0013] Further optionally, the first scoring module includes: a time difference score calculation submodule, which is used to calculate the time difference score based on the timestamp of the successfully matched original lyrics and the transliteration timestamp; a conversion submodule, which is used to transcribe the successfully matched original lyrics according to the vocabulary comparison table to obtain transcribed original lyrics; a similarity score calculation submodule, which is used to calculate the similarity score between the transcribed original lyrics and the corresponding transliterated lyrics using a text similarity algorithm; and a comprehensive calculation submodule, which is used to perform a weighted summation of the time difference score and the similarity score to obtain a first matching score.
[0014] Further optionally, the fusion module includes: a first merging submodule, used for, for each original lyrics timestamp, when the first matching result is consistent with the timestamp of the transliterated lyrics matched in the second matching result, using the original lyrics timestamp and the corresponding transliterated lyrics timestamp as the timestamp pair in the final matching result; a second merging submodule, used for, when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are inconsistent, comparing the first matching score and the second matching score of the original lyrics timestamp, selecting the larger matching score as the candidate matching score, if the candidate matching score is greater than a preset score threshold, using the transliterated lyrics timestamp corresponding to the candidate matching score and the original lyrics timestamp as the timestamp pair in the final matching result; otherwise, manually transliterating the original lyrics corresponding to the original lyrics timestamp to obtain the corresponding transliterated lyrics.
[0015] Further optionally, the display module includes: a display submodule, which is used to display the successfully matched original lyrics and transliterated lyrics in double lines and in different colors.
[0016] The above technical scheme has the following beneficial effects: through bidirectional alignment and correction, not only the transliterated lyrics are aligned with the original lyrics, but also the original lyrics are aligned with the transliterated lyrics, and the two alignment results are corrected to ensure that the synchronization between the two is more accurate; different matching methods are used for lyrics files of different lengths, so that long files can be matched through multi-level matching, which improves the matching speed while ensuring the matching accuracy; the accuracy of the transliterated lyrics text is guaranteed through a scoring mechanism. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 is a flow chart of a method for synchronously displaying transliterated lyrics provided by an embodiment of the present invention;
[0019] Figure 2 is a flowchart of a timestamp matching method provided by an embodiment of the present invention;
[0020] Figure 3 is a flow chart of a scoring calculation method provided by an embodiment of the present invention;
[0021] Figure 4 is a flow chart of a matching result merging method provided by an embodiment of the present invention;
[0022] Figure 5It is a structural schematic diagram of a system for synchronously displaying transliterated lyrics provided by an embodiment of the present invention;
[0023] Figure 6 is a schematic diagram of the structure of a submodule of the first scoring module for timestamp matching provided by an embodiment of the present invention;
[0024] Figure 7 is a schematic diagram of the structure of a submodule used for scoring calculation in the first scoring module provided in an embodiment of the present invention;
[0025] Figure 8 It is a schematic diagram of the structure of the fusion module provided in an embodiment of the present invention.
[0026] Figure markings: 100-data acquisition module; 200-timestamp extraction module; 300-first scoring module; 3001-multi-level matching submodule; 3002-single-level matching submodule; 3003-time difference scoring calculation submodule; 3004-conversion submodule; 3005-similarity scoring calculation submodule; 3006-comprehensive calculation submodule; 400-second scoring module; 500-fusion module; 5001-first merging submodule; 5002-second merging submodule; 600-display module; 6001-display submodule. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] In order to solve the problem in the prior art that transliterated lyrics and original lyrics cannot be accurately synchronized, an embodiment of the present invention provides a method for synchronously displaying transliterated lyrics. Figure 1 is a flow chart of a method for synchronously displaying transliterated lyrics provided by an embodiment of the present invention. Figure 1 As shown, the method includes:
[0029] S1. Obtain the original lyrics file and the transliterated lyrics file.
[0030] For a song, you can search for its original lyrics file and transliterated lyrics file based on the song name.
[0031] The lyrics file is a file containing the song timeline and lyrics text, such as an LRC file, a KRC file, etc.
[0032] The original lyrics file contains the original lyrics of the song and their corresponding timestamps.
[0033] The transliterated lyrics file contains the transliterated lyrics of the song and its corresponding timestamp. Transliterated lyrics are the pronunciation of the original lyrics converted into text in the target language so that users can pronounce them according to the text in the target language.
[0034] S2. Use a string matching algorithm to extract the original lyrics and the corresponding original lyrics timestamps in the original lyrics file; use a string matching algorithm to extract the transliterated lyrics and the corresponding transliterated lyrics timestamps in the transliterated lyrics file.
[0035] For original lyrics files and transliterated lyrics files, you can select the appropriate parsing algorithm according to their file types. For example, for LRC files, you can use the regular expression \[(\d{2}):(\d{2})\.(\d{2,3})\](.*) to extract the timestamp and text content; for KRC files, you can use a dedicated KRC file parsing library for parsing.
[0036] After parsing the original lyrics file, multiple original lyrics timestamps and their corresponding original lyrics can be obtained, for example, [00:10.00]Hello, world, where [00:10.00] is the original lyrics timestamp and Hello, world is the original lyrics corresponding to the original lyrics timestamp.
[0037] After parsing the transliterated lyrics file, multiple transliterated lyrics timestamps and their corresponding transliterated lyrics can be obtained, for example, [00:10.00]He lo, wu er de, where [00:10.00] is the transliterated lyrics timestamp, and He lo, wu er de is the transliterated lyrics corresponding to the transliterated lyrics timestamp, and the transliterated lyrics are obtained by transcribing the pronunciation of the original lyrics Hello, world.
[0038] S3. Select a first target matching method according to the number of original lyrics timestamps, use the first target matching method to match and obtain the transliterated lyrics timestamp corresponding to each original lyrics timestamp as the first matching result, and calculate a first matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics.
[0039] Since the original lyrics file and the transliterated lyrics file are two independent files, the original lyrics timestamp and the transliterated lyrics timestamp corresponding to each line of lyrics of the song may be different and need to be matched.
[0040] Determine a suitable first target matching method according to the number of original lyrics timestamps, perform text matching by the first target matching method, and obtain a first matching result. The first matching result includes a mapping relationship between each original lyrics timestamp and the corresponding transliterated lyrics timestamp. The original lyrics corresponding to the successfully matched original lyrics timestamp and the transliterated lyrics corresponding to the transliterated lyrics timestamp can be identified as lyrics that should be played at the same time.
[0041] As an optional implementation, when there are too many timestamps in the original lyrics, a matching method can be adopted in which the lyrics are first segmented and then matched through a matching algorithm. At this time, each lyric segment can be processed in a different thread to improve matching efficiency; otherwise, the matching algorithm is directly used for matching.
[0042] As an optional implementation, when there are too many timestamps in the original lyrics, a fuzzy match followed by a detailed match may be used; otherwise, the detailed match may be used directly for matching.
[0043] After matching, a score is calculated based on the difference between the timestamp of the original lyrics and the timestamp of the transliterated lyrics, and another score is calculated based on the difference between the original lyrics and the transliterated lyrics. The first matching score is obtained by combining the two scores.
[0044] S4. Select a second target matching method according to the number of transliterated lyrics timestamps, use the second target matching method to match the original lyrics timestamp corresponding to each transliterated lyrics timestamp as the second matching result, and calculate a second matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics.
[0045] To ensure the accuracy of timestamp matching, the original lyrics timestamp needs to be matched again based on the transliterated lyrics timestamp. The way to obtain the second matching result is the same as the way to obtain the first matching result, and the way to calculate the second matching score is the same as the way to calculate the first matching score.
[0046] S5. Combine the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result.
[0047] For the same original lyrics timestamp, the timestamp of the transliterated lyrics matched in the first matching result and the timestamp of the transliterated lyrics matched in the second matching result may be the same or different. For the same matching results, the timestamp of the transliterated lyrics matched in the second matching result may be directly adopted, and for different matching results, the transliterated lyrics timestamp may be selected on a preferential basis.
[0048] Optionally, the first matching score and the second matching score corresponding to the original lyrics timestamp are compared, and the transliterated lyrics timestamp corresponding to the higher score is selected as the final matching result.
[0049] S6. Synchronously display the original lyrics and the transliterated lyrics that are successfully matched in the final matching results.
[0050] After obtaining the final matching result, if the timestamps corresponding to the two lyrics texts in the matching result are the same, the two lyrics texts are synchronously displayed according to the same timestamp.
[0051] Of course, there may be a situation where there is a slight difference between the two timestamps. In this case, the two lyrics texts can be displayed synchronously according to the timestamp of the transliterated lyrics. If the user turns on the transliterated lyrics when singing, it means that the user is more inclined to sing according to the transliterated lyrics. Then, if the timestamp of the transliterated lyrics is slightly different from the timestamp of the corresponding original lyrics, the timestamp of the original lyrics is modified to the corresponding timestamp of the transliterated lyrics for synchronous playback. For example, the original lyrics "[00:10.00]Sakura,sakura" is slightly different from the transliterated lyrics "[00:09.50]Sa ku la,sa ku la". The timestamp of the transliterated lyrics is earlier than that of the original lyrics. Then the timestamp of the original lyrics [00:10.00] is modified to [00:09.50] to achieve synchronous playback.
[0052] In addition, in order to improve the accuracy of the transliterated lyrics, the present embodiment also provides a translation correction function, which automatically corrects the translation errors of the transliterated lyrics according to the context semantics and user feedback. For example, the transliterated lyrics can be proofread using a machine translation API or a manual translation library, and the proofread results can be updated to the lyrics file.
[0053] As an optional implementation, Figure 2 is a flowchart of a timestamp matching method provided by an embodiment of the present invention. Figure 2 As shown, the first target matching method is selected according to the number of original lyrics timestamps, and the first target matching method is used to match the transliterated lyrics timestamp corresponding to each original lyrics timestamp, including:
[0054] S301. When the number of original lyrics timestamps is greater than a preset number threshold, a time window is used to perform a rough match on the original lyrics timestamps and the transliterated lyrics timestamps to obtain a candidate transliterated lyrics timestamp corresponding to each original lyrics timestamp; a dynamic time warping algorithm is used to perform a fine match on the original lyrics timestamps and the candidate transliterated lyrics timestamps to obtain a transliterated lyrics timestamp corresponding to each original lyrics.
[0055] When the number of original lyrics timestamps is greater than a preset number threshold, it is considered that the original lyrics file is long, and a method of first coarse matching and then fine matching is selected as the first target matching method.
[0056] A song with a length of 2 minutes contains about 10-20 timestamps, and a song with a length of 5 minutes contains 50-100 timestamps. Therefore, according to the rules of most songs, the preset number threshold can be manually set, and the selection range can be between 25-35. Preferably, the preset number threshold is 30.
[0057] First, a time window (e.g., ±0.5s) is pre-set within which the matching is performed. The size of the time window can be adjusted according to the rhythm and lyrics density of the song.
[0058] For songs with a faster tempo, a smaller time window is used, such as 0.5s-1.5s; conversely, for songs with a slower tempo, a larger time window is used, such as 1.5-2.5s. If each paragraph of lyrics has more words and the interval between lyrics is short, a smaller time window is used, such as 0.5s-1.5s; conversely, if each paragraph of lyrics has more words and the interval between lyrics is short, a larger time window is used, such as 0.5s-1.5s. The specific time window setting can be adaptively selected according to the actual situation.
[0059] A time window-based matching algorithm is used. For each original lyrics timestamp, the transliterated lyrics timestamps within the time window corresponding to the original lyrics timestamp are screened from all transliterated lyrics timestamps as candidate transliterated lyrics timestamps. There may be multiple candidate transliterated lyrics timestamps, and fine matching is required at this time. The dynamic time warping algorithm is applied to the matching pairs screened out in the coarse matching stage to determine the best timestamp pair.
[0060] Furthermore, after obtaining the candidate transliterated lyrics timestamps through coarse matching, a thread is assigned to process each original lyrics timestamp that needs to be finely matched, so as to improve processing efficiency.
[0061] S302: When the number of original lyrics timestamps is not greater than a preset number threshold, the original lyrics timestamps and the transliterated lyrics timestamps are finely matched according to a dynamic time warping algorithm to obtain the transliterated lyrics timestamp corresponding to each original lyric.
[0062] When the number of original lyrics timestamps is less than a preset threshold, the original lyrics file is considered to be short, and the dynamic time warping algorithm can be directly used as the first target matching method to match the original lyrics timestamps with the transliterated lyrics timestamps to obtain the transliterated lyrics timestamp corresponding to each original lyrics timestamp.
[0063] As an optional implementation, Figure 3 is a flow chart of a scoring calculation method provided by an embodiment of the present invention. Figure 3As shown, the first matching score is calculated based on the timestamp of the original lyrics, the timestamp of the transliterated lyrics, the original lyrics and the transliterated lyrics that have been successfully matched, including:
[0064] S303, calculating a time difference score according to the successfully matched original lyrics timestamp and transliteration timestamp.
[0065] Calculate the time difference between the timestamp of the successfully matched original lyrics and the timestamp of the transliterated lyrics, and normalize each time difference to obtain the time difference score corresponding to each timestamp pair.
[0066] As an optional implementation, each time difference is normalized and calculated using the following formula: time difference score = 1 / (1+time difference). For example, if the time difference between two timestamps is 0.5s, then the time difference score = 1 / (1+0.5) = 0.67.
[0067] As an optional implementation, the time difference may be mapped to a specified score range (eg, 0 to 1) through a linear scaling function to obtain a time difference score.
[0068] S304, using the vocabulary comparison table to transcribe the successfully matched original lyrics to obtain transcribed original lyrics.
[0069] The original lyrics can be transcribed using a predefined vocabulary comparison table to obtain the transcribed original lyrics. The vocabulary comparison table is a comparison table for converting the source language to pinyin, which can be predefined manually. For example, the pronunciation of each kana in Japanese is transcribed to pinyin, for example, the kana "ら" with the romanization "ra" corresponds to the pinyin "la" in the vocabulary comparison table.
[0070] According to the above vocabulary comparison table, "さくら" (Sakura) can be transcribed to obtain the transcribed original lyrics "saku la".
[0071] S305: Calculate the similarity score between the transcribed original lyrics and the corresponding transliterated lyrics using a text similarity algorithm.
[0072] The similarity of the pinyin text is calculated using a text similarity algorithm. For example, the similarity between the transcribed original lyrics and the corresponding transliterated lyrics can be calculated using an edit distance algorithm, and the similarity is used as a similarity score. For example, if the similarity score between the transcribed original lyrics and the corresponding transliterated lyrics is 98%, the similarity score is 0.98.
[0073] S306: Perform weighted summation on the time difference score and the similarity score to obtain a first matching score.
[0074] The time difference score corresponds to one weight, and the similarity score corresponds to another weight. The two scores are weighted and summed according to their respective weights to obtain the similarity score.
[0075] As an optional implementation, the first matching result and the second matching result are combined according to the first matching score and the second matching score to obtain a final matching result, including:
[0076] S501. For each original lyrics timestamp, when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are consistent, the original lyrics timestamp and the corresponding transliterated lyrics timestamp are used as timestamp pairs in the final matching result.
[0077] S502. When the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are inconsistent, compare the first matching score and the second matching score of the original lyrics timestamp, select the larger matching score as the candidate matching score, and if the candidate matching score is greater than a preset score threshold, use the transliterated lyrics timestamp corresponding to the candidate matching score and the original lyrics timestamp as the timestamp pair in the final matching result; otherwise, perform manual transliteration according to the original lyrics corresponding to the original lyrics timestamp to obtain the corresponding transliterated lyrics.
[0078] During the merging process, the original lyrics timestamp is used as the basis to determine whether the timestamps of the transliterated lyrics in the first matching result and the second matching result are consistent. If they are consistent, the same transliterated lyrics timestamp and the original lyrics timestamp are used as the timestamp pair in the final matching result, and the content of the transliterated lyrics does not need to be changed.
[0079] If they are inconsistent, it is necessary to further compare the first match score and the second match score corresponding to the original lyrics timestamp, and select the match score with the larger value as the candidate match score. Then compare the candidate match score with the preset score threshold. When the candidate match score is greater than the preset score threshold, the match result is considered to be credible, and the timestamp of the transliterated lyrics corresponding to the candidate match score and the timestamp of the original lyrics form a timestamp pair in the final match result; when the candidate match score is less than or equal to the preset score threshold, the match result is considered to be unreliable, and the original lyrics corresponding to the original lyrics timestamp need to be manually transliterated to obtain the transliterated lyrics for synchronous display with the original lyrics.
[0080] As an optional implementation, the original lyrics and the transliterated lyrics that are successfully matched in the final matching result are displayed synchronously, including:
[0081] S601, displaying the successfully matched original lyrics and transliterated lyrics in two lines and in different colors.
[0082] The successfully matched original lyrics and transliterated lyrics are displayed in double lines, for example, the original lyrics are displayed on the top and the transliterated lyrics are displayed on the bottom.
[0083] The original lyrics and the transliterated lyrics may also be displayed in different colors, for example, the original lyrics may be displayed in white and the transliterated lyrics may be displayed in yellow.
[0084] Additionally, a toggle button may be provided to allow the user to switch between the original lyrics and the transliterated lyrics.
[0085] The embodiment of the present invention also provides a system for synchronously displaying transliterated lyrics. Figure 5 is a structural diagram of a system for synchronously displaying transliterated lyrics provided by an embodiment of the present invention. Figure 5 As shown, the system includes:
[0086] The data acquisition module 100 is used to acquire the original lyrics file and the transliterated lyrics file;
[0087] For a song, you can search for its original lyrics file and transliterated lyrics file based on the song name.
[0088] The lyrics file is a file containing the song timeline and lyrics text, such as an LRC file, a KRC file, etc.
[0089] The original lyrics file contains the original lyrics of the song and their corresponding timestamps.
[0090] The transliterated lyrics file contains the transliterated lyrics of the song and its corresponding timestamp. Transliterated lyrics are the pronunciation of the original lyrics converted into text in the target language so that users can pronounce them according to the text in the target language.
[0091] The timestamp extraction module 200 is used to extract the original lyrics and the corresponding original lyrics timestamps in the original lyrics file by using a string matching algorithm; and to extract the transliterated lyrics and the corresponding transliterated lyrics timestamps in the transliterated lyrics file by using a string matching algorithm.
[0092] For original lyrics files and transliterated lyrics files, you can select the appropriate parsing algorithm according to their file types. For example, for LRC files, you can use the regular expression \[(\d{2}):(\d{2})\.(\d{2,3})\](.*) to extract the timestamp and text content; for KRC files, you can use a dedicated KRC file parsing library for parsing.
[0093] After parsing the original lyrics file, multiple original lyrics timestamps and their corresponding original lyrics can be obtained, for example, [00:10.00]Hello, world, where [00:10.00] is the original lyrics timestamp and Hello, world is the original lyrics corresponding to the original lyrics timestamp.
[0094] After parsing the transliterated lyrics file, multiple transliterated lyrics timestamps and their corresponding transliterated lyrics can be obtained, for example, [00:10.00]He lo, wu er de, where [00:10.00] is the transliterated lyrics timestamp, and He lo, wu er de is the transliterated lyrics corresponding to the transliterated lyrics timestamp, and the transliterated lyrics are obtained by transcribing the pronunciation of the original lyrics Hello, world.
[0095] The first scoring module 300 is used to select a first target matching method according to the number of original lyrics timestamps, use the first target matching method to match the transliterated lyrics timestamp corresponding to each original lyrics timestamp as the first matching result, and calculate the first matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics.
[0096] Since the original lyrics file and the transliterated lyrics file are two independent files, the original lyrics timestamp and the transliterated lyrics timestamp corresponding to each line of lyrics of the song may be different and need to be matched.
[0097] Determine a suitable first target matching method according to the number of original lyrics timestamps, perform text matching by the first target matching method, and obtain a first matching result. The first matching result includes a mapping relationship between each original lyrics timestamp and the corresponding transliterated lyrics timestamp. The original lyrics corresponding to the successfully matched original lyrics timestamp and the transliterated lyrics corresponding to the transliterated lyrics timestamp can be identified as lyrics that should be played at the same time.
[0098] As an optional implementation, when there are too many timestamps in the original lyrics, a matching method can be adopted in which the lyrics are first segmented and then matched through a matching algorithm. At this time, each lyric segment can be processed in a different thread to improve matching efficiency; otherwise, the matching algorithm is directly used for matching.
[0099] As an optional implementation, when there are too many timestamps in the original lyrics, a fuzzy match followed by a detailed match may be used; otherwise, the detailed match may be used directly for matching.
[0100] After matching, a score is calculated based on the difference between the timestamp of the original lyrics and the timestamp of the transliterated lyrics, and another score is calculated based on the difference between the original lyrics and the transliterated lyrics. The first matching score is obtained by combining the two scores.
[0101] The second scoring module 400 is used to select a second target matching method according to the number of transliterated lyrics timestamps, and use the second target matching method to match the original lyrics timestamp corresponding to each transliterated lyrics timestamp as the second matching result, and calculate the second matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics.
[0102] To ensure the accuracy of timestamp matching, the original lyrics timestamp needs to be matched again based on the transliterated lyrics timestamp. The way to obtain the second matching result is the same as the way to obtain the first matching result, and the way to calculate the second matching score is the same as the way to calculate the first matching score.
[0103] The fusion module 500 is used to merge the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result.
[0104] For the same original lyrics timestamp, the timestamp of the transliterated lyrics matched in the first matching result and the timestamp of the transliterated lyrics matched in the second matching result may be the same or different. For the same matching results, the timestamp of the transliterated lyrics matched in the second matching result may be directly adopted, and for different matching results, the transliterated lyrics timestamp may be selected on a preferential basis.
[0105] Optionally, the first matching score and the second matching score corresponding to the original lyrics timestamp are compared, and the transliterated lyrics timestamp corresponding to the higher score is selected as the final matching result.
[0106] The display module 600 is used to synchronously display the original lyrics and the transliterated lyrics that are successfully matched in the final matching results.
[0107] After obtaining the final matching result, if the timestamps corresponding to the two lyrics texts in the matching result are the same, the two lyrics texts are synchronously displayed according to the same timestamp.
[0108] Of course, there may be a situation where there is a slight difference between the two timestamps. In this case, the two lyrics texts can be displayed synchronously according to the timestamp of the transliterated lyrics. If the user turns on the transliterated lyrics when singing, it means that the user is more inclined to sing according to the transliterated lyrics. Then, if the timestamp of the transliterated lyrics is slightly different from the timestamp of the corresponding original lyrics, the timestamp of the original lyrics is modified to the corresponding timestamp of the transliterated lyrics for synchronous playback. For example, the original lyrics "[00:10.00]Sakura,sakura" is slightly different from the transliterated lyrics "[00:09.50]Sa ku la,sa ku la". The timestamp of the transliterated lyrics is earlier than that of the original lyrics. Then the timestamp of the original lyrics [00:10.00] is modified to [00:09.50] to achieve synchronous playback.
[0109] In addition, in order to improve the accuracy of the transliterated lyrics, the present embodiment also provides a translation correction function, which automatically corrects the translation errors of the transliterated lyrics according to the context semantics and user feedback. For example, the transliterated lyrics can be proofread using a machine translation API or a manual translation library, and the proofread results can be updated to the lyrics file.
[0110] As an optional implementation, Figure 6 is a schematic diagram of the structure of a submodule for timestamp matching of the first scoring module provided in an embodiment of the present invention, such as Figure 6 As shown, the first scoring module 300 includes:
[0111] The multi-level matching submodule 3001 is used to, when the number of original lyrics timestamps is greater than a preset number threshold, use a time window to perform a coarse match on the original lyrics timestamps and the transliterated lyrics timestamps to obtain a candidate transliterated lyrics timestamp corresponding to each original lyrics timestamp; and perform a fine match on the original lyrics timestamps and the candidate transliterated lyrics timestamps according to a dynamic time warping algorithm to obtain a transliterated lyrics timestamp corresponding to each original lyrics.
[0112] When the number of original lyrics timestamps is greater than a preset number threshold, it is considered that the original lyrics file is long, and a method of first coarse matching and then fine matching is selected as the first target matching method.
[0113] A song with a length of 2 minutes contains about 10-20 timestamps, and a song with a length of 5 minutes contains 50-100 timestamps. Therefore, according to the rules of most songs, the preset number threshold can be manually set, and the selection range can be between 25-35. Preferably, the preset number threshold is 30.
[0114] First, a time window (e.g., ±0.5s) is pre-set within which the matching is performed. The size of the time window can be adjusted according to the rhythm and lyrics density of the song.
[0115] For songs with a faster tempo, a smaller time window is used, such as 0.5s-1.5s; conversely, for songs with a slower tempo, a larger time window is used, such as 1.5-2.5s. If each paragraph of lyrics has more words and the interval between lyrics is short, a smaller time window is used, such as 0.5s-1.5s; conversely, if each paragraph of lyrics has more words and the interval between lyrics is short, a larger time window is used, such as 0.5s-1.5s. The specific time window setting can be adaptively selected according to the actual situation.
[0116] A time window-based matching algorithm is used. For each original lyrics timestamp, the transliterated lyrics timestamps within the time window corresponding to the original lyrics timestamp are screened from all transliterated lyrics timestamps as candidate transliterated lyrics timestamps. There may be multiple candidate transliterated lyrics timestamps, and fine matching is required at this time. The dynamic time warping algorithm is applied to the matching pairs screened out in the coarse matching stage to determine the best timestamp pair.
[0117] Furthermore, after obtaining the candidate transliterated lyrics timestamps through coarse matching, a thread is assigned to process each original lyrics timestamp that needs to be finely matched, so as to improve processing efficiency.
[0118] The single-level matching submodule 3002 is used to perform detailed matching of the original lyrics timestamps and the transliterated lyrics timestamps according to the dynamic time warping algorithm when the number of original lyrics timestamps is not greater than a preset number threshold, so as to obtain the transliterated lyrics timestamp corresponding to each original lyric.
[0119] When the number of original lyrics timestamps is less than a preset threshold, the original lyrics file is considered to be short, and the dynamic time warping algorithm can be directly used as the first target matching method to match the original lyrics timestamps with the transliterated lyrics timestamps to obtain the transliterated lyrics timestamp corresponding to each original lyrics timestamp.
[0120] As an optional implementation, Figure 7 is a schematic diagram of the structure of the submodules used for scoring calculation in the first scoring module provided in an embodiment of the present invention, such as Figure 7 As shown, the first scoring module 300 includes:
[0121] The time difference score calculation submodule 3003 is used to calculate the time difference score according to the successfully matched original lyrics timestamp and transliteration timestamp.
[0122] Calculate the time difference between the timestamp of the successfully matched original lyrics and the timestamp of the transliterated lyrics, and normalize each time difference to obtain the time difference score corresponding to each timestamp pair.
[0123] As an optional implementation, each time difference is normalized and calculated using the following formula: time difference score = 1 / (1+time difference). For example, if the time difference between two timestamps is 0.5s, then the time difference score = 1 / (1+0.5) = 0.67.
[0124] As an optional implementation, the time difference may be mapped to a specified score range (eg, 0 to 1) through a linear scaling function to obtain a time difference score.
[0125] The conversion submodule 3004 is used to transcribe the successfully matched original lyrics using the vocabulary comparison table to obtain transcribed original lyrics.
[0126] The original lyrics can be transcribed using a predefined vocabulary comparison table to obtain the transcribed original lyrics. The vocabulary comparison table is a comparison table for converting the source language to pinyin, which can be predefined manually. For example, the pronunciation of each kana in Japanese is transcribed to pinyin, for example, the kana "ら" with the romanization "ra" corresponds to the pinyin "la" in the vocabulary comparison table.
[0127] According to the above vocabulary comparison table, "さくら" (Sakura) can be transcribed to obtain the transcribed original lyrics "saku la".
[0128] The similarity score calculation submodule 3005 is used to calculate the similarity score between the transcribed original lyrics and the corresponding transliterated lyrics using a text similarity algorithm.
[0129] The similarity of the pinyin text is calculated using a text similarity algorithm. For example, the similarity between the transcribed original lyrics and the corresponding transliterated lyrics can be calculated using an edit distance algorithm, and the similarity is used as a similarity score. For example, if the similarity score between the transcribed original lyrics and the corresponding transliterated lyrics is 98%, the similarity score is 0.98.
[0130] The comprehensive calculation submodule 3006 is used to perform weighted summation on the time difference score and the similarity score to obtain a first matching score.
[0131] The time difference score corresponds to one weight, and the similarity score corresponds to another weight. The two scores are weighted and summed according to their respective weights to obtain the similarity score.
[0132] As an optional implementation, Figure 8 is a schematic diagram of the structure of the fusion module provided in an embodiment of the present invention, such as Figure 8 As shown, the fusion module 500 includes:
[0133] The first merging submodule 5001 is used for, for each original lyrics timestamp, when the timestamps of the matched transliterated lyrics in the first matching result and the second matching result are consistent, taking the original lyrics timestamp and the corresponding transliterated lyrics timestamp as the timestamp pair in the final matching result;
[0134] The second merging submodule 5002 is used to compare the first matching score and the second matching score of the original lyrics timestamp when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are inconsistent, and select the larger matching score as the candidate matching score. If the candidate matching score is greater than a preset score threshold, the transliterated lyrics timestamp corresponding to the candidate matching score and the original lyrics timestamp are used as the timestamp pair in the final matching result; otherwise, manual transliteration is performed according to the original lyrics corresponding to the original lyrics timestamp to obtain the corresponding transliterated lyrics.
[0135] During the merging process, the original lyrics timestamp is used as the basis to determine whether the timestamps of the transliterated lyrics in the first matching result and the second matching result are consistent. If they are consistent, the same transliterated lyrics timestamp and the original lyrics timestamp are used as the timestamp pair in the final matching result, and the content of the transliterated lyrics does not need to be changed.
[0136] If they are inconsistent, it is necessary to further compare the first match score and the second match score corresponding to the original lyrics timestamp, and select the match score with the larger value as the candidate match score. Then compare the candidate match score with the preset score threshold. When the candidate match score is greater than the preset score threshold, the match result is considered to be credible, and the timestamp of the transliterated lyrics corresponding to the candidate match score and the timestamp of the original lyrics form a timestamp pair in the final match result; when the candidate match score is less than or equal to the preset score threshold, the match result is considered to be unreliable, and the original lyrics corresponding to the original lyrics timestamp need to be manually transliterated to obtain the transliterated lyrics for synchronous display with the original lyrics.
[0137] As an optional implementation, the display module 600 includes:
[0138] The display submodule 6001 is used to display the successfully matched original lyrics and transliterated lyrics in double lines and different colors.
[0139] The successfully matched original lyrics and transliterated lyrics are displayed in double lines, for example, the original lyrics are displayed on the top and the transliterated lyrics are displayed on the bottom.
[0140] The original lyrics and the transliterated lyrics may also be displayed in different colors, for example, the original lyrics may be displayed in white and the transliterated lyrics may be displayed in yellow.
[0141] Additionally, a toggle button may be provided to allow the user to switch between the original lyrics and the transliterated lyrics.
[0142] The above technical scheme has the following beneficial effects: through bidirectional alignment and correction, not only the transliterated lyrics are aligned with the original lyrics, but also the original lyrics are aligned with the transliterated lyrics, and the two alignment results are corrected to ensure that the synchronization between the two is more accurate; different matching methods are used for lyrics files of different lengths, so that long files can be matched through multi-level matching, which improves the matching speed while ensuring the matching accuracy; the accuracy of the transliterated lyrics text is guaranteed through a scoring mechanism.
[0143] The specific implementation methods of the above invention further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above content is only the specific implementation methods of the present invention and is not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for synchronously displaying transliterated lyrics, It is characterized in that include: Get the original lyrics file and the transliterated lyrics file; Using a string matching algorithm to extract the original lyrics and the corresponding original lyrics timestamps in the original lyrics file; Using a string matching algorithm to extract the transliterated lyrics and the corresponding transliterated lyrics timestamps in the transliterated lyrics file; Selecting a first target matching method according to the number of original lyrics timestamps, using the first target matching method to match and obtain the transliterated lyrics timestamp corresponding to each original lyrics timestamp as a first matching result, and calculating a first matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics; Selecting a second target matching method according to the number of transliterated lyrics timestamps, using the second target matching method to match and obtain the original lyrics timestamp corresponding to each transliterated lyrics timestamp as a second matching result, and calculating a second matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics; Combining the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result; The original lyrics and the transliterated lyrics that are successfully matched in the final matching result are displayed synchronously.
2. The method for synchronously displaying transliterated lyrics according to claim 1, It is characterized in that The selecting a first target matching method according to the number of original lyrics timestamps, and using the first target matching method to match and obtain the transliterated lyrics timestamp corresponding to each original lyrics timestamp, includes: When the number of original lyrics timestamps is greater than a preset number threshold, a time window is used to perform a rough match between the original lyrics timestamps and the transliterated lyrics timestamps to obtain a candidate transliterated lyrics timestamp corresponding to each original lyrics timestamp; a dynamic time warping algorithm is used to perform a fine match between the original lyrics timestamps and the candidate transliterated lyrics timestamps to obtain a transliterated lyrics timestamp corresponding to each original lyrics; When the number of original lyrics timestamps is not greater than a preset number threshold, the original lyrics timestamps and the transliterated lyrics timestamps are finely matched according to a dynamic time warping algorithm to obtain the transliterated lyrics timestamp corresponding to each original lyric.
3. The method for synchronously displaying transliterated lyrics according to claim 2, It is characterized in that The calculating of the first matching score according to the timestamp of the original lyrics, the timestamp of the transliterated lyrics, the original lyrics and the transliterated lyrics that have been matched successfully includes: Calculate the time difference score based on the timestamp of the original lyrics and the transliteration timestamp that are successfully matched; Using the vocabulary comparison table to transcribe the successfully matched original lyrics to obtain transcribed original lyrics; Using a text similarity algorithm to calculate the similarity score between the transcribed original lyrics and the corresponding transliterated lyrics; A weighted sum is performed on the time difference score and the similarity score to obtain a first matching score.
4. The method for synchronously displaying transliterated lyrics according to claim 3, It is characterized in that The step of combining the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result includes: For each original lyrics timestamp, when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are consistent, the original lyrics timestamp and the corresponding transliterated lyrics timestamp are used as the timestamp pair in the final matching result; When the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are inconsistent, the first matching score and the second matching score of the original lyrics timestamp are compared, and the larger matching score is selected as the candidate matching score. If the candidate matching score is greater than a preset score threshold, the transliterated lyrics timestamp corresponding to the candidate matching score and the original lyrics timestamp are used as the timestamp pair in the final matching result; otherwise, manual transliteration is performed according to the original lyrics corresponding to the original lyrics timestamp to obtain the corresponding transliterated lyrics.
5. The method for synchronously displaying transliterated lyrics according to claim 4, It is characterized in that The synchronous display of the original lyrics and the transliterated lyrics that successfully match in the final matching result includes: The successfully matched original lyrics and transliterated lyrics are displayed in double lines and in different colors.
6. A system for synchronously displaying transliterated lyrics, It is characterized in that include: A data acquisition module is used to acquire original lyrics files and transliterated lyrics files; A timestamp extraction module, used to extract the original lyrics and the corresponding original lyrics timestamps in the original lyrics file by using a string matching algorithm; Using a string matching algorithm to extract the transliterated lyrics and the corresponding transliterated lyrics timestamps in the transliterated lyrics file; A first scoring module is used to select a first target matching method according to the number of original lyrics timestamps, use the first target matching method to match and obtain the transliterated lyrics timestamp corresponding to each original lyrics timestamp as a first matching result, and calculate a first matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics; A second scoring module is used to select a second target matching method according to the number of transliterated lyrics timestamps, use the second target matching method to match and obtain the original lyrics timestamp corresponding to each transliterated lyrics timestamp as a second matching result, and calculate a second matching score according to the successfully matched original lyrics timestamp, transliterated lyrics timestamp, original lyrics and transliterated lyrics; A fusion module, configured to merge the first matching result and the second matching result according to the first matching score and the second matching score to obtain a final matching result; The display module is used to synchronously display the original lyrics and the transliterated lyrics that are successfully matched in the final matching result.
7. The system for synchronously displaying transliterated lyrics according to claim 6, It is characterized in that The first scoring module comprises: The multi-level matching submodule is used to, when the number of original lyrics timestamps is greater than a preset number threshold, use a time window to perform a rough match on the original lyrics timestamps and the transliterated lyrics timestamps to obtain a candidate transliterated lyrics timestamp corresponding to each original lyrics timestamp; perform a fine match on the original lyrics timestamps and the candidate transliterated lyrics timestamps according to a dynamic time warping algorithm to obtain a transliterated lyrics timestamp corresponding to each original lyrics; The single-level matching submodule is used to perform fine matching on the original lyrics timestamps and the transliterated lyrics timestamps according to the dynamic time warping algorithm when the number of original lyrics timestamps is not greater than a preset number threshold, so as to obtain the transliterated lyrics timestamp corresponding to each original lyric.
8. The system for synchronously displaying transliterated lyrics according to claim 7, It is characterized in that The first scoring module includes: A time difference score calculation submodule is used to calculate the time difference score according to the original lyrics timestamp and the transliteration timestamp that are successfully matched; The conversion submodule is used to transcribe the original lyrics that have been successfully matched using the vocabulary comparison table to obtain the transcribed original lyrics; A similarity score calculation submodule, used to calculate the similarity score between the transcribed original lyrics and the corresponding transliterated lyrics using a text similarity algorithm; The comprehensive calculation submodule is used to perform weighted summation on the time difference score and the similarity score to obtain a first matching score.
9. The system for synchronously displaying transliterated lyrics according to claim 8, It is characterized in that The fusion module includes: A first merging submodule is used for timestamping each original lyric, and when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are consistent, the timestamp of the original lyric and the timestamp of the corresponding transliterated lyrics are used as the timestamp pair in the final matching result; The second merging submodule is used to compare the first matching score and the second matching score of the original lyrics timestamp when the timestamps of the transliterated lyrics matched in the first matching result and the second matching result are inconsistent, and select the larger matching score as the candidate matching score; if the candidate matching score is greater than a preset score threshold, the transliterated lyrics timestamp corresponding to the candidate matching score and the original lyrics timestamp are used as the timestamp pair in the final matching result; otherwise, manual transliteration is performed according to the original lyrics corresponding to the original lyrics timestamp to obtain the corresponding transliterated lyrics.
10. The system for synchronously displaying transliterated lyrics according to claim 9, It is characterized in that The display module comprises: The display submodule is used to display the successfully matched original lyrics and transliterated lyrics in double lines and different colors.
