# Creating Synced Lyrics with Translations by merging with another field

**URL:** https://community.mp3tag.de/t/creating-synced-lyrics-with-translations-by-merging-with-another-field/66389
**Category:** General Discussion
**Created:** [October 31, 2024, 4:54pm UTC](https://community.mp3tag.de/t/creating-synced-lyrics-with-translations-by-merging-with-another-field/66389 "2024-10-31T16:54:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mista\_j](https://community.mp3tag.de/user_avatar/community.mp3tag.de/mista_j/32/15808_2.png) [@mista\_j](https://community.mp3tag.de/u/mista_j)
#### Post date: [October 31, 2024, 4:54pm UTC](https://community.mp3tag.de/t/creating-synced-lyrics-with-translations-by-merging-with-another-field/66389/1 "2024-10-31T16:54:50Z")

</div>

I'd like to shuffle / zip two fields together.

Allow me to explain. My music player now supports non timestamped lines in synced lyrics.

So this:  
[00:00.00] Agua  
Water

Means both those lines will appear at the timestamp with the timestamped line being bold, which is cool.

To create these synced lyrics with translations I was manually inserting the translated lines one by one if i could not find a synced lyrics file that already features translation.

If possible i'd like to place the synced lyrics in one field. The translated lyrics in another field & have them shuffled together like a deck of playing cards, joined together in a zipper fashion.

So if:  
Field 1=  
[00:00.00] A  
[00:01.00] B  
[00:02.00] C

Field 2=  
1  
2  
3

I want Field 3=  
[00:00.00] A  
1  
[00:01.00] B  
2  
[00:02.00] C  
3

I was first thinking of using a spreadsheet & some simple formulas to accomplish this as I don't know how to script & have yet to figure regex out. I feel mp3tag is probably powerful enough to do this I just havent gotten the right idea.

Any suggestions would be greatly appreciated!

---

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [October 31, 2024, 5:33pm UTC](https://community.mp3tag.de/t/creating-synced-lyrics-with-translations-by-merging-with-another-field/66389/2 "2024-10-31T17:33:12Z")

</div>

In case no one provides an mp3tag solution, here's a simple python script I just created with the help of ChatGPT for this purpose.

```auto
def zip_files(file_a_path, file_b_path, output_path):
    # Open both files with UTF-8 encoding and read the lines
    with open(file_a_path, 'r', encoding='utf-8') as file_a, open(file_b_path, 'r', encoding='utf-8') as file_b:
        lines_a = file_a.readlines()
        lines_b = file_b.readlines()
        
        # Check if line counts match
        if len(lines_a) != len(lines_b):
            print("The files have different line counts and cannot be zipped together.")
            return
        
        # Open the output file with UTF-8 encoding to write the zipped lines
        with open(output_path, 'w', encoding='utf-8') as output_file:
            for line_a, line_b in zip(lines_a, lines_b):
                # Strip newline characters and format output
                output_file.write(f"{line_a.strip()}\n{line_b.strip()}\n")

    print("Files have been zipped successfully!")

# Example usage:
zip_files('original language.txt', 'translation.txt', 'output.lrc')

```

Save this as `zipme.py` (or whatever name you like) in a folder.  
Then create 2 .txt files in the same folder that you name `original language.txt` and `translation.txt`  
Open both in a text editor and save the original lyrics to `original language.txt` and the translation to `translation.txt`. Ensure that the line count of both is identical. Then open a cmd window in that folder (CTRL+L → `cmd` → ENTER) followed by `zipme.py` → ENTER  
That ought to create a new file called output.lrc with the results you want.  
If you keep all 3 files open in a text editor that detects changes like Notepad++ that should be relatively quick.

For the test case you provided:  
original language.txt =

```auto
[00:00.00] A
[00:01.00] B
[00:02.00] C

```

translation.txt =

```auto
1
2
3

```

it yielded output.lrc =

```auto
[00:00.00] A
1
[00:01.00] B
2
[00:02.00] C
3

```

I have not tested it further than that. I'd be curious how this can be solved in Mp3tag.

---

<div class="post-metadata">

### Author: ![mista\_j](https://community.mp3tag.de/user_avatar/community.mp3tag.de/mista_j/32/15808_2.png) [@mista\_j](https://community.mp3tag.de/u/mista_j)
#### Post date: [October 31, 2024, 5:48pm UTC](https://community.mp3tag.de/t/creating-synced-lyrics-with-translations-by-merging-with-another-field/66389/3 "2024-10-31T17:48:41Z")

</div>

Oh nice! Thank You so much! I'll have to give this a go.

I'm also curious if/how this could be done in mp3tag. If not I think this should work exactly as planned.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [November 1, 2024, 8:08am UTC](https://community.mp3tag.de/t/creating-synced-lyrics-with-translations-by-merging-with-another-field/66389/5 "2024-11-01T08:08:26Z")

</div>

> [@mista\_j](#):
>
> I'm also curious if/how this could be done in mp3tag.

I do not know any function in MP3tag that has a loop which terminates after a certain condition has been met.  
As far as I understand regular expressions they are meant to deal with fixed patterns but not variable amounts of data - which would mean in this case: one would have to count the lines and then add as many groups in the expression.  
Which would lead me to the assumption that the problem cannot be solved with MP3tag functions in a flexible way.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [December 1, 2024, 8:08am UTC](https://community.mp3tag.de/t/creating-synced-lyrics-with-translations-by-merging-with-another-field/66389/6 "2024-12-01T08:08:33Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
