suno-ai / bark

🔊 Text-Prompted Generative Audio Model
MIT License
35.24k stars 4.13k forks source link

No module named 'bark' #316

Open coffseducation opened 1 year ago

coffseducation commented 1 year ago

Hello,

I cannot get a script to run. I am using the default example. I seemed to have installed Bark:

pipx install git+https://github.com/suno-ai/bark.git --include-deps ⚠ Note: f2py was already on your PATH at /usr/bin/f2py ⚠ Note: f2py3 was already on your PATH at /usr/bin/f2py3 ⚠ Note: f2py3.11 was already on your PATH at /usr/bin/f2py3.11 ⚠ Note: cmake was already on your PATH at /usr/bin/cmake ⚠ Note: cpack was already on your PATH at /usr/bin/cpack ⚠ Note: ctest was already on your PATH at /usr/bin/ctest ⚠ Note: tqdm was already on your PATH at /usr/bin/tqdm installed package suno-bark 0.0.1a0, installed using Python 3.11.2 These apps are now globally available

When I run the default script which I labelled barktext.py I get:

python3 barktext.py
Traceback (most recent call last): File "/home/anarcho/bin/barktext.py", line 2, in from bark import SAMPLE_RATE, generate_audio, preload_models ModuleNotFoundError: No module named 'bark'

Operating System: Kubuntu 23.04 KDE Plasma Version: 5.27.4 KDE Frameworks Version: 5.104.0 Qt Version: 5.15.8 Kernel Version: 6.2.0-1003-lowlatency (64-bit) Graphics Platform: X11 Processors: 8 × Intel® Core™ i7-6700 CPU @ 3.40GHz Memory: 31.2 GiB of RAM Graphics Processor: Mesa Intel® HD Graphics 530 Manufacturer: Dell Inc. Product Name: Precision 5720 AIO

tongbaojia commented 1 year ago

When you installed it -- suno-bark 0.0.1a0, installed using Python 3.11.2 Is your python3 also 3.11.2, the same environment?

coffseducation commented 1 year ago

When you installed it -- suno-bark 0.0.1a0, installed using Python 3.11.2 Is your python3 also 3.11.2, the same environment?

Thanks for the reply. Unfortunately I do not know what that means. 🥴

jameswan commented 1 year ago

Using Python 3.11.1

Traceback (most recent call last): File "C:\Users\James\Desktop\articles\suno_text_to_voice.py", line 1, in from bark import SAMPLE_RATE, generate_audio, preload_models ImportError: cannot import name 'SAMPLE_RATE' from 'bark' (unknown location)

tongbaojia commented 1 year ago

This is a classic issue: the python environment you use to run suno differs from the python environment you installed suno.

I'd recommend using a virtual environment, installing suno there, and using it from that environment.

jameswan commented 1 year ago

This is a classic issue: the python environment you use to run suno differs from the python environment you installed suno.

I'd recommend using a virtual environment, installing suno there, and using it from that environment.

Thank you for clarifying. Can I please confirm what Python version is required? I'll create a new conda environment and install bark again.

When I execute: pip install git+https://github.com/suno-ai/bark.git

I get these errors: speechbrain 0.5.12 requires torch<=1.11,>=1.7, but you have torch 1.13.0 which is incompatible. pyannote-audio 2.1.1 requires soundfile<0.11,>=0.10.2, but you have soundfile 0.11.0 which is incompatible

tongbaojia commented 1 year ago

This is a classic issue: the python environment you use to run suno differs from the python environment you installed suno. I'd recommend using a virtual environment, installing suno there, and using it from that environment.

Thank you for clarifying. Can I please confirm what Python version is required? I'll create a new conda environment and install bark again.

When I execute: pip install git+https://github.com/suno-ai/bark.git

I get these errors: speechbrain 0.5.12 requires torch<=1.11,>=1.7, but you have torch 1.13.0 which is incompatible. pyannote-audio 2.1.1 requires soundfile<0.11,>=0.10.2, but you have soundfile 0.11.0 which is incompatible

Looks like your env isn't fresh -- there are some pre-installed stuff.

Any python > 3.8 is should be fine. I am on python 3.10.10 or 3.9.6 both works. If it helps:

