aarnphm / whispercpp

Pybind11 bindings for Whisper.cpp
Apache License 2.0
320 stars 57 forks source link

bug: from_pretrained() gives HTTP Error 401: Unauthorized #137

Open tleyden opened 1 year ago

tleyden commented 1 year ago

Describe the bug

Calling Whisper.from_pretrained("base") gives an error:

>>> whisper = Whisper.from_pretrained("base")
Downloading model base. It may take a while...Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda3/envs/misc/lib/python3.10/site-packages/whispercpp/__init__.py", line 106, in from_pretrained
    utils.download_model(model_name, basedir=basedir), no_state=no_state
  File "/opt/miniconda3/envs/misc/lib/python3.10/site-packages/whispercpp/utils.py", line 71, in download_model
    request.urlretrieve(MODELS_URL[model_name], model_path)
  File "/opt/miniconda3/envs/misc/lib/python3.10/urllib/request.py", line 241, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/opt/miniconda3/envs/misc/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/opt/miniconda3/envs/misc/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/opt/miniconda3/envs/misc/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/opt/miniconda3/envs/misc/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/opt/miniconda3/envs/misc/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/opt/miniconda3/envs/misc/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

When I try to manually open the url (https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-base.bin) in the browser, hugging face is popping up a login dialog.

Screenshot 2023-07-18 at 1 39 31 PM

To reproduce

  1. Create conda environment with python 3.10
  2. pip install whispercpp
  3. Open python shell
  4. from whispercpp import Whisper
  5. whisper = Whisper.from_pretrained("base")

Expected behavior

No errors

Environment

python: 3.10 platform: OSX 13 (apple silicon)

tleyden commented 1 year ago

Installing the latest version via pip install git+https://github.com/aarnphm/whispercpp.git -vv fixes the issue.

Since it seems like some pretty basic functionality is broken in the pypi release version, it might be good to push another release to pypi or add something to the README to warn users. Not sure if I could help w /the pypi stuff, but I'd be happy to submit a PR to update the README.

chrisspen commented 8 months ago

That didn't work for me. That just gives me the error:

Running command git submodule update --init --recursive -q
fatal: remote error: upload-pack: not our ref c9d5095f0c64455b201f1cd0b547efcf093ee7c3
fatal: Fetched in submodule path 'extern/whispercpp/bindings/ios', but it did not contain c9d5095f0c64455b201f1cd0b547efcf093ee7c3. Direct fetching of that commit failed.
fatal:
fatal: Failed to recurse into submodule path 'extern/whispercpp'
error: subprocess-exited-with-error

× git submodule update --init --recursive -q did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
full command: git submodule update --init --recursive -q
cwd: /tmp/pip-req-build-4d807i0h
error: subprocess-exited-with-error

× git submodule update --init --recursive -q did not run successfully.
│ exit code: 1
╰─> See above for output.