A LoRA-finetuned version of
openai/whisper-tiny for
Japanese Automatic Speech Recognition (ASR), trained on the
ReazonSpeech dataset using Parameter-Efficient Fine-Tuning (PEFT/LoRA).
This model applies Low-Rank Adaptation (LoRA) on top of Whisper Tiny to improve Japanese transcription quality while keeping the number of trainable parameters small. LoRA adapters are merged post-training for easy deployment.
1import torch
2from transformers import AutoProcessor, WhisperForConditionalGeneration
3from peft import PeftModel
4
5# Load base model and processor
6base_model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny")
7processor = AutoProcessor.from_pretrained("openai/whisper-tiny")
8
9# Load LoRA adapter
10model = PeftModel.from_pretrained(base_model, "dungca/whisper-tiny-ja-lora")
11model.eval()
12
13# Transcribe audio
14def transcribe(audio_array, sampling_rate=16000):
15 inputs = processor(
16 audio_array,
17 sampling_rate=sampling_rate,
18 return_tensors="pt"
19 )
20 with torch.no_grad():
21 predicted_ids = model.generate(
22 inputs["input_features"],
23 language="japanese",
24 task="transcribe"
25 )
26 return processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
1from transformers import pipeline
2from peft import PeftModel, PeftConfig
3from transformers import WhisperForConditionalGeneration, AutoProcessor
4
5config = PeftConfig.from_pretrained("dungca/whisper-tiny-ja-lora")
6base_model = WhisperForConditionalGeneration.from_pretrained(config.base_model_name_or_path)
7model = PeftModel.from_pretrained(base_model, "dungca/whisper-tiny-ja-lora")
8
9processor = AutoProcessor.from_pretrained(config.base_model_name_or_path)
10
11asr = pipeline(
12 "automatic-speech-recognition",
13 model=model,
14 tokenizer=processor.tokenizer,
15 feature_extractor=processor.feature_extractor,
16 generate_kwargs={"language": "japanese", "task": "transcribe"},
17)
18
19result = asr("your_audio.wav")
20print(result["text"])
Evaluated on the ReazonSpeech validation split.
For production use cases requiring high accuracy, consider using
openai/whisper-large-v3 or waiting for the upcoming
whisper-small-ja-lora checkpoint.
If you use this model, please cite the base Whisper model and the LoRA/PEFT method:
1@misc{radford2022whisper,
2 title={Robust Speech Recognition via Large-Scale Weak Supervision},
3 author={Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
4 year={2022},
5 eprint={2212.04356},
6 archivePrefix={arXiv}
7}
8
9@misc{hu2021lora,
10 title={LoRA: Low-Rank Adaptation of Large Language Models},
11 author={Hu, Edward J. and others},
12 year={2021},
13 eprint={2106.09685},
14 archivePrefix={arXiv}
15}