linto-ai / whisper-timestamped

Multilingual Automatic Speech Recognition with word-level timestamps and confidence
GNU Affero General Public License v3.0
2.01k stars 156 forks source link

Install whisper-timestamped with only CPU dependencies #68

Closed agorman closed 1 year ago

agorman commented 1 year ago

Is there a way to install whisper-timestamped with only dependencies required for CPU processing?

This change to requirements adds some very large packages as dependencies that don't appear to be required when not using GPU. I'm avoiding this now by doing the following.

Install whisper avoiding GPU deps

pip install torch-1.13.1+cpu-cp39-cp39-linux_x86_64.whl
pip install git+https://github.com/openai/whisper.git

Install whisper-timestamped avoiding GPU deps

pip install Cython dtw-python
pip install --no-deps git+https://github.com/linto-ai/whisper-timestamped

This isn't a great solution for whisper-timestamped because if you add other needed dependencies to requirements.txt it will fail.

Jeronymous commented 1 year ago

Thanks, that's a good suggestion. Indeed a lot of useless things can get installed when running on CPU only.

Concerning the recently added requirements you point, onnxruntime and torchaudio are needed when using the --vad option (VAD is not by default). Maybe I should put them in the "extras_require" of the setup, but I find this a bit awkward. Hmm, I have to think.

Jeronymous commented 1 year ago

Actually, I did some tests, and there is no need to modify whisper-timestamped. You can just run this before installing the rest as usual:

pip install \
    torch==1.13.1+cpu \
    torchaudio==0.13.1+cpu \
    -f https://download.pytorch.org/whl/torch_stable.html

By doing this, I can indeed build a docker image of 3.42GB instead of 8.84GB.

I'll add a note in the README, and maybe another Dockerfile.

Thanks again

PlkMarudny commented 1 year ago

Actually, this gives an error:

ERROR: Could not find a version that satisfies the requirement torch==1.13.1+cpu (from versions: 2.0.0, 2.0.0+cpu, 2.0.0+cu117, 2.0.0+cu118, 2.0.1, 2.0.1+cpu, 2.0.1+cu117, 2.0.1+cu118)