Skip to content

Failed to import the NeMo framework or its dependencies! 'pip install -U \"batchalign[speaker] #30

@Noah-Jaffe

Description

@Noah-Jaffe

Issue:

In https://talkbank.org/info/BA2-usage.pdf:

To use Batchalign, you first have to install a version of Python greater than 3.9. You can
install the current version from https://python.org/downloads. Some external
dependencies will be installed automatically when you install Batchalign. This means
that, you should not install any dependencies (like Whisper or Nvidia Nemo) manually. If
a special function requires a manual dependency, the Batchalign program will prompt
you with instructions

Attempting to get a transcript with a working diarize to run on my local machine.

batchalign -vvv transcribe --lang=eng --whisper --num_speakers=2 --diarize .\.tmp_test\in .\.tmp_test\out\

Expand for stacktrace
[03/02/25 10:45:02] DEBUG    Attempting to create               dispatch.py:134
                             BatchalignPipeline for CLI...                     
                    DEBUG    Initializing packages, got:         dispatch.py:64
                             packages='['asr', 'speaker']' and                 
                             config='{'DEFAULT': , 'asr': ,                  
                             'ud': }'                             
                    INFO     Initializing engines...             dispatch.py:85
                    INFO     -------------------------------     dispatch.py:86
                    INFO     | asr          |      whisper |    dispatch.py:100
                    INFO     -------------------------------    dispatch.py:101
                    DEBUG    Initializing whisper model...      infer_asr.py:67
Device set to use cpu
[03/02/25 10:45:03] DEBUG    Done, initalizing processor and    infer_asr.py:81
                             config...                                         
                    DEBUG    Whisper initialization done.       infer_asr.py:83
                    DEBUG    Initializing utterance model...      whisper.py:46
                    DEBUG    Done.                                whisper.py:52
                    INFO     | speaker      | nemo_speaker |    dispatch.py:100
                    INFO     -------------------------------    dispatch.py:101
