MahmoudAshraf97 / whisper-diarization

Automatic Speech Recognition with Speaker Diarization based on OpenAI Whisper
BSD 2-Clause "Simplified" License
3.75k stars 329 forks source link

Latest update broke the code? 'huggingface_hub.errors #244

Closed shivamtawari closed 1 month ago

shivamtawari commented 1 month ago

I tried to work with the latest update of this project and I got this error, it was working fine till yesterday.

ModuleNotFoundError: No module named 'huggingface_hub.errors'

MahmoudAshraf97 commented 1 month ago

Please post the complete error trace

shivamtawari commented 1 month ago

First this error:

ImportError                               Traceback (most recent call last)
File /workspace/whisper-diarization/diarize.py:17
      8 from ctc_forced_aligner import (
      9     generate_emissions,
     10     get_alignments,
   (...)
     14     preprocess_text,
     15 )
     16 from deepmultilingualpunctuation import PunctuationModel
---> 17 from nemo.collections.asr.models.msdd_models import NeuralDiarizer
     19 from helpers import (
     20     cleanup,
     21     create_config,
   (...)
     30     write_srt,
     31 )
     32 from transcription_helpers import transcribe_batched

File /usr/local/lib/python3.11/dist-packages/nemo/collections/asr/__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from nemo.collections.asr import data, losses, models, modules
     16 from nemo.package_info import __version__
     18 # Set collection version equal to NeMo version.

File /usr/local/lib/python3.11/dist-packages/nemo/collections/asr/losses/__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from nemo.collections.asr.losses.angularloss import AngularSoftmaxLoss
     16 from nemo.collections.asr.losses.audio_losses import MSELoss, SDRLoss
     17 from nemo.collections.asr.losses.ctc import CTCLoss

File /usr/local/lib/python3.11/dist-packages/nemo/collections/asr/losses/angularloss.py:18
      1 # ! /usr/bin/python
      2 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      3 #
   (...)
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     16 import torch
---> 18 from nemo.core.classes import Loss, Typing, typecheck
     19 from nemo.core.neural_types import LabelsType, LogitsType, LossType, NeuralType
     21 __all__ = ['AngularSoftmaxLoss']

File /usr/local/lib/python3.11/dist-packages/nemo/core/__init__.py:16
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     15 import nemo.core.neural_types
---> 16 from nemo.core.classes import *

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/__init__.py:20
     17 import omegaconf
     18 import pytorch_lightning
---> 20 from nemo.core.classes.common import (
     21     FileIO,
     22     Model,
     23     PretrainedModelInfo,
     24     Serialization,
     25     Typing,
     26     is_typecheck_enabled,
     27     typecheck,
     28 )
     29 from nemo.core.classes.dataset import Dataset, IterableDataset
     30 from nemo.core.classes.exportable import Exportable, ExportFormat

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/common.py:40
     37 from omegaconf import DictConfig, OmegaConf
     39 import nemo
---> 40 from nemo.core.classes.mixins.hf_io_mixin import HuggingFaceFileIO
     41 from nemo.core.config.templates.model_card import NEMO_DEFAULT_MODEL_CARD_TEMPLATE
     42 from nemo.core.connectors.save_restore_connector import SaveRestoreConnector

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/mixins/__init__.py:28
     16 from nemo.core.classes.mixins.adapter_mixin_strategies import (
     17     ResidualAddAdapterStrategy,
     18     ResidualAddAdapterStrategyConfig,
     19     ReturnResultAdapterStrategy,
     20     ReturnResultAdapterStrategyConfig,
     21 )
     22 from nemo.core.classes.mixins.adapter_mixins import (
     23     AdapterModelPTMixin,
     24     AdapterModuleMixin,
     25     get_registered_adapter,
     26     register_adapter,
     27 )
---> 28 from nemo.core.classes.mixins.hf_io_mixin import HuggingFaceFileIO

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/mixins/hf_io_mixin.py:19
     16 from pathlib import Path
     17 from typing import Dict, Iterable, List, Optional, Union
---> 19 from huggingface_hub import HfApi, ModelCard, ModelCardData, ModelFilter
     20 from huggingface_hub import get_token as get_hf_token
     21 from huggingface_hub.hf_api import ModelInfo

