Audio-to-Audio
PyTorch
Safetensors
xcodec2

You are using a model of type xcodec2 to instantiate a model of type xcodec. This is not supported for all configurations of models and can yield errors.

#10
by shuqinjun - opened

could anyone help me?

================================================================================

my test script:

import torch
import soundfile as sf
from transformers import AutoConfig

from xcodec2.modeling_xcodec2 import XCodec2Model

model_path = "./pretrained_models/xcodec2"

model = XCodec2Model.from_pretrained(model_path)
model.eval().cuda()

wav, sr = sf.read("test.wav")
wav_tensor = torch.from_numpy(wav).float().unsqueeze(0) # Shape: (1, T)

with torch.no_grad():

Only 16khz speech

Only supports single input. For batch inference, please refer to the link below.

vq_code = model.encode_code(input_waveform=wav_tensor)
print("Code:", vq_code )  

recon_wav = model.decode_code(vq_code).cpu()       # Shape: (1, 1, T')

sf.write("reconstructed.wav", recon_wav[0, 0, :].numpy(), sr)
print("Done! Check reconstructed.wav")

==============================================================================================================================
the flollowing is the err:

(llasa) yunfeiyang@ubuntuserver:~/LLaSA_training$ python3 ./xcodec_test.py
You are using a model of type xcodec2 to instantiate a model of type xcodec. This is not supported for all configurations of models and can yield errors.
Traceback (most recent call last):
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/utils/_http.py", line 406, in hf_raise_for_status
response.raise_for_status()
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://mirror.tuna.tsinghua.edu.cn/hugging-face/facebook/w2v-bert-2.0/resolve/main/config.json

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1746, in _get_metadata_or_catch_error
metadata = get_hf_file_metadata(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1666, in get_hf_file_metadata
r = _request_wrapper(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 364, in _request_wrapper
response = _request_wrapper(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 388, in _request_wrapper
hf_raise_for_status(response)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/utils/_http.py", line 477, in hf_raise_for_status
raise _format(HfHubHTTPError, str(e), response) from e
huggingface_hub.errors.HfHubHTTPError: 404 Client Error: Not Found for url: https://mirror.tuna.tsinghua.edu.cn/hugging-face/facebook/w2v-bert-2.0/resolve/main/config.json

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/transformers/utils/hub.py", line 403, in cached_file
resolved_file = hf_hub_download(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/utils/_deprecation.py", line 101, in inner_f
return f(*args, **kwargs)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1232, in hf_hub_download
return _hf_hub_download_to_cache_dir(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1339, in _hf_hub_download_to_cache_dir
_raise_on_head_call_error(head_call_error, force_download, local_files_only)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1857, in _raise_on_head_call_error
raise LocalEntryNotFoundError(
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/yunfeiyang/LLaSA_training/./xcodec_test.py", line 10, in
model = XCodec2Model.from_pretrained(model_path)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3886, in from_pretrained
model = cls(config, *model_args, **model_kwargs)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/xcodec2/modeling_xcodec2.py", line 19, in init
self.semantic_model = Wav2Vec2BertModel.from_pretrained(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3408, in from_pretrained
config, model_kwargs = cls.config_class.from_pretrained(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/transformers/configuration_utils.py", line 541, in from_pretrained
config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/transformers/configuration_utils.py", line 570, in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/transformers/configuration_utils.py", line 629, in _get_config_dict
resolved_config_file = cached_file(
File "/home/yunfeiyang/anaconda3/envs/llasa/lib/python3.10/site-packages/transformers/utils/hub.py", line 446, in cached_file
raise EnvironmentError(
OSError: We couldn't connect to 'https://mirror.tuna.tsinghua.edu.cn/hugging-face' to load this file, couldn't find it in the cached files and it looks like facebook/w2v-bert-2.0 is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

shuqinjun changed discussion status to closed

Sign up or log in to comment