+--------------------- Traceback (most recent call last) ---------------------+
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\models\speaker\infer.py:27 in __init__                         |
|                                                                             |
|   24 class NemoSpeakerModel(object):                                        |
|   25     def __init__(self):                                                |
|   26         try:                                                           |
| > 27             from omegaconf import OmegaConf                            |
|   28             self.__base = OmegaConf.load(resolve_config())             |
|   29         except ImportError:                                            |
|   30             self.__raise()                                             |
+-----------------------------------------------------------------------------+
ModuleNotFoundError: No module named 'omegaconf'
System.Management.Automation.RemoteException
During handling of the above exception, another exception occurred:
System.Management.Automation.RemoteException
+--------------------- Traceback (most recent call last) ---------------------+
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\cli\dispatch.py:135 in _dispatch                               |
|                                                                             |
|   132                                                                       |
|   133         # create pipeline and read files                              |
|   134         baL.debug("Attempting to create BatchalignPipeline for CLI... |
| > 135         pipeline = BatchalignPipeline.new(Cmd2Task[command],          |
|   136                                           lang=lang, num_speakers=num |
|   137         baL.debug(f"Successfully created BatchalignPipeline... {pipel |
|   138                                                                       |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\pipelines\pipeline.py:60 in new                                |
|                                                                             |
|    57         """                                                           |
|    58                                                                       |
|    59         from batchalign.pipelines.dispatch import dispatch_pipeline   |
| >  60         return dispatch_pipeline(tasks, lang=lang, num_speakers=num_s |
|    61                                                                       |
|    62     def __call__(self, input, callback=None, **kwargs):               |
|    63         """Call the pipeline.                                         |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\pipelines\dispatch.py:126 in dispatch_pipeline                 |
|                                                                             |
|   123         elif engine == "evaluation":                                  |
|   124             engines.append(EvaluationEngine())                        |
|   125         elif engine == "nemo_speaker":                                |
| > 126             engines.append(NemoSpeakerEngine(num_speakers=num_speaker |
|   127         elif engine == "stanza_utt":                                  |
|   128             engines.append(StanzaUtteranceEngine())                   |
|   129         elif engine == "stanza_coref":                                |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\pipelines\speaker\nemo_speaker.py:26 in __init__               |
|                                                                             |
|   23                                                                        |
|   24         self.status_hook = None                                        |
|   25         self.num_speakers = num_speakers                               |
| > 26         self.__model = NemoSpeakerModel()                              |
|   27                                                                        |
|   28     def process(self, doc:Document, **kwargs):                         |
|   29         # check that the document has a media path to align to         |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\models\speaker\infer.py:30 in __init__                         |
|                                                                             |
|   27             from omegaconf import OmegaConf                            |
|   28             self.__base = OmegaConf.load(resolve_config())             |
|   29         except ImportError:                                            |
| > 30             self.__raise()                                             |
|   31                                                                        |
|   32     def __raise(self):                                                 |
|   33         raise ImportError("Failed to import the NeMo framework or its  |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\models\speaker\infer.py:33 in __raise                          |
|                                                                             |
|   30             self.__raise()                                             |
|   31                                                                        |
|   32     def __raise(self):                                                 |
| > 33         raise ImportError("Failed to import the NeMo framework or its  |
|   34                                                                        |
|   35     def __call__(self, in_file, num_speakers=2):                       |
|   36         try:                                                           |
+-----------------------------------------------------------------------------+
ImportError: Failed to import the NeMo framework or its dependencies!
Hint: run 'pip install -U "batchalign[speaker]"' to install speaker diarization
tools.
System.Management.Automation.RemoteException
During handling of the above exception, another exception occurred:
System.Management.Automation.RemoteException
+--------------------- Traceback (most recent call last) ---------------------+
| in _run_module_as_main:198                                                  |
| in _run_code:88                                                             |
|                                                                             |
| in :7                                                               |
|                                                                             |
|   4 from batchalign.cli.cli import batchalign                               |
|   5 if __name__ == '__main__':                                              |
|   6     sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])    |
| > 7     sys.exit(batchalign())                                              |
|   8                                                                         |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich_click\rich_command.py:367 in __call__                                |
|                                                                             |
|   364         # Include this here because I run into a false warning        |
|   365         # in the PyCharm IDE otherwise; for some reason PyCharm doesn |
|   366         # seem to think RichGroups are callable. (No issues with Mypy |
| > 367         return super().__call__(*args, **kwargs)                      |
|   368                                                                       |
|   369                                                                       |
|   370 class RichCommandCollection(CommandCollection, RichGroup):            |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\click\core.py:1161 in __call__                                            |
|                                                                             |
|   1158                                                                      |
|   1159     def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:      |
|   1160         """Alias for :meth:`main`."""                                |
| > 1161         return self.main(*args, **kwargs)                            |
|   1162                                                                      |
|   1163                                                                      |
|   1164 class Command(BaseCommand):                                          |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich_click\rich_command.py:152 in main                                    |
|                                                                             |
|   149         try:                                                          |
|   150             try:                                                      |
|   151                 with self.make_context(prog_name, args, **extra) as c |
| > 152                     rv = self.invoke(ctx)                             |
|   153                     if not standalone_mode:                           |
|   154                         return rv                                     |
|   155                     # it's not safe to `ctx.exit(rv)` here!           |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\click\core.py:1697 in invoke                                              |
|                                                                             |
|   1694                 super().invoke(ctx)                                  |
|   1695                 sub_ctx = cmd.make_context(cmd_name, args, parent=ct |
|   1696                 with sub_ctx:                                        |
| > 1697                     return _process_result(sub_ctx.command.invoke(su |
|   1698                                                                      |
|   1699         # In chain mode we create the contexts step by step, but aft |
|   1700         # base command has been invoked.  Because at that point we d |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\click\core.py:1443 in invoke                                              |
|                                                                             |
|   1440             echo(style(message, fg="red"), err=True)                 |
|   1441                                                                      |
|   1442         if self.callback is not None:                                |
| > 1443             return ctx.invoke(self.callback, **ctx.params)           |
|   1444                                                                      |
|   1445     def shell_complete(self, ctx: Context, incomplete: str) -> t.Lis |
|   1446         """Return a list of completions for the incomplete value. Lo |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\click\core.py:788 in invoke                                               |
|                                                                             |
|    785                                                                      |
|    786         with augment_usage_errors(__self):                           |
|    787             with ctx:                                                |
| >  788                 return __callback(*args, **kwargs)                   |
|    789                                                                      |
|    790     def forward(__self, __cmd: "Command", *args: t.Any, **kwargs: t. |
|    791         """Similar to :meth:`invoke` but fills in default keyword    |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\click\decorators.py:33 in new_func                                        |
|                                                                             |
|    30     """                                                               |
|    31                                                                       |
|    32     def new_func(*args: "P.args", **kwargs: "P.kwargs") -> "R":       |
| >  33         return f(get_current_context(), *args, **kwargs)              |
|    34                                                                       |
|    35     return update_wrapper(new_func, f)                                |
|    36                                                                       |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\cli\cli.py:187 in transcribe                                   |
|                                                                             |
|   184                                 write_wor=kwargs.get("wor", False))   |
|   185                                                                       |
|   186     if kwargs.get("diarize"):                                         |
| > 187         _dispatch("transcribe_s",                                     |
|   188                   lang, num_speakers, ["mp3", "mp4", "wav"], ctx,     |
|   189                   in_dir, out_dir,                                    |
|   190                   loader, writer, C,                                  |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\batchalign\cli\dispatch.py:126 in _dispatch                               |
|                                                                             |
|   123     # cache the errors                                                |
|   124     errors = []                                                       |
|   125                                                                       |
| > 126     with prog as prog:                                                |
|   127         tasks = {}                                                    |
|   128         errors = []                                                   |
|   129         # create the spinner bars                                     |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich\progress.py:1191 in __exit__                                         |
|                                                                             |
|   1188         exc_val: Optional[BaseException],                            |
|   1189         exc_tb: Optional[TracebackType],                             |
|   1190     ) -> None:                                                       |
| > 1191         self.stop()                                                  |
|   1192                                                                      |
|   1193     def track(                                                       |
|   1194         self,                                                        |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich\progress.py:1177 in stop                                             |
|                                                                             |
|   1174                                                                      |
|   1175     def stop(self) -> None:                                          |
|   1176         """Stop the progress display."""                             |
| > 1177         self.live.stop()                                             |
|   1178         if not self.console.is_interactive and not self.console.is_j |
|   1179             self.console.print()                                     |
|   1180                                                                      |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich\live.py:147 in stop                                                  |
|                                                                             |
|   144                 self._refresh_thread = None                           |
|   145             # allow it to fully render on the last even if overflow   |
|   146             self.vertical_overflow = "visible"                        |
| > 147             with self.console:                                        |
|   148                 try:                                                  |
|   149                     if not self._alt_screen and not self.console.is_j |
|   150                         self.refresh()                                |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich\console.py:864 in __exit__                                           |
|                                                                             |
|    861                                                                      |
|    862     def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any |
|    863         """Exit buffer context."""                                   |
| >  864         self._exit_buffer()                                          |
|    865                                                                      |
|    866     def begin_capture(self) -> None:                                 |
|    867         """Begin capturing console output. Call :meth:`end_capture`  |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich\console.py:822 in _exit_buffer                                       |
|                                                                             |
|    819     def _exit_buffer(self) -> None:                                  |
|    820         """Leave buffer context, and render content if required."""  |
|    821         self._buffer_index -= 1                                      |
| >  822         self._check_buffer()                                         |
|    823                                                                      |
|    824     def set_live(self, live: "Live") -> None:                        |
|    825         """Set Live instance. Used by Live context manager.          |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich\console.py:2019 in _check_buffer                                     |
|                                                                             |
|   2016             return                                                   |
|   2017                                                                      |
|   2018         try:                                                         |
| > 2019             self._write_buffer()                                     |
|   2020         except BrokenPipeError:                                      |
|   2021             self.on_broken_pipe()                                    |
|   2022                                                                      |
|                                                                             |
| c:\Users\PC\Documents\python_scripts\videotranscript\.venv\Lib\site-package |
| s\rich\console.py:2067 in _write_buffer                                     |
|                                                                             |
|   2064                             MAX_WRITE = 32 * 1024 // 4               |
|   2065                             try:                                     |
|   2066                                 if len(text) <= MAX_WRITE:           |
| > 2067                                     write(text)                      |
|   2068                                 else:                                |
|   2069                                     batch: List[str] = []            |
|   2070                                     batch_append = batch.append      |
|                                                                             |
| C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\tempfile.py:499 in  |
| func_wrapper                                                                |
|                                                                             |
|   496             func = a                                                  |
|   497             @_functools.wraps(func)                                   |
|   498             def func_wrapper(*args, **kwargs):                        |
| > 499                 return func(*args, **kwargs)                          |
|   500             # Avoid closing the file as long as the wrapper is alive, |
|   501             # see issue #18879.                                       |
|   502             func_wrapper._closer = self._closer                       |
|                                                                             |
| C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1252.py |
| :19 in encode                                                               |
|                                                                             |
|    16                                                                       |
|    17 class IncrementalEncoder(codecs.IncrementalEncoder):                  |
|    18     def encode(self, input, final=False):                             |
| >  19         return codecs.charmap_encode(input,self.errors,encoding_table |
|    20                                                                       |
|    21 class IncrementalDecoder(codecs.IncrementalDecoder):                  |
|    22     def decode(self, input, final=False):                             |
+-----------------------------------------------------------------------------+
UnicodeEncodeError: 'charmap' codec can't encode character '\u2827' in position
0: character maps to 
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***


I tried this with python 3.12.9, 3.11.11, and 3.9 (all in a fresh venv).
Whats the deal?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions