GithubHelp home page GithubHelp logo

TypeError: TranscriptionOptions.__new__() missing 3 required positional arguments: 'max_new_tokens', 'clip_timestamps', and 'hallucination_silence_threshold' about whisperx HOT 16 OPEN

sushk0841 avatar sushk0841 commented on June 12, 2024
TypeError: TranscriptionOptions.__new__() missing 3 required positional arguments: 'max_new_tokens', 'clip_timestamps', and 'hallucination_silence_threshold'

from whisperx.

Comments (16)

ccos89 avatar ccos89 commented on June 12, 2024 1

For those having this issue, check your asr.py file and ensure at line 322 that after "suppress_numerals": False, that you have the following three lines
"max_new_tokens": None, "clip_timestamps": None, "hallucination_silence_threshold": None,

For whatever reason I did not have these arguments in mine and it was causing the issue. Adding those solved it. You can also just download and replace your asr.py file with the current one from the repository as the current file has these options in it.

from whisperx.

SobolevskyDmitry avatar SobolevskyDmitry commented on June 12, 2024

Try to reinstall WhisperX again, this issue was already fixed recently
bbaa2f0

from whisperx.

phil-pf avatar phil-pf commented on June 12, 2024

I just tried to run WhisperX on a Windows 10 host that's running Python 3.12.3. Pip is showing that I've installed
whisper 1.1.10 and whisperx 3.1.2. The code failed with that same error:

Error while loading whisper model:
TranscriptionOptions.__new__() missing 3 required positional arguments: 'max_new_tokens', 'clip_timestamps', and 'hallucination_silence_threshold'

Apologies for sounding like a tyro, but I believe that this code was working last week-- it's a student's code-- and I have no idea as to how to proceed from here, given that I've already uninstalled and reinstalled Whisper and WhisperX three times.

from whisperx.

phil-pf avatar phil-pf commented on June 12, 2024

So, a follow-on to my former comment. I just tried, under Windows 10, to revert faster-whisper to 0.10.1 and speechbrain to 0.5.16. Reverting to speechbrain 0.5.16 appears to work. Reverting to faster-whisper 0.10.1, however, fails with the following messages:

E:\2024 spring_Dept. workflows project\gradapp preprocessing utilities\pdf page selector\source files>pip install --force-reinstall -v "faster-whisper==0.10.1"
Using pip 24.0 from C:\Program Files\Python312\Lib\site-packages\pip (python 3.12)
Collecting faster-whisper==0.10.1
Obtaining dependency information for faster-whisper==0.10.1 from https://files.pythonhosted.org/packages/8e/bd/81f2ab3adc12b4e63c8fe8a50a4abfd6f32bf58a0b5abbfb7c584946cf82/faster_whisper-0.10.1-py3-none-any.whl.metadata
Using cached faster_whisper-0.10.1-py3-none-any.whl.metadata (11 kB)
Collecting av==10.* (from faster-whisper==0.10.1)
Using cached av-10.0.0.tar.gz (2.4 MB)
Running command pip subprocess to install build dependencies
Collecting setuptools
Using cached setuptools-69.1.1-py3-none-any.whl.metadata (6.2 kB)
Collecting wheel
Using cached wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB)
Collecting cython
Using cached Cython-3.0.8-cp312-cp312-win_amd64.whl.metadata (3.2 kB)
Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Using cached wheel-0.42.0-py3-none-any.whl (65 kB)
Using cached Cython-3.0.8-cp312-cp312-win_amd64.whl (2.8 MB)
Installing collected packages: wheel, setuptools, cython
Successfully installed cython-3.0.8 setuptools-69.1.1 wheel-0.42.0
Installing build dependencies ... done
Running command Getting requirements to build wheel
Compiling av\buffer.pyx because it changed.
[1/1] Cythonizing av\buffer.pyx
Compiling av\bytesource.pyx because it changed.
[1/1] Cythonizing av\bytesource.pyx
Compiling av\descriptor.pyx because it changed.
[1/1] Cythonizing av\descriptor.pyx
Compiling av\dictionary.pyx because it changed.
[1/1] Cythonizing av\dictionary.pyx
Compiling av\enum.pyx because it changed.
[1/1] Cythonizing av\enum.pyx
Compiling av\error.pyx because it changed.
[1/1] Cythonizing av\error.pyx
Compiling av\format.pyx because it changed.
[1/1] Cythonizing av\format.pyx
Compiling av\frame.pyx because it changed.
[1/1] Cythonizing av\frame.pyx
performance hint: av\logging.pyx:232:5: Exception check on 'log_callback' will always require the GIL to be acquired.
Possible solutions:
1. Declare 'log_callback' as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
2. Use an 'int' return type on 'log_callback' to allow an error code to be returned.

Error compiling Cython file:

...
cdef const char *log_context_name(void *ptr) nogil:
cdef log_context obj = <log_context>ptr
return obj.name

cdef lib.AVClass log_class
log_class.item_name = log_context_name
^

av\logging.pyx:216:22: Cannot assign type 'const char *(void *) except? NULL nogil' to 'const char ()(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'const char *(void *) except? NULL nogil'.

Error compiling Cython file:

...

Start the magic!

We allow the user to fully disable the logging system as it will not play

nicely with subinterpreters due to FFmpeg-created threads.

if os.environ.get('PYAV_LOGGING') != 'off':
lib.av_log_set_callback(log_callback)
^

av\logging.pyx:351:28: Cannot assign type 'void (void *, int, const char *, va_list) except * nogil' to 'av_log_callback'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void *, int, const char *, va_list) except * nogil'.
Compiling av\logging.pyx because it changed.
[1/1] Cythonizing av\logging.pyx
Traceback (most recent call last):
File "C:\Program Files\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main()
File "C:\Program Files\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\philp\AppData\Local\Temp\pip-build-env-etcde4gf\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\philp\AppData\Local\Temp\pip-build-env-etcde4gf\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "C:\Users\philp\AppData\Local\Temp\pip-build-env-etcde4gf\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "C:\Users\philp\AppData\Local\Temp\pip-build-env-etcde4gf\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "", line 157, in
File "C:\Users\philp\AppData\Local\Temp\pip-build-env-etcde4gf\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
cythonize_one(*args)
File "C:\Users\philp\AppData\Local\Temp\pip-build-env-etcde4gf\overlay\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: av\logging.pyx
error: subprocess-exited-with-error

× Getting requirements to build wheel 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: 'C:\Program Files\Python312\python.exe' 'C:\Program Files\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py' get_requires_for_build_wheel 'C:\Users\philp\AppData\Local\Temp\tmphjdanlya'
cwd: C:\Users\philp\AppData\Local\Temp\pip-install-xs1iul8q\av_cd4f9e37a9f245a29659800df80341c5
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel 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.

from whisperx.

souvikqb avatar souvikqb commented on June 12, 2024

Getting this error even after the following requirements -

TypeError: new() missing 3 required positional arguments: 'max_new_tokens', 'clip_timestamps', and 'hallucination_silence_threshold'

git+https://github.com/m-bain/whisperx.git
faster-whisper == 1.0.1
speechbrain == 0.5.16

from whisperx.

phil-pf avatar phil-pf commented on June 12, 2024

from whisperx.

phil-pf avatar phil-pf commented on June 12, 2024

from whisperx.

phil-pf avatar phil-pf commented on June 12, 2024

from whisperx.

phil-pf avatar phil-pf commented on June 12, 2024

from whisperx.

adrianguanipa avatar adrianguanipa commented on June 12, 2024

I need some help with this error, I'm using Whisperx to extract text from an audio file, when I run the code via VSCode (on a Mac mini M2) without the transcription options all works as expected, but when I compose up to docker the code fails to run indicating I'm missing 3 argument, I've tried adding those arguments to my code but that's not working either.

I'm running --platform=linux/arm64 python:3.10. I downloaded the latest whisper.
Any idea what could be wrong here?

Error:

2024-03-20 22:23:15 test-1 | Traceback (most recent call last):
2024-03-20 22:23:15 test-1 | import speech
2024-03-20 22:23:15 test-1 | File "/code/speech.py", line 274, in
2024-03-20 22:23:15 test-1 | File "/code/speech.py", line 69, in get_speeach_to_text
2024-03-20 22:23:15 test-1 | model = whisperx.load_model("medium", device, compute_type=compute_type)
2024-03-20 22:23:15 test-1 | File "/usr/local/lib/python3.10/site-packages/whisperx/asr.py", line 332, in load_model
2024-03-20 22:23:15 test-1 | default_asr_options = faster_whisper.transcribe.TranscriptionOptions(**default_asr_options)
2024-03-20 22:23:15 test-1 | TypeError: TranscriptionOptions.new() missing 3 required positional arguments: 'max_new_tokens', 'clip_timestamps', and 'hallucination_silence_threshold'

