tmoroney / auto-subs

Generate subtitles using OpenAI Whisper in Davinci Resolve editing software.
https://tom-moroney.com/auto-subs/
MIT License
577 stars 34 forks source link

stable_whisper not defined #102

Open Newfies opened 1 week ago

Newfies commented 1 week ago

i tried removing the line "import stable_whisper" and by doing that it actually loads the ui but when it says its transcribing audio it errors name 'stable_whisper' is not defined

but with the line and running it, it doesnt open and errors Traceback (most recent call last): File "C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Utility\auto-subs.py", line 26, in import stable_whisper ModuleNotFoundError: No module named 'stable_whisper'

Zimayet commented 6 days ago

I'm having the same issue.

ismaelvelasco commented 5 days ago

I see you are implementing for Davinci Resolve, so these comments or notes are for it.

I fixed the following problems: not opening the script/no stable-whisper/numpy errors.

I am not getting into pytorch, whisper, nor ffmpeg installation.

I am addressing my Windows 11 "auto-subs.py" not running problem. And how I fixed my particular case. Which I consider to be a problem of correctly finding the folders and libraries paths, in order to run the script.

Check first that you have these two: 1) auto-subs.pyfile inside: C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Utility\auto-subs.pyb 2) stable-ts-main folder in the following path: C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Utility\stable-ts-main

I noticed that my Davinci Resolve 19 console was pointing to Python312. I verified this with the following inputs:
In the Console toggle to Py3 button.
At the bottom of the Console you will see a red input square Type: import sys
then press Enter key Set back again in the red square Type: print("Python Version:", sys.version) then press Enter key.
Now you can check what python version Davinci Resolve 19 is using to load. I assumed that it will try to search for the libraries in that python version. So I searched for python version 312.

It seemed important to me to work with the same version of Python and Davinci Resolve 19. So I addressed my efforts to use the same python version, in my case Python312. Why is this important? Because if you happen to have several Python versions, or even Conda or Miniconda, the order of the environmental variables may be your problem. I moved both user and environmental variables for Python312 just below my nvidia-gpu-cuda variables. So, I updated User and System variables "Path". It might be redundant, but I chose that way to play safe. First add User variables: a) Look for Path variable and double-left-click on it to open, or select it and press Edit button. b) Look for Python312 variable.
If found, move it up with the button "Move Up" up to the top.
If not found, create one variable. Press New button, and add value: C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python312\ Second add System variables a)Look or create a new System variable named: PYTHONPATH.
Press button New, a floating window will open and request two values: Variable name and Variable value. Insert in Variable name: PYTHONPATH.
Insert in Variable value: C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python312 Press OK. b) Insert two new values to PYTHONPATH: Double-Left-Click on PYTHONPATH Press New button Insert value: %PYTHONPATH% Insert value: %RESOLVE_SCRIPT_API%\Modules\ Then press OK. c) Exit all Environmental variables windows with Apply and then OK. If not Apply button, just OK. Many recommend restarting Windows. So after restarting, Run Davinci Resolve 19 and try to run the auto-subs script. If it fails, then add two more System variables. In the System variables section create a new Variable.
Name it: RESOLVE_SCRIPT_API
Value: %PROGRAMDATA%\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting Press OK. Create another System variable Name: RESOLVE_SCRIPT_LIB Value: C:\Program Files\Blackmagic Design\DaVinci Resolve\fusionscript.dll (You need to check your Davinci Resolve path, the one i provide is the general installation) Exit all Environmental variables windows with Apply and then OK. If not Apply button, just OK. Restart Windows

'Hope you can run the script with these updates.

SrTonn commented 5 days ago

@ismaelvelasco after your explanation I noticed that had two python versions in my PC and uninstalled the recent version leaving only the older version and now the script can open. thanks

Zimayet commented 5 days ago

Well, I deleted multiple python (13/12) on my windows. Then installed python 13. Still script not working. Should I install an older version of python? Also , I don't have C:\Program Data\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Utility\stable-ts-main.

ismaelvelasco commented 4 days ago

Well, I deleted multiple python (13/12) on my windows. Then installed python 13. Still script not working. Should I install an older version of python? Also , I don't have C:\Program Data\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Utility\stable-ts-main.

Suggestion Check for Python312 using windows command prompt window: "WINDOWS key " displays the menu, and write "cmd". below the input box, you will see "best match" left-click over "Command Prompt".
A Command Prompt window will open. Type: python, and then prese Enter key. it will display the Python version that is the "first" version your system will call or is recognized. you should see something like the followin: Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

Remember: to look for YOUR python version just after the word "Python", in this example it shows: Python 3.12.4...etc. If yours is Python 3.11.X or 3.10.X, more than likely it won't work for Davinci Resolve 19. Now that you know what python version you have, follow the instructions above and check where it is been run or called from: it could be called from a conda or miniconda environment, and I know for a fact, that I was not able to call the script from neither conda nor miniconda environemnts - maybe it can be run, but I just changed to Python312 program.