Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate: Malformed #2519

Closed
gianfelicevincenzo opened this issue Jun 8, 2024 · 30 comments
Closed

Translate: Malformed #2519

gianfelicevincenzo opened this issue Jun 8, 2024 · 30 comments

Comments

@gianfelicevincenzo
Copy link

gianfelicevincenzo commented Jun 8, 2024

Describe the bug
Translate from english to italian. Error report in log is:

BAZARR is unable to translate malformed subtitles: /media/plex/film/moviemedia/Sadistic - The Exorcism Of Lily Deckert (2022) {imdb-tt11443106}/Sadistic - The Exorcism Of Lily Deckert (2022) {imdb-tt11443106}.srt

To Reproduce
Steps to reproduce the behavior:

  1. Go to Movie
  2. Click on '...'
  3. Click in menu on Translate
  4. Choose language italian

Expected behavior
Translated movie subtitle

Software (please complete the following information):

  • Bazarr: v1.4.3 2024-06-02 MASTER

subs.txt

@morpheus65535
Copy link
Owner

Your subtitles is probably malformed as stated in log. I've just test with a random subtitles and it works as expected.

image

@BramFr
Copy link

BramFr commented Jun 18, 2024

Your subtitles is probably malformed as stated in log. I've just test with a random subtitles and it works as expected.

