Whisper Small

Fine-Tuned for Polish language recognition based on openai/whisper-small

Description

  • Architecture: OpenAI Whisper Small
  • Language: Polish
  • Tasks: Speech transcription to text
  • Training: Full Fine-Tuning
  • Hardware: AMD Radeon 7800 XT

Usage

  • Offline speech transcription on consumer GPU on end devices CPUs
  • .bin files are converted to use in mobile keyboard q5_0 recomended
import torch
import librosa
import warnings
from transformers import WhisperProcessor, WhisperForConditionalGeneration

warnings.filterwarnings("ignore")

model_id = "bobix/whisper-small-polish"
base_model_id = "openai/whisper-small"

processor = WhisperProcessor.from_pretrained(base_model_id, language="Polish", task="transcribe")

model = WhisperForConditionalGeneration.from_pretrained(
    model_id,
    attn_implementation="eager"
)

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

audio_file = "test.wav"

try:
    speech, rate = librosa.load(audio_file, sr=16000)
except FileNotFoundError:
    print(f"File could not be found")
    exit()

inputs = processor(speech, sampling_rate=16000, return_tensors="pt")
inputs = {k: v.to(device) for k, v in inputs.items()}

attention_mask = inputs.get("attention_mask", torch.ones_like(inputs["input_features"]))
forced_decoder_ids = processor.get_decoder_prompt_ids(language="polish", task="transcribe")

with torch.no_grad():
    predicted_ids = model.generate(
        inputs["input_features"],
        attention_mask=attention_mask,
        forced_decoder_ids=forced_decoder_ids,
        max_length=448
    )

transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]

print()
print(transcription)
Downloads last month
46
Safetensors
Model size
0.2B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for bobix/whisper-small-polish

Finetuned
(3550)
this model