Bug 491350 - Automatic Subtitling with Whisper does not work on Windows 10
Summary: Automatic Subtitling with Whisper does not work on Windows 10
Status: CONFIRMED
Alias: None
Product: kdenlive
Classification: Applications
Component: Video Effects & Transitions (show other bugs)
Version: 24.05.2
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL: https://www.reddit.com/r/kdenlive/com...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-06 12:42 UTC by Zeth
Modified: 2024-08-14 19:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zeth 2024-08-06 12:42:44 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
When attempt to initialize the aforementioned process, dialogue window notifies me (irrespective of which Whisper model is used) "Subtitling Imported" and log spits out errors.

STEPS TO REPRODUCE
1. Load up a video, use Speech Recognition
2. In the Automatic Subtitling window with Whisper > Process (reproducible with any option);
3. "Subtitling Imported" > See Log >

OBSERVED RESULT

Traceback (most recent call last):
File "C:\Program Files\kdenlive\bin\data\kdenlive\scripts\whispertosrt.py", line 9, in <module>
import whispertotext
File "C:\Program Files\kdenlive\bin\data\kdenlive\scripts\whispertotext.py", line 13, in <module>
import torch
File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\__init__.py", line 148, in <module>
raise err
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

EXPECTED RESULT

Subtitles generated on the timeline.

SOFTWARE/OS VERSIONS
Windows: 10;

ADDITIONAL INFORMATION

Python was installed with PATH option on the installer selected;
Comment 1 Jean-Baptiste Mardelle 2024-08-13 09:33:14 UTC
Git commit 79045d36f909cbbda9ea5ad1f402f5eb0441d814 by Jean-Baptiste Mardelle.
Committed on 13/08/2024 at 09:32.
Pushed by mardelle into branch 'release/24.08'.

Switch openai installer to python requirements files, allowing to fix numpy error on Windows

M  +3    -0    data/scripts/CMakeLists.txt
M  +15   -5    data/scripts/checkpackages.py
A  +3    -0    data/scripts/requirements-seamless.txt
A  +5    -0    data/scripts/requirements-whisper-windows.txt
A  +4    -0    data/scripts/requirements-whisper.txt
M  +47   -9    src/pythoninterfaces/abstractpythoninterface.cpp
M  +1    -0    src/pythoninterfaces/abstractpythoninterface.h
M  +12   -7    src/pythoninterfaces/speechtotext.cpp

https://invent.kde.org/multimedia/kdenlive/-/commit/79045d36f909cbbda9ea5ad1f402f5eb0441d814
Comment 2 Jean-Baptiste Mardelle 2024-08-13 11:20:58 UTC
There are currently 2 issues with Whisper on Windows.
The problem you are experiencing is related to torch and python 3.12, and is caused by a missing dll. I don't know why this happens and don't think there is anything we can do from Kdenlive's side.

The solution is to copy the missing dll (libomp140.x86_64.dll) to the torch folder:
C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\lib\

This library can be downloaded from:
https://www.dllme.com/dll/files/libomp140_x86_64

The other problem, that you will experience once this is solved, is an incompatibility between torch and the latest versions of numpy / numba, see the bug report for solution:
https://bugs.kde.org/show_bug.cgi?id=490661
Comment 3 Zeth 2024-08-14 19:36:10 UTC
That does it! Twenty minutes later and my video document is correctly and almost effortlessly subtitled. There is only one snag, a note really. Whisper still spits out an error in the log, despite functioning:

"C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\whisper\__init__.py:146: 

FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details).
In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
  checkpoint = torch.load(fp, map_location=device)"

Should I be worried? From what I understand, the program is warning me that an update might break a functionality?

Thank you for the fix!!