ImportError: cannot import name 'ModelFilter' from 'huggingface_hub' (/usr/local/lib/python3.11/dist-packages/huggingface_hub/__init__.py)

Then I tried this solution #202:

pip uninstall huggingface_hub pip install huggingface-hub==0.20.3

Got this error:


ImportError                               Traceback (most recent call last)
File /workspace/whisper-diarization/diarize.py:17
      8 from ctc_forced_aligner import (
      9     generate_emissions,
     10     get_alignments,
   (...)
     14     preprocess_text,
     15 )
     16 from deepmultilingualpunctuation import PunctuationModel
---> 17 from nemo.collections.asr.models.msdd_models import NeuralDiarizer
     19 from helpers import (
     20     cleanup,
     21     create_config,
   (...)
     30     write_srt,
     31 )
     32 from transcription_helpers import transcribe_batched

File /usr/local/lib/python3.11/dist-packages/nemo/collections/asr/__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from nemo.collections.asr import data, losses, models, modules
     16 from nemo.package_info import __version__
     18 # Set collection version equal to NeMo version.

File /usr/local/lib/python3.11/dist-packages/nemo/collections/asr/losses/__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from nemo.collections.asr.losses.angularloss import AngularSoftmaxLoss
     16 from nemo.collections.asr.losses.audio_losses import MSELoss, SDRLoss
     17 from nemo.collections.asr.losses.ctc import CTCLoss

File /usr/local/lib/python3.11/dist-packages/nemo/collections/asr/losses/angularloss.py:18
      1 # ! /usr/bin/python
      2 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      3 #
   (...)
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     16 import torch
---> 18 from nemo.core.classes import Loss, Typing, typecheck
     19 from nemo.core.neural_types import LabelsType, LogitsType, LossType, NeuralType
     21 __all__ = ['AngularSoftmaxLoss']

File /usr/local/lib/python3.11/dist-packages/nemo/core/__init__.py:16
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     15 import nemo.core.neural_types
---> 16 from nemo.core.classes import *

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/__init__.py:20
     17 import omegaconf
     18 import pytorch_lightning
---> 20 from nemo.core.classes.common import (
     21     FileIO,
     22     Model,
     23     PretrainedModelInfo,
     24     Serialization,
     25     Typing,
     26     is_typecheck_enabled,
     27     typecheck,
     28 )
     29 from nemo.core.classes.dataset import Dataset, IterableDataset
     30 from nemo.core.classes.exportable import Exportable, ExportFormat

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/common.py:40
     37 from omegaconf import DictConfig, OmegaConf
     39 import nemo
---> 40 from nemo.core.classes.mixins.hf_io_mixin import HuggingFaceFileIO
     41 from nemo.core.config.templates.model_card import NEMO_DEFAULT_MODEL_CARD_TEMPLATE
     42 from nemo.core.connectors.save_restore_connector import SaveRestoreConnector

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/mixins/__init__.py:28
     16 from nemo.core.classes.mixins.adapter_mixin_strategies import (
     17     ResidualAddAdapterStrategy,
     18     ResidualAddAdapterStrategyConfig,
     19     ReturnResultAdapterStrategy,
     20     ReturnResultAdapterStrategyConfig,
     21 )
     22 from nemo.core.classes.mixins.adapter_mixins import (
     23     AdapterModelPTMixin,
     24     AdapterModuleMixin,
     25     get_registered_adapter,
     26     register_adapter,
     27 )
---> 28 from nemo.core.classes.mixins.hf_io_mixin import HuggingFaceFileIO

File /usr/local/lib/python3.11/dist-packages/nemo/core/classes/mixins/hf_io_mixin.py:19
     16 from pathlib import Path
     17 from typing import Dict, Iterable, List, Optional, Union
---> 19 from huggingface_hub import HfApi, ModelCard, ModelCardData, ModelFilter
     20 from huggingface_hub import get_token as get_hf_token
     21 from huggingface_hub.hf_api import ModelInfo

ImportError: cannot import name 'ModelFilter' from 'huggingface_hub' (/usr/local/lib/python3.11/dist-packages/huggingface_hub/__init__.py)```

Then I was again trying some other solutions from Google.
shivamtawari commented 1 month ago

My bad I didn't checked this updated readme:

pip install -c constraints.txt -r requirements.txt

I think it should work, but I was working with older commit right now.