Wat do you mean with malformd? I have the same issue with almost every subs. I`m trying translate to dutch.

Version: v1.4.3-ls254 by linuxserver.io

BAZARR is unable to translate malformed subtitles: /mnt/nfs/01-Movies/Late Night with the Devil (2024) {imdb-tt14966898}/Late Night with the Devil (2024) {imdb-tt14966898} [WEBDL-1080p][EAC3 5.1][h264]-BYNDR.en.srt

@resuarez
Copy link

resuarez commented Jun 20, 2024

I have the same problem, using same Version: v1.4.3-ls254 by linuxserver.io
I am trying to translate to french, though. The curious works to spanish (the current spanish subtitles was translated without problem from the same english source), but someway, the french is not working. It happens often with the tv shows.
bazarr.log

@resuarez
Copy link

Just create a new log using common fixes in the source subtitles and trying to translate, finally, after couple tries, it worked
bazarr-with-translation.log
Checking between the original subtitles and the fixed copy, I've found this difference
image

However, I want to point that the file was translated initially to spanish without problem
So, I don't think that it is the problem
image

@resuarez
Copy link

Just try with another show, I usually translate to french and spanish. And this time, the french was translated, but not the spanish
bazarr-evil.log
I hope it helps.

@napalmpt
Copy link

I had this happen to me too, in my case I look at the subtitles and find many "—" at end of sentences. remove them all and then it was able to translate

@resuarez
Copy link

I will check. However, previous version worked flawless. So, something changed in the code.

@morpheus65535
Copy link
Owner

I've been able to reproduce the issue with a subtitles. I've made a small fix that seems to correct the issue on my side. Can you test upcoming beta and let me know?

@resuarez
Copy link

I've just tested the v1.4.4-beta.11 and I cannot reproduce the issue. However, I would like to do more testing. I will update any findings. Thank you for your work and help.

@resuarez
Copy link

I cannot reproduce the issue with the v1.4.4-beta.11. For my side, I think the problem was solved. Thank you again

@morpheus65535
Copy link
Owner

@vincenzogianfelice can I close this issue as fixed?

@gianfelicevincenzo
Copy link
Author

@morpheus65535 I'll check in a couple of days and let you know. I can not at the moment

@morpheus65535
Copy link
Owner

No news, good news!

@Manny8787
Copy link

I am having this same problem, English to French. Did anyone find a fix?

@gianfelicevincenzo
Copy link
Author

@morpheus65535 From the little I've tried (same film and same subtitles) the problem hasn't recurred. I will keep you updated if there are any problems. Sorry but between holidays and work now I don't have much time!

@helissonms
Copy link

I am having this same problem, English to Portuguese.
Even applying "Common Fixes" is not solving the problem.

Version: v1.4.4-beta.30

@resuarez
Copy link

I had some problems too. But, it is more rare and complicated to reproduce. I usually translate from English to French and Spanish and I get one of the language translated, but the other not. I have to modify the original in other to get the second language translated. However, I didn't report it because I cannot reproduce the issue a will, like before

@resuarez
Copy link

Finally, I was capable to reproduce the issue. I have this srt (from unknown movie)
Angels Fallen Warriors of Peace (2024) [WEBRip-720p] [YTS.MX].en.zip
And the log with the error:
bazarr.log
If I open the subtitle with Subtitle editor software, it doesn't show any problem, and even, I can translate with its tool without any issue. The subtitle, I think is the shd type, with a lot of words between square brackets. Not sure if it is the problem. Or maybe an special character.

@elektron303
Copy link

I also have this problem, English to Thai. With almost all the translations. Sometimes I can try 3-4 times and then it works, but sometimes even after multiple attemps it won't translate. Applying "Common Fixes" is not solving the problem.

Version: v1.4.3

@driesmp
Copy link

driesmp commented Aug 13, 2024

English to Dutch here same error, I'm on version 1.4.3. I just tested the committed fix, 9049ab2; and it works.

@TheWalkingDadNL
Copy link

English to Dutch here same error, I'm on version 1.4.3. I just tested the committed fix, 9049ab2; and it works.

Yes, this also did the trick for me. Had problems translating from English to Dutch also. I run in Docker. What i did:

Log in to docker container with: docker exec -it bazarr bash
Edit the file translate.py in directory: /app/bazarr/bin/bazarr/subtitles/tools
Restart container

After that it works.

Also a side node. there is a line (47) with:

joined_lines_str = '\n\n\n'.join(lines_list)

I did not change this line. I only change like described in: 9049ab2

@helissonms
Copy link

I'm testing it on the development branch, where there is this solution, but it doesn't work.

@elektron303
Copy link

I applied the fix 9049ab2
It was working for some days. Now I have the issue again.

@morpheus65535
Copy link
Owner

It was working for some days. Now I have the issue again.

Provide a new debug log reproducing the issue. I can't do anything with "I have the issue again".

@elektron303
Copy link

bazarr.log
I applied the fix like mentioned here #2519 (comment)

@morpheus65535
Copy link
Owner

I applied the fix like mentioned here #2519 (comment)

2024-09-02 14:28:17|DEBUG |root |Bazarr version: 1.4.3|

You can't simply apply the fix, it will get overwritten. You either switch to nightly (dev branch) or you stay with master but you can't patch ti as you want.

Anyway, the translation process has been refactored and the fix you applied doesn't work anymore.

@elektron303
Copy link

elektron303 commented Sep 2, 2024

That makes sense. Thank you!
EDIT: I switched to the dev branch. I'm on v1.4.4-beta.39 - Works flawless. Thank you again :)

@resuarez
Copy link

resuarez commented Oct 15, 2024

I've been experiencing issues with some translations, I am using the latest beta version, particularly when handling special characters like "♪♪". After a detailed analysis, I've discovered that the problem lies with certain symbols. To further investigate, I added additional logging to the translate.py script to pinpoint the issue.

Here's an example from the log:

Exception on /api/subtitles [PATCH] | 2024-10-15 06:15:28
-- | -- | --
line_list=None | 2024-10-15 06:15:28 |
i=6 line=<SSAEvent type=Dialogue start=0:00:14 end=0:00:21 text='♪♪'> | 2024-10-15 06:15:28 | 
line_list=[Acclamations et applaudissements] | 2024-10-15 06:15:28 |  
i=5 line=<SSAEvent type=Dialogue start=0:00:12 end=0:00:14 text='[Cheers and applause]'> | 2024-10-15 06:15:28 |  
line_list=C'est l'heure du « Scrabble ». | 2024-10-15 06:15:28 |  
i=4 line=<SSAEvent type=Dialogue start=0:00:09 end=0:00:12 text='It\'s time for "Scrabble."'> | 2024-10-15 06:15:28 |  
line_list=pour avoir une chance de gagner jusqu'à 10 000 $. | 2024-10-15 06:15:28 |  
i=3 line=<SSAEvent type=Dialogue start=0:00:06 end=0:00:09 text='for their chance to win\\Nup to $10,000.'> | 2024-10-15 06:15:28 |  
line_list=ces deux détectives de l'orthographe s'affrontent | 2024-10-15 06:15:28 |  
i=2 line=<SSAEvent type=Dialogue start=0:00:04 end=0:00:06 text='these two spelling sleuths\\Nare going head to head'> | 2024-10-15 06:15:28 |  
line_list=Et bien, nos joueurs aussi. Et ce soir, | 2024-10-15 06:15:28 |  
i=1 line=<SSAEvent type=Dialogue start=0:00:02 end=0:00:04 text='Well, so do our players.\\NAnd tonight,'> | 2024-10-15 06:15:28 |  
line_list=-Tu penses avoir un don avec les mots ? | 2024-10-15 06:15:28 |  
i=0 line=<SSAEvent type=Dialogue start=0:00:01 end=0:00:02 text='-Think you have a way\\Nwith words?'> | 2024-10-15 06:15:28 |  
BAZARR Log file emptied

As you can see, the original text is '♪♪', but the translated text is None, which leads to a replacement failure and results in the following error:

Exception on /api/subtitles [PATCH] Traceback (most recent call last):
File "/app/bazarr/bin/bazarr/../libs/flask/app.py", line 870, in full_dispatch_request
    rv = self.dispatch_request()
File "/app/bazarr/bin/bazarr/../libs/flask/app.py", line 855, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/app/bazarr/bin/bazarr/../libs/flask_restx/api.py", line 402, in wrapper
    resp = resource(*args, **kwargs)
File "/app/bazarr/bin/bazarr/../libs/flask/views.py", line 110, in view
    return current_app.ensure_sync(self.dispatch_request)(**kwargs)
File "/app/bazarr/bin/bazarr/../libs/flask_restx/resource.py", line 41, in dispatch_request
    resp = meth(*args, **kwargs)
File "/app/bazarr/bin/bazarr/api/utils.py", line 30, in wrapper
    return actual_method(*args, **kwargs)
File "/app/bazarr/bin/bazarr/api/subtitles/subtitles.py", line 175, in patch
    translate_subtitles_file(video_path=video_path, source_srt_file=subtitles_path,
File "/app/bazarr/bin/bazarr/subtitles/tools/translate.py", line 103, in translate_subtitles_file
    line.plaintext = lines_list[i]
File "/app/bazarr/bin/bazarr/../libs/pysubs2/ssaevent.py", line 115, in plaintext
    self.text = text.replace("\\n", r"\\N")
AttributeError: 'NoneType' object has no attribute 'replace'

Hope this help.

If you need the original str, let me know.

@morpheus65535
Copy link
Owner

@resuarez it should be fixed in upcoming beta. Thanks for reporting.

@resuarez
Copy link

That is great, I will test it. If I find anything, I will report it. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants