[Python] Use pretrained model with insanely fast whisper

Discussão em 'Python' iniciado por Stack, Julho 25, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use a custom model with insanely fast whisper.

    This is the code that I have so far:

    ...
    def __init__(self):
    self.insanely_fast_whisper_model = PreTrainedModel(
    config=PretrainedConfig(name_or_path=WHISPER_MODEL_PATH),
    )
    ...
    async def _transcribe_insanely_fast_whisper(self, file_content: bytes = None) -> str:
    pipe = pipeline(
    "automatic-speech-recognition",
    model=self.insanely_fast_whisper_model, # "openai/whisper-large-v3",
    device="cpu", # "cuda:0", # or mps for Mac devices
    model_kwargs={"attn_implementation": "flash_attention_2"}
    if is_flash_attn_2_available()
    else {"attn_implementation": "sdpa"},
    )

    outputs = pipe(
    file_content,
    chunk_length_s=30,
    batch_size=24,
    return_timestamps=True,
    )
    return outputs


    I've tried many things but whenever I am running the code I am getting:

    File "/usr/local/lib/python3.12/site-packages/transformers/pipelines/__init__.py", line 1097, in pipeline
    return pipeline_class(model=model, framework=framework, task=task, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/transformers/pipelines/automatic_speech_recognition.py", line 210, in __init__
    feature_extractor._processor_class
    AttributeError: 'NoneType' object has no attribute '_processor_class'


    I don't know a lot about models and transformers and how to use them. Tried reading the documentation but didn't find an answer. Additionally here is the directory structure that WHISPER_MODEL_PATH is pointing to, for what it's worth:

    .
    ├── dataset
    │ └── whisper-large-v3-ro-ct2
    │ ├── config.json
    │ ├── preprocessor_config.json
    │ ├── tokenizer.json
    │ └── vocabulary.json
    ├── Dockerfile
    ├── readme.md
    └── setup_python.sh


    Please, let me know if you need any additional info.

    Continue reading...

Compartilhe esta Página