Error while running the code

#4
by ahamedddd - opened

import torch
from transformers import pipeline

path to the audio file to be transcribed

audio = "/content/speech_segment.wav"
device = "cuda:0" if torch.cuda.is_available() else "cpu"

transcribe = pipeline(task="automatic-speech-recognition", model="vasista22/whisper-telugu-base", chunk_length_s=30, device=device)
transcribe.model.config.forced_decoder_ids = transcribe.tokenizer.get_decoder_prompt_ids(language="te", task="transcribe")

print('Transcription: ', transcribe(audio)["text"])

------

IndexError Traceback (most recent call last)
in <cell line: 11>()
9 transcribe.model.config.forced_decoder_ids = transcribe.tokenizer.get_decoder_prompt_ids(language="te", task="transcribe")
10
---> 11 print('Transcription: ', transcribe(audio)["text"])

7 frames
/usr/local/lib/python3.10/dist-packages/transformers/models/whisper/generation_whisper.py in _prepare_decoder_input_ids(cur_bsz, init_tokens, current_segments, batch_idx_map, do_condition_on_prev_tokens, prompt_ids, generation_config, config, device, suppress_tokens, kwargs)
1679 prev_start_of_text = getattr(generation_config, "prev_sot_token_id", None)
1680 if prev_start_of_text is None:
-> 1681 prev_start_of_text = suppress_tokens[-2] if suppress_tokens is not None else None
1682
1683 if any(do_condition_on_prev_tokens) and len(current_segments[0]) > 0:

IndexError: index -2 is out of bounds for dimension 0 with size 0

@vasista22 Could you help? Seems like a issue with suppress_tokens.

Sign up or log in to comment