boto3==1.26.138
botocore==1.29.138
certifi==2023.5.7
charset-normalizer==3.1.0
einops==0.6.1
encodec==0.1.1
filelock==3.12.0
fsspec==2023.5.0
funcy==2.0
huggingface-hub==0.14.1
idna==3.4
Jinja2==3.1.2
jmespath==1.0.1
MarkupSafe==2.1.2
mpmath==1.3.0
networkx==3.1
numpy==1.24.3
packaging==23.1
python-dateutil==2.8.2
PyYAML==6.0
regex==2023.5.5
requests==2.31.0
s3transfer==0.6.1
scipy==1.10.1
six==1.16.0
sympy==1.12
tokenizers==0.13.3
torch==2.0.1
torchaudio==2.0.2
tqdm==4.65.0
transformers==4.29.2
typing_extensions==4.6.0
urllib3==1.26.15
tongbaojia commented 1 year ago

sorry, I stopped using windows machines years ago exactly because of environment reasons.

This is not a suno problem but a windows / conda / python problem. Your conda version of python and your windows default python are different. Make sure (google how to do it) that you are running the script under your installed python on windows.

Good luck.

maxbrito500 commented 1 year ago

Hello,

I've followed the installation tutorial on a normal Ubuntu install 22.04 and had the exact same issue. I'm not a python developer so these environment situations are not straightforward to know in advance for non-python developers.

I've installed Python3 and shows version 3.10.6

git clone https://github.com/suno-ai/bark Cloning into 'bark'... remote: Enumerating objects: 787, done. remote: Counting objects: 100% (336/336), done. remote: Compressing objects: 100% (168/168), done. remote: Total 787 (delta 263), reused 176 (delta 167), pack-reused 451 Receiving objects: 100% (787/787), 2.58 MiB | 465.00 KiB/s, done. Resolving deltas: 100% (313/313), done.

brito@box:~/data$ cd bark && pip install . Defaulting to user installation because normal site-packages is not writeable Processing /home/brito/data/bark Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: UNKNOWN Building wheel for UNKNOWN (pyproject.toml) ... done Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=1784 sha256=06547f65284edc6ef0f6c1a0c2d557fa135a56ddac6ac49e05ceb8c9f88a9f16 Stored in directory: /tmp/pip-ephem-wheel-cache-c_bqmjqm/wheels/93/df/10/cfac35006a991587aee4848c2d7b749d0774a2abf274e5f679 Successfully built UNKNOWN Installing collected packages: UNKNOWN Attempting uninstall: UNKNOWN Found existing installation: UNKNOWN 0.0.0 Uninstalling UNKNOWN-0.0.0: Successfully uninstalled UNKNOWN-0.0.0 Successfully installed UNKNOWN-0.0.0

For information, there is no "python" command available by default on Ubuntu. So running the mentioned command line does not work:

python -m bark --text "Hello, my name is Suno." --output_filename "example.wav"

The solution is to call python3 instead:

python3 -m bark --text "Hello, my name is Suno." --output_filename "example.wav"

But when we do this, the same error message comes up:

/usr/bin/python3: No module named bark

The solution on Ubuntu 22.04 was:

sudo apt install python3 python3.10-venv
mkdir bark
cd bark
python3 -m venv venv
source venv/bin/activate
pip install git+https://github.com/suno-ai/bark.git

Then it finally installed pytorch, the other remaining dependencies and went forward:

python3 -m bark --text "Hello, my name is Suno." --output_filename "example.wav"

If you agree, please include these instructions on the main page, they will help more people adopt bark since it is a fantastic resource.

chenilim commented 1 year ago

As a python newbie, I struggled getting this to work with VSCode notebooks (long_form_generation.ipynb) on a Mac. What eventually worked for me was:

  1. Pick the Python version in the top-right dropdown in VSCode (3.8.13 in my case, which is from pyenv)
  2. Add a cell to the top with:
    %pip install git+https://github.com/suno-ai/bark.git
    %pip install nltk numpy
  3. I also had to add another cell with:
    import nltk
    nltk.download('punkt')

The notebook was able to run after that. Hope this helps someone.