gitmylo / audio-webui

A webui for different audio related Neural Networks
MIT License
973 stars 90 forks source link

[BUG REPORT] NameError: name 'Union' is not defined #163

Closed PawKanarek closed 9 months ago

PawKanarek commented 9 months ago

Describe the bug When i try to build code from current master (sha: 4b54d93744e680a94bb0fda581f76fe5d28fc8a5) i got error:

(audio) ➜  ~/git/audio-webui git:(master) ✗ python main.py -sv -u 'user' -p 'pass'    
Checking installs and venv + autodebug checks
Python version:  3.10.13 (main, Sep 11 2023, 08:16:02) [Clang 14.0.6 ]
Webui version: 4b54d93744e680a94bb0fda581f76fe5d28fc8a5 - Thu Oct 12 17:22:23 2023 +0200
Found extensions: 
Done installing/checking installs.
Activating extensions
Preparing
Triton is not available, some optimizations will not be enabled.
This is just a warning: triton is not available
没有发现支持的N卡, 使用MPS进行推理
exception in config_file_change_fp32: [Errno 2] No such file or directory: 'configs/32k.json'
Monkeypatching bark
Traceback (most recent call last):
  File "/Users/raix/git/audio-webui/main.py", line 44, in <module>
    autodebug.catcher(e)
  File "/Users/raix/git/audio-webui/autodebug/autodebug.py", line 79, in catcher
    raise e
  File "/Users/raix/git/audio-webui/main.py", line 27, in <module>
    patch1()
  File "/Users/raix/git/audio-webui/webui/modules/implementations/tts_monkeypatching.py", line 4, in patch
    import webui.modules.implementations.patches.bark_api as new_bark_api
  File "/Users/raix/git/audio-webui/webui/modules/implementations/patches/bark_api.py", line 11, in <module>
    history_prompt: Optional[Union[str, dict]] = None,
NameError: name 'Union' is not defined

To Reproduce

  1. Get code from master (sha: 4b54d93744e680a94bb0fda581f76fe5d28fc8a5)
  2. Run command python main.py -sv -u 'user' -p 'pass'
  3. Build fails NameError: name 'Union' is not defined

Expected behavior Builds without error

PawKanarek commented 9 months ago

I looked into the codebase and looks like a simple import was missing: from typing import Union.

https://github.com/gitmylo/audio-webui/assets/15096514/afd4d79b-6f5f-48f7-9122-61e16d60e0ed

With this additional line, the server starts successfully. I can open new PR with this change, but it's strange that I'm the only one experiencing this kind of error.

gitmylo commented 9 months ago

That's odd, Union indeed does not have any issues when being used in my code without the import. image

Maybe there's a difference between python 3.10.8 (mine) and 3.10.13 (yours) Regardless, I will add the import.