suno-ai / bark

🔊 Text-Prompted Generative Audio Model
MIT License
36.3k stars 4.27k forks source link

cannot import name 'SAMPLE_RATE' from 'bark' #195

Closed BorisMolch closed 1 year ago

BorisMolch commented 1 year ago

Using anaconda3

did pip install git+https://github.com/suno-ai/bark.git

running code from example in readme , and getting:

(base) C:\Users\mcbub>python bbbtest.py Traceback (most recent call last): File "C:\Users\mcbub\bbbtest.py", line 1, in from bark import SAMPLE_RATE, generate_audio, preload_models ImportError: cannot import name 'SAMPLE_RATE' from 'bark' (C:\Users\mcbub\anaconda3\lib\site-packages\bark__init__.py)

greenyoyo123 commented 1 year ago

I'm experiencing the same issue using a fresh install of windows 10 with a 5800x3d and 5700xt.

ImportError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from bark import SAMPLE_RATE, generate_audio, preload_models 2 from IPython.display import Audio 4 # download and load all models

ImportError: cannot import name 'SAMPLE_RATE' from 'bark' (unknown location)

greenyoyo123 commented 1 year ago

I got further in. My problem was i wasn't starting cmd and starting jupyter notebook from the right folder now i'm onto a new error.

ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from bark import SAMPLE_RATE, generate_audio, preload_models 2 from IPython.display import Audio 4 # download and load all models

File ~\Desktop\bark\bark\bark__init__.py:1 ----> 1 from .api import generate_audio, text_to_semantic, semantic_to_waveform, save_as_prompt 2 from .generation import SAMPLE_RATE, preload_models

File ~\Desktop\bark\bark\bark\api.py:5 1 from typing import Optional 3 import numpy as np ----> 5 from .generation import codec_decode, generate_coarse, generate_fine, generate_text_semantic 8 def text_to_semantic( 9 text: str, 10 history_prompt: Optional[str] = None, 11 temp: float = 0.7, 12 silent: bool = False, 13 ): 14 """Generate semantic array from text. 15 16 Args: (...) 23 numpy semantic array to be fed into semantic_to_waveform 24 """

File ~\Desktop\bark\bark\bark\generation.py:8 5 import re 6 import requests ----> 8 from encodec import EncodecModel 9 import funcy 10 import logging

ModuleNotFoundError: No module named 'encodec'

Hel5ing commented 1 year ago

same problem

mcamac commented 1 year ago

Can try one of:

pip install -U encodec # stable release
pip install -U git+https://git@github.com/facebookresearch/encodec#egg=encodec # bleeding edge
BorisMolch commented 1 year ago

pip install -U git+https://git@github.com/facebookresearch/encodec#egg=encodec

i've tried both. still getting the saem error.

Jeru2023 commented 1 year ago

pip install -U git+https://git@github.com/facebookresearch/encodec#egg=encodec

i've tried both. still getting the saem error.

pip list check what package you've installed, make sure you have not run "pip install bark" before as it will incur conflict.

chillin2 commented 1 year ago

same error here

lee-b commented 1 year ago

You need to pip uninstall bark, then pip install git+https://github.com/suno-ai/bark. bark has a naming conflict with another pypi package, and is now called suno-bark in its poetry package, but seems to need to be installed from git as just given, and still uses the bark module name. I guess this'll get resolved over time in the bark package and the requirements and import here will need to change to match, but for now, the commands given here should get you going.

lee-b commented 1 year ago

If you have no other copy of bark installed, so that the following works (looks as given, with this ModuleNotFoundError):

$ python3 -c 'import bark'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'bark'

then doing a pip3 install git+https://github.com/suno-ai/bark, should allow this to work:

$ python3 -c 'from bark import SAMPLE_RATE; print("Sample rate is", SAMPLE_RATE)'
Sample rate is 24000

If you're getting any other results you likely have conflicting python installations and should start from scratch, and using a clean virtual python environment (pyenv virtualenv or a python venv) with no system packages involved in that virtual environment.

Anyway, it's very slow, I wouldn't bother right now.

Diyago commented 1 year ago

reinstalling solved the problem, I had old env from 2021. Thank you

gkucsko commented 1 year ago

great!

digits122 commented 1 year ago

same problem

lee-b commented 1 year ago

Same mistake, @digits122 ; it happens when the wrong library is installed, as there are two similarly named libraries.

Julien-cpsn commented 1 year ago

I had the same problem, just don't call your file bark.py :))

staticVlo commented 1 year ago

Check if your python filename is also called bark.py If yes, modify it

tomredman commented 1 year ago

I had the same problem, just don't call your file bark.py :))

LOL

Got me :) Thanks!

Ronkiro commented 1 year ago

solved my case by using Python 3.8 (i am using pyenv for windows)