ImportError: cannot import name 'compute_metrics_per_sample' from 'nemo.collections.asr.parts.utils.transcribe_utils' (/DATA/anaconda3/envs/nemo/lib/python3.10/site-packages/nemo/collections/asr/parts/utils/transcribe_utils.py)
State: closed | Pull request: no
Labels: name: bug

name: stale

I am using [this](https://github.com/NVIDIA/NeMo/blob/main/examples/asr/speech_to_text_eval.py) script to decode a conformer-CTC finetuned using the following bash script:-
```
CUDA_VISIBLE_DEVICES=0 python /DATA/Sougata/BTech/NeMo/examples/asr/speech_to_text_eval.py \
    model_path=${model_path} \
    dataset_manifest=${dataset_manifest} \
    output_filename=${output_filename} \
    batch_size=32 \
    amp=True \
    use_cer=True
```
I am getting the following error:-
```
Traceback (most recent call last):
  File "/home/conformer/NeMo/examples/asr/speech_to_text_eval.py", line 75, in <module>
    from nemo.collections.asr.parts.utils.transcribe_utils import (
ImportError: cannot import name 'compute_metrics_per_sample' from 'nemo.collections.asr.parts.utils.transcribe_utils' (/opt/conda/lib/python3.8/site-packages/nemo/collections/asr/parts/utils/transcribe_utils.py)
```
After following a similar [issue](https://github.com/NVIDIA/NeMo/issues/7104#issuecomment-1650726632) I have installed ``` nemo_toolkit[asr]==1.19.1``` but still it is showing the same error.

Can anybody kindly please help me in resolving this issue?
 


You need a more recent NeMo version, 1.21 of 1.22. 

Or you can switch branch to 1.19 and then use the script from that branch 

> You need a more recent NeMo version, 1.21 of 1.22.

What is the command line for checking nemo version?

```
import nemo
print(nemo.__version__)
```

> You need a more recent NeMo version, 1.21 of 1.22.

Yes I have checked the nemo version is 1.21.0 but still it is giving the [same](https://github.com/NVIDIA/NeMo/issues/8105#issue-2060870667) error.

I meant use the version of the script from branch r1.21.0 on GitHub - https://github.com/NVIDIA/NeMo/blob/r1.21.0/examples/asr/transcribe_speech.py

This one corresponds to the NeMo installed version of 1.21.0. 

If you use main branch script (upcoming release of 1.22.0), with installed NeMo 1.21 - it will generally not work. 

Since you specifically looking to calculate scores, you'll need the r1.21.0 version of the eval script as well - https://github.com/NVIDIA/NeMo/blob/r1.21.0/examples/asr/speech_to_text_eval.py

> I meant use the version of the script from branch r1.21.0 on GitHub - https://github.com/NVIDIA/NeMo/blob/r1.21.0/examples/asr/transcribe_speech.py
> 
> This one corresponds to the NeMo installed version of 1.21.0.
> 
> If you use main branch script (upcoming release of 1.22.0), with installed NeMo 1.21 - it will generally not work.

I have directly downloaded [this](https://github.com/NVIDIA/NeMo/blob/r1.21.0/examples/asr/speech_to_text_eval.py) script from the r1.21.0 branch and replaced the original one but it is again showing the following error:-
```
Traceback (most recent call last):
  File "/home/conformer/NeMo/examples/asr/speech_to_text_eval.py", line 185, in <module>
    main()  # noqa pylint: disable=no-value-for-parameter
  File "/opt/conda/lib/python3.8/site-packages/nemo/core/config/hydra_runner.py", line 126, in wrapper
    _run_hydra(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
    _run_app(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/utils.py", line 457, in _run_app
    run_and_report(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
    lambda: hydra.run(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 105, in run
    cfg = self.compose_config(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 594, in compose_config
    cfg = self.config_loader.load_configuration(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/config_loader_impl.py", line 142, in load_configuration
    return self._load_configuration_impl(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/config_loader_impl.py", line 244, in _load_configuration_impl
    parsed_overrides, caching_repo = self._parse_overrides_and_create_caching_repo(
  File "/opt/conda/lib/python3.8/site-packages/hydra/_internal/config_loader_impl.py", line 228, in _parse_overrides_and_create_caching_repo
    parsed_overrides = parser.parse_overrides(overrides=overrides)
  File "/opt/conda/lib/python3.8/site-packages/hydra/core/override_parser/overrides_parser.py", line 96, in parse_overrides
    raise OverrideParseException(
hydra.errors.OverrideParseException: LexerNoViableAltException:  
                           ^
See https://hydra.cc/docs/1.2/advanced/override_grammar/basic for details
```
Is this happening due to the python version? Here python3.8 is being used.

I have also tried with python 3.10 version after downloading [this](https://github.com/NVIDIA/NeMo/blob/r1.21.0/examples/asr/speech_to_text_eval.py) script from the r1.21.0 branch and replaced the previous one but it is again showing the following error:-
```
Traceback (most recent call last):
  File "/DATA/Sougata/BTech/NeMo/examples/asr/speech_to_text_eval.py", line 75, in <module>
    from nemo.collections.asr.parts.utils.transcribe_utils import (
ImportError: cannot import name 'compute_metrics_per_sample' from 'nemo.collections.asr.parts.utils.transcribe_utils' (/DATA/anaconda3/envs/nemo/lib/python3.10/site-packages/nemo/collections/asr/parts/utils/transcribe_utils.py)
```


This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been inactive for 7 days since being marked as stale.