# Pretrained wav2vec2 speech to text - decoded text is gibberish

**URL:** <https://discuss.huggingface.co/t/pretrained-wav2vec2-speech-to-text-decoded-text-is-gibberish/42954>\
**Category:** Models\
**Created:** [June 12, 2023, 4:25pm UTC](https://discuss.huggingface.co/t/pretrained-wav2vec2-speech-to-text-decoded-text-is-gibberish/42954 "2023-06-12T16:25:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihaelagrigore](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@mihaelagrigore](https://discuss.huggingface.co/u/mihaelagrigore)\
**Post date:** [June 12, 2023, 4:25pm UTC](https://discuss.huggingface.co/t/pretrained-wav2vec2-speech-to-text-decoded-text-is-gibberish/42954/1 "2023-06-12T16:25:17Z")

</div>

I am trying to do **inference** using the **pretrained wav2vec2-base-960H** on a couple of audio files on English speakers conversation.

The decoded text looks like mostly gibberish.  
I was wondering how come, maybe I am doing something wrong.

The code I’m using is the most basic inference from the [\> wav2vec github page example](https://github.com/facebookresearch/fairseq/blob/main/examples/wav2vec/README.md)

```auto
# !pip install transformers
# !pip install datasets
import soundfile as sf
import torch
from datasets import load_dataset
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor

# load pretrained model
processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")

librispeech_samples_ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")

# load audio
audio_input, sample_rate = sf.read(librispeech_samples_ds[0]["file"])

# pad input values and return pt tensor
input_values = processor(audio_input, sampling_rate=sample_rate, return_tensors="pt").input_values  

# INFERENCE

# retrieve logits & take argmax
logits = model(input_values).logits # this is the line where OOM appears
predicted_ids = torch.argmax(logits, dim=-1)

# transcribe
transcription = processor.decode(predicted_ids[0])

```

The output I get does not look like English words for a large part of it.

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/f/c/fc9649cee24ae58ae66da4c243e274ea86298dfd.png)

I cannot believe this is a normal behavior for a tool that got the WER reported in their research papers.

And many other tools are being benchmarked against wav2vec2, so I’m very surprised this is actually a state of the art transcription that get one of the lowest WERs.

As can be been in the image of the `transcription` variable contents, most words are not even real words.

Is there something that I am missing ? Does this transcription still need some processing ?
