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

Error with Japanese subtitles #15

Closed
rsmith02ct opened this issue Apr 14, 2023 · 40 comments
Closed

Error with Japanese subtitles #15

rsmith02ct opened this issue Apr 14, 2023 · 40 comments

Comments

@rsmith02ct
Copy link

I'm attempting to generate text for Japanese audio through SubtitleEdit but getting this error which appears to be a python issue with the characters:

Date: 04/14/2023 13:57:40
SE: 3.6.12.62 - Microsoft Windows NT 10.0.22621.0 - 64-bit
Message: Calling whisper (CTranslate2) with : C:\Users\rsmit\Dropbox\transfer settings\Whisper-Faster\Whisper-Faster\whisper-ctranslate2.exe --language ja --model "large" "D:\Temp\3787e9c7-46dd-4055-aa58-377ada7b89e0.wav"
UnicodeEncodeError: 'charmap' codec can't encode characters in position 26-45: character maps to

File "encodings\cp1252.py", line 19, in encode

File "D:\whisper-fast_main_.py", line 399, in cli

File "D:\whisper-fast_main_.py", line 406, in

Traceback (most recent call last):

[3696] Failed to execute script 'main' due to unhandled exception!

Calling whisper CTranslate2 done in 00:00:09.1675218
Loading result from STDOUT

@jordimas
Copy link
Collaborator

Thanks for reporting this.

Do you have more details of the errors? Can you share if more things are displayed? (e.g. Traceback (most recent call last):)

Does the problem appear if you execute the application with the parameter "--verbose False"?

Finally, will be possible to share a file that allows me to reproduce the problem?

Thanks

@rsmith02ct
Copy link
Author

rsmith02ct commented Apr 14, 2023 via email

@jordimas
Copy link
Collaborator

Try with --device cuda --language ja --model "base" --verbose False

To see if makes any difference. Thanks

@rsmith02ct
Copy link
Author

rsmith02ct commented Apr 14, 2023 via email

@jordimas
Copy link
Collaborator

Thanks

I cannot see the image that you shared.

My understading is that now it did finished but no contents on the files. Correct?

@rsmith02ct
Copy link
Author

Screenshot 2023-04-14 16 35 47
Sorry about that, though I could just do it from email.

It just gave a few repeated garbage characters and no file that I could find (nothing in the source footage folder or Faster Whisper folder).

@jordimas
Copy link
Collaborator

Thanks, let me have a a look in the next days and come back to you.

@rsmith02ct
Copy link
Author

I appreciate it and and am happy to perform more tests to isolate the issue.

@jordimas
Copy link
Collaborator

I did a test in Windows an it works for me:

Captura de pantalla 2023-04-14 a les 15 31 13

Can you check which version of whisper-ctranslate2 are you running? Just type whisper-ctranslate2 --version

@rsmith02ct
Copy link
Author

rsmith02ct commented Apr 14, 2023 via email

@jordimas
Copy link
Collaborator

jordimas commented Apr 14, 2023

You are not executing whisper-ctranslate2, you are really executing OpenAI whisper client. I guess that you renamed the binary or similar.

As you can see below whisper-ctranslate2 has more options that you are showing. You are not running whisper-ctranslate2

Captura de pantalla de 2023-04-14 16-07-15

@rsmith02ct
Copy link
Author

Thank you for confirming that, I'll ask the person who made this binary what it is as I'm just a user trying to test implementations for Subtitle Edit.

@ras0k
Copy link

ras0k commented Apr 14, 2023

Thank you for confirming that, I'll ask the person who made this binary what it is as I'm just a user trying to test implementations for Subtitle Edit.

maybe the person had malicious intent, faster-whisper is just a branding (to help understand the intent of creating a faster (more compressed) whisper), the actual software you would interact with (through CLI) is called whisper-cTranslate2

@rsmith02ct
Copy link
Author

Okay, I'm trying to do this properly and installed it from git.

whisper-ctranslate2 --version
whisper-ctranslate2 0.1.8

Is that a proper one?

@jordimas
Copy link
Collaborator

Yes, this is the last version. Great!

@Purfview
Copy link

OP meant that the standalone executables compiled with pyinstaller fails with that error on Japanese in SubtitleEdit.
When OP didn't used a compile from this repo, same "UnicodeEncodeError" error is produced with a compile from this repo too.

I'm pretty rusty on Python, need to read up why it happens.

@jordimas
Copy link
Collaborator

@Purfview Some questions:

  • Can you run whisper-ctranslate2 --version and report the version?
  • What steps can I follow to setup whisper-ctranslate2 to work with SubtitleEdit as you guys are doing?

Thanks

@Purfview
Copy link

Purfview commented Apr 16, 2023

It reported whisper 0.1.9.

Get SE beta: https://github.com/SubtitleEdit/subtitleedit/releases/download/3.6.12/SubtitleEditBeta.zip
Your repo compiled [CPU only]: whisper-ctranslate2.exe
Short Japanese sample: test_ja.wav

Then it's usual, SE will ask you to point to whisper-ctranslate2.exe, do Japanese transcription, see error output in SE's root in file error_log.txt.

