python example please

#1
by skoll520 - opened

normally I use the whisper large from openai, but, using transformers library, can you give me an example of python code? I can't make it run anyway

Ol谩, @skoll520 馃憢馃徎 thanks for your interest in this model.

Here's a snippet you can copy to run Whisper models with transformers :

from transformers import pipeline
import torch

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

transcribe = pipeline(
    task="automatic-speech-recognition",
    model="jlondonobo/whisper-large-v2-pt",
    chunk_length_s=30,
    device=device,
)

transcribe.model.config.forced_decoder_ids = transcribe.tokenizer.get_decoder_prompt_ids(language="pt", task="transcribe")

# audio files can be of any type (.mp3, .m4a, .wav)
transcribe("audio.m4a")["text"]

I would encourage you to use the updated version of this model. It is significantly more precise with the same inference time.

Sign up or log in to comment