[Feature Request]: Romanized Lyrics using Goolgle Translate API #3329

Open
opened 2025-05-06 14:42:37 +00:00 by AMZMA · 6 comments
AMZMA commented 2025-05-06 14:42:37 +00:00 (Migrated from github.com)

Preflight Checklist

  • I use the latest version of YouTube Music (Application).
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

using google translate to Romanized/Pronunciation/Transliteration the lyrics for any non roman text language.

Image

Proposed Solution

for reference:
https://github.com/ssut/py-googletrans
https://github.com/therealbush/translator

Alternatives Considered

thank you.

Additional Information

No response

### Preflight Checklist - [x] I use the latest version of YouTube Music (Application). - [x] I have searched the [issue tracker](https://github.com/th-ch/youtube-music/issues) for a feature request that matches the one I want to file, without success. ### Problem Description using google translate to Romanized/Pronunciation/Transliteration the lyrics for any non roman text language. ![Image](https://github.com/user-attachments/assets/10c69d8c-6131-40c2-894a-8dd31e24c9ab) ### Proposed Solution for reference: https://github.com/ssut/py-googletrans https://github.com/therealbush/translator ### Alternatives Considered thank you. ### Additional Information _No response_
Owner

py-googletrans looks promising

I've already tried various Google translate endpoints in the past w/o success, will give this a look later

py-googletrans looks promising I've already tried various Google translate endpoints in the past w/o success, will give this a look later
AMZMA commented 2025-05-06 15:57:27 +00:00 (Migrated from github.com)

I've been doing this manually using Google Translate with MacroDroid on my phone.
I just copy all the lyrics (from LrcLib or Kugou) along with their timecodes, then paste them into Google Translate via browser.
I replace the newline and space characters beforehand using regex.

I'm not sure if this is helpful, though.

I've been doing this manually using Google Translate with MacroDroid on my phone. I just copy all the lyrics (from LrcLib or Kugou) along with their timecodes, then paste them into Google Translate via browser. I replace the newline and space characters beforehand using regex. I'm not sure if this is helpful, though.
Owner

py-googletrans somewhat works, although translation.pronunciation is always None, but in translation.extra_data I can see the romaji

input: 獣は砂を一握り撒いた
output:

{
  "translation": [
    [
      "The beast spread a handful of sand",
      "獣は砂を一握り撒いた",
      null,
      null,
      3,
      null,
      null,
      [
        [
          null,
          "offline"
        ]
      ],
      [
        [
          [
            "b8e89a82d2c70a0f411a34d09528c227",
            "offline_launch_doc.md"
          ]
        ]
      ]
    ],
    [
      null,
      null,
      null,
      "Kemono wa suna o hitonigiri maita"
    ]
  ],
  "all-translations": null,
  "original-language": "ja",
  "possible-translations": [
    [
      "獣は砂を一握り撒いた",
      null,
      [
        [
          "The beast spread a handful of sand",
          null,
          true,
          false,
          [
            3
          ],
          null,
          [
            [
              3
            ]
          ]
        ]
      ],
      [
        [
          0,
          10
        ]
      ],
      "獣は砂を一握り撒いた",
      0,
      0
    ]
  ],
  "confidence": 1,
  "possible-mistakes": null,
  "language": [
    [
      "ja"
    ],
    null,
    [
      1
    ],
    [
      "ja"
    ]
  ],
  "synonyms": null,
  "definitions": null,
  "examples": null,
  "see-also": null
}
`py-googletrans` somewhat works, although `translation.pronunciation` is always None, but in `translation.extra_data` I can see the romaji input: `獣は砂を一握り撒いた` output: ```json { "translation": [ [ "The beast spread a handful of sand", "獣は砂を一握り撒いた", null, null, 3, null, null, [ [ null, "offline" ] ], [ [ [ "b8e89a82d2c70a0f411a34d09528c227", "offline_launch_doc.md" ] ] ] ], [ null, null, null, "Kemono wa suna o hitonigiri maita" ] ], "all-translations": null, "original-language": "ja", "possible-translations": [ [ "獣は砂を一握り撒いた", null, [ [ "The beast spread a handful of sand", null, true, false, [ 3 ], null, [ [ 3 ] ] ] ], [ [ 0, 10 ] ], "獣は砂を一握り撒いた", 0, 0 ] ], "confidence": 1, "possible-mistakes": null, "language": [ [ "ja" ], null, [ 1 ], [ "ja" ] ], "synonyms": null, "definitions": null, "examples": null, "see-also": null } ```
Owner

What remains to be figured out is, how can we reliably get the romanization from that json?
Is the json always consistent?
Why is py-googletrans not detecting the pronunciation?

What remains to be figured out is, how can we reliably get the romanization from that json? Is the json always consistent? Why is py-googletrans not detecting the pronunciation?
AMZMA commented 2025-05-07 11:32:56 +00:00 (Migrated from github.com)
https://github.com/fast4x/RiMusic/ have been doing this, no problem so far. https://github.com/fast4x/RiMusic/blob/master/composeApp/src/androidMain/kotlin/it/fast4x/rimusic/ui/screens/player/Lyrics.kt begin at line 399.
h-banii commented 2025-05-09 22:52:03 +00:00 (Migrated from github.com)

👀

  • sl=auto: source language
  • client: idk, but it's required
  • dt=rm: transliteration
  • dj=1: nice json key names
curl \
  -G 'https://translate.google.com/translate_a/single' \
  -d 'sl=auto' \
  -d 'client=gtx' \
  -d 'dt=rm' \
  -d 'dj=1' \
  --data-urlencode "q=獣は砂を一握り撒いた"
{
  "sentences": [
    {
      "src_translit": "Kemono wa suna o hitonigiri maita"
    }
  ],
  "src": "ja",
  "confidence": 1.0,
  "spell": {},
  "ld_result": {
    "srclangs": [
      "ja"
    ],
    "srclangs_confidences": [
      1.0
    ],
    "extended_srclangs": [
      "ja"
    ]
  }
}
👀 - sl=auto: source language - client: idk, but it's required - dt=rm: transliteration - dj=1: nice json key names ```sh curl \ -G 'https://translate.google.com/translate_a/single' \ -d 'sl=auto' \ -d 'client=gtx' \ -d 'dt=rm' \ -d 'dj=1' \ --data-urlencode "q=獣は砂を一握り撒いた" ``` ```json { "sentences": [ { "src_translit": "Kemono wa suna o hitonigiri maita" } ], "src": "ja", "confidence": 1.0, "spell": {}, "ld_result": { "srclangs": [ "ja" ], "srclangs_confidences": [ 1.0 ], "extended_srclangs": [ "ja" ] } } ```
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: YTMD/youtube-music#3329
No description provided.