m-bain / whisperX

WhisperX: Automatic Speech Recognition with Word-level Timestamps (& Diarization)
BSD 2-Clause "Simplified" License
11.41k stars 1.2k forks source link

UnboundLocalError: local variable 'word_start' referenced before assignment and installing whisperx v3 in google colaboratory #206

Open akashmamun610 opened 1 year ago

akashmamun610 commented 1 year ago

When i run whisperx in google colab it always says , UnboundLocalError: local variable 'word_start' referenced before assignment.

My command was..

Screenshot_20230502-051355 !whisperx "/content/drive/MyDrive/Dvd.mp4" --model large-v2 --language "en"

Performing transcription... Performing alignment... Failed to align segment (" Thank you."): backtrack failed, resorting to original... Traceback (most recent call last): File "/usr/local/bin/whisperx", line 8, in sys.exit(cli()) File "/usr/local/lib/python3.10/site-packages/whisperx/transcribe.py", line 183, in cli result = align(result["segments"], align_model, align_metadata, input_audio, device, interpolate_method=interpolate_method) File "/usr/local/lib/python3.10/site-packages/whisperx/alignment.py", line 442, in align "start": word_start,

UnboundLocalError: local variable 'word_start' referenced before assignment

arnavmehta7 commented 1 year ago

Here's the fix: https://github.com/m-bain/whisperX/pull/208

arnavmehta7 commented 1 year ago

It's merged. Re-install library and it won't occur again :D

akashmamun610 commented 1 year ago

Thanks a lot @arnavmehta7 .. it has worked.. 😊😊😊....

I have also some issues on running whisperx in google colaboratory.. can you help me to fix it ???

Example..

  1. First i have to input this command in google colab.. !pip install -q condacolab import condacolab condacolab.install()

When i input this command then it is working otherwise not... but it restarts the whole running cell.. Screenshot_20230502-190932

  1. When i input this command below in google colab it works.. !conda create --name whisperx python=3.8 !conda activate whisperx

Screenshot_20230502-195213

But it doesn't work in python=3.10 I think whisperx v3 should be work in latest version of python..

  1. when i install torch, torchvision and torchaudio latest version it doesn't work .. it only works when i input below command...

!pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113

Screenshot_20230502-195512

  1. Now when i input the most important command below this..

!pip install git+https://github.com/m-bain/whisperx.git@v3 --upgrade

It install and unstall many things.. Screenshot_20230502-195713

But at the end it always said..

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv WARNING: The following packages were previously imported in this runtime: [cycler,dateutil,google,kiwisolver,matplotlib,mpl_toolkits,six] You must restart the runtime in order to use newly installed versions.

Screenshot_20230502-200340

When i restart the runtime then all my data's have lost and i have to install all these things i said above..

  1. My last input is. !whisperx "/content/drive/MyDrive/dvd" --language "en" --model large-v2 --max_line_count 2 --max_line_width 42 --device "cuda" --batch_size 32 --beam_size 5 --compute_type "float16"

Screenshot_20230502-201050

And it works super super fast.. movie length is about 1 hour 43 minutes and 53 seconds and it transcribes within about 4 minutes.. if batch_size is 32 then it works faster than batch_size 16..

But something i missing is that, VAD, diarize, word _timestamps, highlights word , hf_token is not working in this version.. Also some align segment is missing such as

(Failed to align segment (" Thank you."): backtrack failed, resorting to original) Screenshot_20230502-202154

Can you help me how i can solve all these problems..???? 🤔🤔🤔🤔

Thanks a lot ...

arnavmehta7 commented 1 year ago

You can firstly uninstall torch, torchvision, torchaudio, and also no need of install "condalab". After that directly install whisperx from whisperX repo by running commands in readme.

akashmamun610 commented 1 year ago

Thanks for reply @arnavmehta7

Whisperx v3 does not work on Google colab if you not install condalab.. Screenshot_20230502-221523 It says SyntaxError: invalid syntax

In readme i follow every steps of it.. it does not work in google colaboratory in their method.. in only works for me that i said earlier.. In whisperx setup method..

  1. pip install git+https://github.com/m-bain/whisperx.git@v3 If i input this command then following error occurs....

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. ipython 7.34.0 requires jedi>=0.16, which is not installed. tensorflow 2.12.0 requires protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3, but you have protobuf 3.20.1 which is incompatible. Successfully installed av-10.0.0 coloredlogs-15.0.1 ctranslate2-3.13.0

Screenshot_20230502-223923

2.. if i install torch in whisperx method following error also occur

!pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. torchdata 0.6.0 requires torch==2.0.0, but you have torch 1.11.0+cu113 which is incompatible. torchtext 0.15.1 requires torch==2.0.0, but you have torch 1.11.0+cu113 which is incompatible.

Screenshot_20230502-224541

  1. Last input..

!Whisperx "/content/drive/MyDrive/Dvd" --language "en" --model large-v2

It says.. /bin/bash: Whisperx: command not found Screenshot_20230502-224832