Instructions to use facebook/hf-seamless-m4t-medium with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use facebook/hf-seamless-m4t-medium with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="facebook/hf-seamless-m4t-medium")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("facebook/hf-seamless-m4t-medium") model = AutoModel.from_pretrained("facebook/hf-seamless-m4t-medium", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Error while running the model
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.
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.
