transformers icon indicating copy to clipboard operation
transformers copied to clipboard

AttributeError: 'Wav2Vec2Processor' object has no attribute 'set_lang'

Open LYPinASR opened this issue 2 years ago • 3 comments

System Info

  • transformers version: 4.28.1
  • Platform: Linux-4.15.0-20-generic-x86_64-with-glibc2.10
  • Python version: 3.8.0
  • Huggingface_hub version: 0.13.4
  • Safetensors version: not installed
  • PyTorch version (GPU?): 1.12.1 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

No response

Information

  • [X] The official example scripts
  • [ ] My own modified scripts

Tasks

  • [X] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [ ] My own task or dataset (give details below)

Reproduction

from transformers import Wav2Vec2ForCTC, AutoProcessor

ckpt = "./mms-1b-all/"

processor = AutoProcessor.from_pretrained(ckpt) model = Wav2Vec2ForCTC.from_pretrained(ckpt) # requires only 3GB of CPU RAM

target_lang = "esp"

processor.set_lang("esp") model.load_adapter("esp") # This will load a file called "adapter.esp.bin" from: https://huggingface.co/patrickvonplaten/mms-1b-all , cache it and replace the adapter

model.to("cuda")

audio, sr = sf.read("/home/lenovo/下载/audio.flac") #/home/lenovo/project/fairseq/content/audio_samples/1.wav

inputs = processor(audio, sampling_rate=sr, return_tensors="pt")

with torch.no_grad(): logits = model(**inputs).logits

transcription = processor.batch_decode(logits.argmax(-1))[0]

print(f"Transcription: {transcription}")

Expected behavior

Fix this error, and output the correct language, such as 'kor'

LYPinASR avatar Jun 01 '23 02:06 LYPinASR

The corresponding PR has not been merged yet.

sgugger avatar Jun 01 '23 13:06 sgugger

PR merged.

Also feel free to check out:

  • https://huggingface.co/docs/transformers/main/en/model_doc/mms
  • https://github.com/huggingface/transformers/pull/23813
  • https://huggingface.co/facebook/mms-1b-all

patrickvonplaten avatar Jun 02 '23 11:06 patrickvonplaten

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Jul 01 '23 15:07 github-actions[bot]