Error while running the model

#24
by pehdrew - opened

Hi, I'm trying to run the code shown in the page, but I ran into a problem here's my code:

'''
from transformers import AutoProcessor, SeamlessM4Tv2Model
import torch, torchaudio

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

processor = AutoProcessor.from_pretrained("facebook/hf-seamless-m4t-medium")
model = SeamlessM4Tv2Model.from_pretrained("facebook/hf-seamless-m4t-medium").to(device)

from audio

audio, orig_freq = torchaudio.load("test.wav")
audio = torchaudio.functional.resample(audio, orig_freq=orig_freq, new_freq=16_000)
audio_inputs = processor(audios=audio, return_tensors="pt").to(device)
audio_array_from_audio = model.generate(**audio_inputs, tgt_lang="fra")[0].cpu().numpy().squeeze() # fra is the French language

torchaudio.save("generated_audio_from_audio.wav", torch.tensor(audio_array_from_audio), 16000)

'''

unfortunately this results in the following error, I don't know how solve it, I tried searching online but it doesn't seem to be a common error or I'm missing a very important detail, if anyone could help, that would be much appreciated!

The error is:
ValueError: This model generation config doesn't have a id_to_text key which maps
token ids to subwords. Make sure to load the right generation config.

image.png

pehdrew changed discussion title from Error while running the modele to Error while running the model

Hello this may be a very late comment. But for the sake of anyone having this issue.
This arises from a mismatch between the model class and the checkpoint. facebook/hf-seamless-m4t-medium is V1 not V2, thus requires the SeamlessM4TModel not the SeamlessM4Tv2Model class.

Sign up or log in to comment