Wav2Vec2 for long audio with N-gram Language model
I'm trying to use Wav2Vec2 for transcribing a long audio file following this blog post here (https://huggingface.co/blog/asr-chunking). 

The mentioned example is this :

```
from transformers import pipeline
pipe = pipeline(model="facebook/wav2vec2-base-960h")
output = pipe("very_long_file.mp3", chunk_length_s=10, stride_length_s=(4, 2))
```

The author said that it is possible to use N-GRAM LM but it is not clear to me as the pipeline produces only the "text", not the logits. Som my question is **how to let the pipeline produces logits instead of pure text**? 


according to this (https://huggingface.co/blog/wav2vec2-with-ngram) and source for pipeline if the model has an N GRAM  LM as the decoder it should be used automatically used for decoding if pyctcdecode and kenlm are installed<|||||>As @Dharisd said, I will help you out with a little bit of code snippet. First thing to do is to install pyctcdecode and kenlm. Use:

`!pip install pyctcdecode`
`!pip install https://github.com/kpu/kenlm/archive/master.zip`

Next make the changes in the file _transformers/pipelines/automatic_speech_recognition.py_ . Add the following code in the line after 315.
`return logits` (This will return the logits instead of text when you use pipeline).

Finally, make sure you are using the N GRAM LM instead of _"facebook/wav2vec2-base-960h"_. The following snippet will give you the desired output:

```
from transformers import pipeline
pipe = pipeline(model="patrickvonplaten/wav2vec2-base-100h-with-lm")
output = pipe("very_long_file.mp3", chunk_length_s=10, stride_length_s=(4, 2))
```

Hope this helps! :D



<|||||>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](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.