---------------------------------------------------------------------------AttributeError Traceback (most recent call last)
Cell In[17], line 1----> 1 model =EncodecModel.encodec_model_24khz()
AttributeError: type object 'EncodecModel' has no attribute 'encodec_model_24khz'
Usage
wav, sr = torchaudio.load("../data/audio/obama.wav")# wav, sr = torch.rand((1, 24000)), 24000# wav, sr = np.random.random((1, 24000)), 24000encodec = EncoDec(device='cpu')codes = encodec(wav,sr)print(f"wav: {wav.shape}, code: {codes.shape} ")plt.rcParams["figure.figsize"] = (5,5)plt.xlabel('frames')plt.ylabel('quantization')plt.imshow(codes.squeeze().cpu().numpy())decoded = encodec.decode(codes)plot_waveform(decoded.detach().cpu().squeeze(0), encodec.sample_rate)
---------------------------------------------------------------------------AttributeError Traceback (most recent call last)
Cell In[12], line 5 1 wav, sr = torchaudio.load("../data/audio/obama.wav")
2# wav, sr = torch.rand((1, 24000)), 24000 3# wav, sr = np.random.random((1, 24000)), 24000----> 5 encodec =EncoDec(device='cpu') 6 codes = encodec(wav,sr)
7print(f"wav: {wav.shape}, code: {codes.shape}")
Cell In[11], line 4, in EncoDec.__init__(self, device) 3def__init__(self, device:str='cpu'):
----> 4self.model =EncodecModel.encodec_model_24khz()
5self._device = device
6self.model.to(self._device)
AttributeError: type object 'EncodecModel' has no attribute 'encodec_model_24khz'
### HF# dummy dataset, however you can swap this with an dataset on the 🤗 hub or bring your ownlibrispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")# load the model + processor (for pre-processing the audio)model = EncodecModel.from_pretrained("facebook/encodec_24khz")processor = AutoProcessor.from_pretrained("facebook/encodec_24khz")librispeech_dummy[0]# cast the audio data to the correct sampling rate for the modellibrispeech_dummy = librispeech_dummy.cast_column("audio", Audio(sampling_rate=processor.sampling_rate))audio_sample = librispeech_dummy[0]["audio"]["array"]