This is my speech.py file after adding the transcription options:

import whisperx
import faster_whisper

transcription_options = faster_whisper.transcribe.TranscriptionOptions(
beam_size=4,
best_of=1,
patience=10,
length_penalty=0.6,
repetition_penalty=1.2,
no_repeat_ngram_size=2,
log_prob_threshold=-20,
no_speech_threshold=0.5,
compression_ratio_threshold=0.5,
condition_on_previous_text=False,
prompt_reset_on_temperature=True,
temperatures=[0.7],
initial_prompt="",
prefix="",
suppress_blank=False,
suppress_tokens=False,
without_timestamps=True,
max_initial_timestamp=60,
word_timestamps=False,
prepend_punctuations="",
append_punctuations="",
max_new_tokens=50,
clip_timestamps=60,
hallucination_silence_threshold=0.5
)

device = "cpu"
batch_size = 16 # reduce if low on GPU mem
compute_type = "int8"

model = whisperx.load_model("medium", device, compute_type=compute_type)

audio = whisperx.load_audio(source_audio_file)
result = model.transcribe(audio, language='en', task='translate', batch_size=batch_size, transcription_options=transcription_options)

from whisperx.

phil-pf avatar phil-pf commented on June 12, 2024

Mr Guanipa - The fix in the ccos89 comment from two weeks ago should work.

  • Do a search in the directory in which WhisperX was installed for the file "asr.py"
  • As that user indicated, add the following three lines to that file after asr.py the "suppress_numerals": False, parameter, ca. 322:
    "max_new_tokens": None, "clip_timestamps": None, "hallucination_silence_threshold": None,

While the git archive may indeed have an updated version of asr.py as Mr. Bain indicated, merely reinstalling whisperX 3.1.2, even after I cleared my pip cache, didn't seem to help. Editing that file by hand did indeed fix the problem on my Windows 10 and Windows 11 devices.

from whisperx.

adrianguanipa avatar adrianguanipa commented on June 12, 2024

Mr Guanipa - The fix in the ccos89 comment from two weeks ago should work.

  • Do a search in the directory in which WhisperX was installed for the file "asr.py"
  • As that user indicated, add the following three lines to that file after asr.py the "suppress_numerals": False, parameter, ca. 322:
    "max_new_tokens": None, "clip_timestamps": None, "hallucination_silence_threshold": None,

While the git archive may indeed have an updated version of asr.py as Mr. Bain indicated, merely reinstalling whisperX 3.1.2, even after I cleared my pip cache, didn't seem to help. Editing that file by hand did indeed fix the problem on my Windows 10 and Windows 11 devices.

Thank you for your input, I did tried editing the files but that didn't work for me, for some reason, but I did try downloading the git directly and fixed my issue, I guess the I had an old version cached somewhere.

whisper==1.1.10
faster-whisper==1.0.0
git+https://github.com/m-bain/whisperX.git

from whisperx.

tddouglas avatar tddouglas commented on June 12, 2024

Thanks @ccos89 for pointing out the root cause!
The latest version of whisperX (v3.1.2) on PyPi was indeed deployed with this issue. You can verify that by downloading 3.1.2 source files and reviewing the default_asr_options. This needs to be fixed by the PyPi maintainer (daswer123) deploying a more recent commit.

In the mean time, I fixed this by adding the missing options to an options dict and passing that into the load_model call. I think this is an easier solution than modifying your local whisperx asr.py file.

    options = {
        "max_new_tokens": None,
        "clip_timestamps": None,
        "hallucination_silence_threshold": None,
    }

    model = whisperx.load_model("large-v2", device, compute_type=compute_type,asr_options=options)

from whisperx.

3blackbar avatar 3blackbar commented on June 12, 2024

4 weeks later, its still not fixed ? Yeah i know about manual edit above but ... ?

from whisperx.

bil-ash avatar bil-ash commented on June 12, 2024

@m-bain Please update the pypi version

from whisperx.

janton10 avatar janton10 commented on June 12, 2024

+1, please update pypi

from whisperx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.