suno-ai / bark

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

Error when tried to use with coqui TTS #487

Closed drishyakarki closed 1 year ago

drishyakarki commented 1 year ago

I cloned the suno-bark from huggingface and followed the docs, when i try to clone voice it gives the following error

the code is

from TTS.tts.configs.bark_config import BarkConfig
from TTS.tts.models.bark import Bark
from scipy.io.wavfile import write as write_wav

config = BarkConfig()
model = Bark.init_from_config(config)
model.load_checkpoint(config, checkpoint_dir="bark/", eval=True)
model.to("cuda")

text = "Hi this is me Barack Obama"

output_dict = model.synthesize(
    text,
    config,
    speaker_id="speaker",
    voice_dirs="bark_voices",
    temperature=0.95
)

write_wav("output.wav", 24000, output_dict["wav"])

the error is

Traceback (most recent call last):
  File "/home/peshal/drishya/barkTTS/cloneVoice.py", line 7, in <module>
    model.load_checkpoint(config, checkpoint_dir="bark/", eval=True)
  File "/home/peshal/drishya/barkTTS/venv/lib/python3.10/site-packages/TTS/tts/models/bark.py", line 281, in load_checkpoint
    self.load_bark_models()
  File "/home/peshal/drishya/barkTTS/venv/lib/python3.10/site-packages/TTS/tts/models/bark.py", line 50, in load_bark_models
    self.semantic_model, self.config = load_model(
  File "/home/peshal/drishya/barkTTS/venv/lib/python3.10/site-packages/TTS/tts/layers/bark/load_model.py", line 121, in load_model
    checkpoint = torch.load(ckpt_path, map_location=device)
  File "/home/peshal/drishya/barkTTS/venv/lib/python3.10/site-packages/torch/serialization.py", line 1028, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/peshal/drishya/barkTTS/venv/lib/python3.10/site-packages/torch/serialization.py", line 1246, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.
drishyakarki commented 1 year ago

Hi, so it was a simple mistake! I didn't have git lfs installed!

ShanthiniMichael commented 10 months ago

Didn't work for me. Any other solution? Thanks in advance.

drishyakarki commented 10 months ago

what is the error you got?

ShanthiniMichael commented 10 months ago

The following error,

Traceback (most recent call last): File "/Users/apple/Documents/lipsync/bark_tts/clone_2.py", line 8, in model.load_checkpoint(config, checkpoint_dir="bark/", eval=True) File "/usr/local/anaconda3/lib/python3.11/site-packages/TTS/tts/models/bark.py", line 281, in load_checkpoint self.load_bark_models() File "/usr/local/anaconda3/lib/python3.11/site-packages/TTS/tts/models/bark.py", line 50, in load_bark_models self.semantic_model, self.config = load_model( ^^^^^^^^^^^ File "/usr/local/anaconda3/lib/python3.11/site-packages/TTS/tts/layers/bark/load_model.py", line 121, in load_model checkpoint = torch.load(ckpt_path, map_location=device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/anaconda3/lib/python3.11/site-packages/torch/serialization.py", line 1028, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/anaconda3/lib/python3.11/site-packages/torch/serialization.py", line 1246, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _pickle.UnpicklingError: invalid load key, '<'.

ShanthiniMichael commented 10 months ago

I am trying to clone again after installing git-lfs. But it is not downloading, it is almost 1 hour, but still not cloning the project.

drishyakarki commented 10 months ago

First remove the before-cloned folders, then try executing the command. Sometimes, if the download stucked, cancelling it and re-running the command helped.

ShanthiniMichael commented 10 months ago

Thank you worked :).