EDIT:
Don't copy SE beta to Window's folders!

@rsmith02ct
Copy link
Author

For SubtitleEdit you need the current beta (standalone): https://github.com/SubtitleEdit/subtitleedit/releases
Then go to video/audio to text Whisper. For engine select ctranslate2. Models should be in the default folder. Then just add a file and hit generate.

I think if it didn't default to CUDA it would likely work as is here.

@Purfview
Copy link

I think if it didn't default to CUDA it would likely work as is here.

No, "CPU only" can't default to CUDA.

@rsmith02ct
Copy link
Author

rsmith02ct commented Apr 16, 2023

I'm using "whisper-ctranslate2 0.1.8" and from the command line with --device CPU it functions here.
If that device preference is not set it appears to default to CUDA and does not generate any text here.

@Purfview
Copy link

Purfview commented Apr 16, 2023

@rsmith02ct Maybe you are mixing the issues because in SE you can't set any custom commands.

@rsmith02ct
Copy link
Author

SE must send commands to the CLI executable- how else is the model type set? (and probably output type and location?) We just can't control what it sends.

@Purfview
Copy link

Purfview commented Apr 16, 2023

In SE you can select only language, model and audio file, only those are sent as command [I think].

@jordimas
Copy link
Collaborator

jordimas commented Apr 16, 2023

Your repo compiled [CPU only]: whisper-ctranslate2.exe

I will suggest to install it using:

pip install -U whisper-ctranslate2

If you can please open a separate bug report for your issue. We are mixing here different configurations what makes difficult to debug. Please describe in the report your version of Windows, screen captures and all details that you can provide. Thanks

@Purfview
Copy link

Purfview commented Apr 16, 2023

I personally don't have issue as I don't use SE or this repo.
I'm not sure what other "configuration" you are trying to debug when my post is the only "configuration" here related to the actual issue.

@Purfview
Copy link

I will suggest to install it using:

pip install -U whisper-ctranslate2

I'm sure it would produce same error.

@keimaruO
Copy link

I'm also experiencing the same issue with Japanese subtitles. I've been using version 0.1.1 as a workaround. You might want to try this version too. Here's how to install it:

Uninstall command:

pip uninstall whisper-ctranslate2

Install version 0.1.1:

pip install git+https://github.com/jordimas/whisper-ctranslate2.git@0.1.1

I hope this helps!

@Purfview
Copy link

I'm also experiencing the same issue with Japanese subtitles. I've been using version 0.1.1 as a workaround.

Strange, did you meant "the same issue" in SubtitleEdit?
Check if standalone executable works from there: https://github.com/Purfview/whisper-standalone-win/releases

@jordimas
Copy link
Collaborator

My current hypothesis is there is a problem with CTranslate2 and GPU on Windows due to CUDA or CTranslate2.

In order to validate or invalidate this hypothesis I will ask you if you can try to run this simple code:

https://github.com/jordimas/calaix-de-sastre/blob/master/faster-whisper/inference.py

And tell me if you can reproduce the problem with this simple code. Thanks

@rsmith02ct
Copy link
Author

I think there is some issue. After installing CUDA 12, CUDA 11, CUDNN, adding things to path, etc. still no luck with ctranslate2 and CUDA.

How can I execute the code?

@jordimas
Copy link
Collaborator

jordimas commented Apr 21, 2023

Sure

  1. Download https://github.com/jordimas/calaix-de-sastre/blob/master/faster-whisper/inference.py
  2. Run it with python inference.py

@rsmith02ct
Copy link
Author

rsmith02ct commented Apr 21, 2023 via email

@jordimas
Copy link
Collaborator

Look inside the file inference.py (open it with notepad), it looks like you download the HTML instead of the file.

@rsmith02ct
Copy link
Author

That makes sense. I opened with notepad and pasted in the code, downloaded the mp3 here and changed the name to file.mp3.

image

@jordimas
Copy link
Collaborator

Yes, you need to have in the same directory the file "file.mp3" which is giving you problems. (the file that I have there is for testing proposes).

The goal here is to see if you can reproduce the same problem observed in whisper-ctranslate2 with this simple version. Thanks

@rsmith02ct
Copy link
Author

rsmith02ct commented Apr 21, 2023

Thanks for being patient with me. Haven't really used a CLI since the days of Windows 95 or programmed anything since Pascal.

I edited the py from file.mp3 to file.mp4 and added a file I had used for testing before. It transcribed 65s of a 2min 35s file (English). I ran it on a Japanese video and it also worked very quickly and accurately for ~60s.

@rsmith02ct
Copy link
Author

I see a big spike in GPU 3D activity so CUDA appears to be working.

@jordimas
Copy link
Collaborator

jordimas commented Jun 6, 2023

Version 0.2.6 should fix this.

@rsmith02ct
Copy link
Author

Thank you for the update- it seems to be 0.2.7 and now works with CUDA. (though it is now case-specific for cpu and cuda and doesn't want uppercase anymore).

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

No branches or pull requests

5 participants