JonathanFly/bark

WebUI won't open.

guestmaan opened this issue · 7 comments

I pulled to the newest version of bark, installed the requirements using
pip install -r requirements-pip.txt
and tried running the webui. However, it errors out here:

Traceback (most recent call last):
  File "/home/rlt/bark/bark_webui.py", line 5, in <module>
    import gradio as gr
  File "/home/rlt/.local/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/home/rlt/.local/lib/python3.10/site-packages/gradio/components.py", line 55, in <module>
    from gradio import processing_utils, utils
  File "/home/rlt/.local/lib/python3.10/site-packages/gradio/utils.py", line 38, in <module>
    import matplotlib
  File "/home/rlt/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 107, in <module>
    from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

I am using Python 3.10.6. Any advice? Same result in miniconda.

Thanks in advance.

I didn't get a chance to update the installs and envs for the fork with cloning yet, hang on a bit.

In the meantime, you can try uninstalling the conda or mamba gradio, and installing the pip gradio on the miniconda install. Maybe with environment-cuda-nightly.yml specifically.

Gradio changes the API weekly (it seems like it sometimes...) so if the version is slightly different things can break.

Try installing via pip fairseq, and via either audiolm_pytorch.

(conda fairseq was too out of date)

Traced it back to matplotlib probablly being out of date and after reinstalling that I'm getting:

2023-05-23 10:02:51.632034: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-05-23 10:02:52.382577: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Current working directory: /home/rlt/bark
Install dir: /home/jon/mamba_projects/bark_infinity_cloning/bark/bark_infinity/hubert
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /home/rlt/bark/bark_webui.py:35 in <module>                                  │
│                                                                              │
│     32                                                                       │
│     33 # If anyone is looking at this code, I just took gradio blocks kitche │
│     34                                                                       │
│ ❱   35 from bark_infinity.clonevoice import clone_voice                      │
│     36                                                                       │
│     37 import threading                                                      │
│     38 import time                                                           │
│                                                                              │
│ /home/rlt/bark/bark_infinity/clonevoice.py:232 in <module>                   │
│                                                                              │
│   229 │   generation.OFFLOAD_CPU = old                                       │
│   230 │   return f"Voice cloning process completed. You'll find your clones  │
│   231                                                                        │
│ ❱ 232 HuBERTManager.make_sure_hubert_installed()                             │
│   233 HuBERTManager.make_sure_tokenizer_installed()                          │
│   234                                                                        │
│   235                                                                        │
│                                                                              │
│ /home/rlt/bark/bark_infinity/hubert/hubert_manager.py:17 in                  │
│ make_sure_hubert_installed                                                   │
│                                                                              │
│   14 │   │   install_dir = os.path.join('/home/jon/mamba_projects/bark_infin │
│   15 │   │   print(f"Install dir: {install_dir}")                            │
│   16 │   │   if not os.path.isdir(install_dir):                              │
│ ❱ 17 │   │   │   os.mkdir(install_dir)                                       │
│   18 │   │                                                                   │
│   19 │   │   install_file = os.path.join(install_dir, 'hubert.pt')           │
│   20 │   │   download_url = 'https://dl.fbaipublicfiles.com/hubert/hubert_ba │
╰──────────────────────────────────────────────────────────────────────────────╯
FileNotFoundError: [Errno 2] No such file or directory: 
'/home/jon/mamba_projects/bark_infinity_cloning/bark/bark_infinity/hubert'

After changing ~bark/bark_infinity/hubert/hubert_manager.py to match what @rmcc3 put, it worked. Thanks!

import os.path
import shutil
import urllib.request

import huggingface_hub

class HuBERTManager:
    @staticmethod
    def get_base_dir():
        # Get the directory that this script is in
        return os.path.dirname(os.path.abspath(__file__))

    @staticmethod
    def make_sure_hubert_installed():
        base_dir = HuBERTManager.get_base_dir()

        print(f"Current working directory: {os.getcwd()}")

        install_dir = os.path.join(base_dir,'hubert')
        print(f"Install dir: {install_dir}")
        os.makedirs(install_dir, exist_ok=True)

        install_file = os.path.join(install_dir, 'hubert.pt')
        download_url = 'https://dl.fbaipublicfiles.com/hubert/hubert_base_ls960.pt'
        if not os.path.isfile(install_file):
            print('Downloading HuBERT small model')
            urllib.request.urlretrieve(download_url, install_file)
            print('Downloaded HuBERT')


    @staticmethod
    def make_sure_tokenizer_installed():
        base_dir = HuBERTManager.get_base_dir()

        install_dir = os.path.join(base_dir,'hubert')
        os.makedirs(install_dir, exist_ok=True)
        install_file = os.path.join(install_dir, 'tokenizer.pth')
        repo = 'GitMylo/bark-voice-cloning'
        file = 'quantifier_hubert_base_ls960_14.pth'
        if not os.path.isfile(install_file):
            print('Downloading HuBERT custom tokenizer')
            huggingface_hub.hf_hub_download(repo, file, local_dir=install_dir, local_dir_use_symlinks=False)
            shutil.move(os.path.join(install_dir, file), install_file)
            print('Downloaded tokenizer')

rmcc3 commented

After changing ~bark/bark_infinity/hubert/hubert_manager.py to match what @rmcc3 put, it worked. Thanks!

import os.path
import shutil
import urllib.request

import huggingface_hub

class HuBERTManager:
    @staticmethod
    def get_base_dir():
        # Get the directory that this script is in
        return os.path.dirname(os.path.abspath(__file__))

    @staticmethod
    def make_sure_hubert_installed():
        base_dir = HuBERTManager.get_base_dir()

        print(f"Current working directory: {os.getcwd()}")

        install_dir = os.path.join(base_dir,'hubert')
        print(f"Install dir: {install_dir}")
        os.makedirs(install_dir, exist_ok=True)

        install_file = os.path.join(install_dir, 'hubert.pt')
        download_url = 'https://dl.fbaipublicfiles.com/hubert/hubert_base_ls960.pt'
        if not os.path.isfile(install_file):
            print('Downloading HuBERT small model')
            urllib.request.urlretrieve(download_url, install_file)
            print('Downloaded HuBERT')


    @staticmethod
    def make_sure_tokenizer_installed():
        base_dir = HuBERTManager.get_base_dir()

        install_dir = os.path.join(base_dir,'hubert')
        os.makedirs(install_dir, exist_ok=True)
        install_file = os.path.join(install_dir, 'tokenizer.pth')
        repo = 'GitMylo/bark-voice-cloning'
        file = 'quantifier_hubert_base_ls960_14.pth'
        if not os.path.isfile(install_file):
            print('Downloading HuBERT custom tokenizer')
            huggingface_hub.hf_hub_download(repo, file, local_dir=install_dir, local_dir_use_symlinks=False)
            shutil.move(os.path.join(install_dir, file), install_file)
            print('Downloaded tokenizer')

You will need to update that code so it installs it next to the script. Right now, that code downloads the cloning models to its own folder, which will cause cloning to not work.

Sorry folks, was in a rush and then wasn't able to make the fixes. Home now, will do the quick stuff and update.

Kind of a dirty fix but I just symlinked the hubert files and it worked. Oddly enough it only sounds like the voice I cloned every other time I try to generate something.